Due to the amount of code used in this week's lecture notebooks, only the solutions to the self-tests are included here rather than all code required to run the self-tests. Attempting to run this code will fail, it is intended for reference only.
James_Jones=Shotlog[(Shotlog.shoot_player == 'James Jones')]
g = sns.FacetGrid(James_Jones, col="date", col_wrap=4)
g = g.map(plt.plot, "time", "current_shot_hit", marker='o', linewidth=0)
Use regression analysis to test "hot hand" for Cheick Diallo
reg_Diallo = sm.ols(formula = 'error ~ lagerror+home_game+opponent_previous_shot+points+time_from_last_shot+quarter', data= Cheick_Diallo).fit()
print(reg_Diallo.summary())
reg_Diallo_wls = sm.wls(formula = 'error ~ lagerror+home_game+opponent_previous_shot+points+time_from_last_shot+quarter', weights=1/Cheick_Diallo['shot_per_game'] , data=Cheick_Diallo).fit()
print(reg_Diallo_wls.summary())