Note on Self-Tests for Week 6

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.

Self Test - 1 Solution

Graph the prediction error for James Jones

  • Separate the shots by game
  • Interpret your result
In [ ]:
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)

Self Test - 2 Solution

Use regression analysis to test "hot hand" for Cheick Diallo

  1. Run an ordinary least square regression of current error on lagged error for Cheick Diallo.
  2. Run a weighted least sqaure regression of current error on lagged error for Cheick Diallo, weight=1/shot_per_game.
  3. Interpret your regression results.
In [ ]:
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())
In [ ]:
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())