Originally posted by George Ford
View Post
I figured out that my problem was that I didn't insert 0 for untreated teams in the t2t variable. I added the command: "replace t2t = 0 if TreatmentGroup == 0", then ran it again and got these new figures (respectively):
How does it look now?
In addition, I ran this code as well, and got these results:
Code:
. g time_to_treat = Year - _nfd (552 missing values generated) . replace time_to_treat = 0 if missing(_nfd) (552 real changes made) . g treatt = !missing(_nfd) . eventdd OverallBalanceDeficit, timevar(time_to_treat) method(hdfe, absorb(team_id Year) cluster (team_id)) (MWFE estimator converged in 5 iterations) HDFE Linear regression Number of obs = 1,178 Absorbing 2 HDFE groups F( 21, 76) = 2.55 Statistics robust to heteroskedasticity Prob > F = 0.0016 R-squared = 0.4236 Adj R-squared = 0.3630 Within R-sq. = 0.0277 Number of clusters (team_id) = 77 Root MSE = 29.9487 (Std. err. adjusted for 77 clusters in team_id) ------------------------------------------------------------------------------ | Robust OverallBal~t | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- lead11 | -.4769937 13.51305 -0.04 0.972 -27.39057 26.43658 lead10 | -6.577794 13.5253 -0.49 0.628 -33.51576 20.36017 lead9 | -12.73715 18.76164 -0.68 0.499 -50.10419 24.62988 lead8 | -3.008794 11.56542 -0.26 0.795 -26.04332 20.02573 lead7 | -5.773172 9.715021 -0.59 0.554 -25.12231 13.57597 lead6 | -8.482715 10.97212 -0.77 0.442 -30.33558 13.37015 lead5 | -7.422983 9.017974 -0.82 0.413 -25.38384 10.53787 lead4 | -13.98219 8.643466 -1.62 0.110 -31.19714 3.232769 lead3 | -8.853627 8.223487 -1.08 0.285 -25.23212 7.524868 lead2 | -9.670522 7.500074 -1.29 0.201 -24.60821 5.26717 lag0 | -4.448779 7.645899 -0.58 0.562 -19.67691 10.77935 lag1 | -22.27183 7.321703 -3.04 0.003 -36.85426 -7.689393 lag2 | -16.29569 8.182697 -1.99 0.050 -32.59294 .0015674 lag3 | -17.22842 9.309728 -1.85 0.068 -35.77035 1.313513 lag4 | -17.84253 12.30589 -1.45 0.151 -42.35185 6.666782 lag5 | -15.0645 7.692217 -1.96 0.054 -30.38487 .2558819 lag6 | -23.63615 9.27095 -2.55 0.013 -42.10084 -5.171448 lag7 | -17.53306 12.15825 -1.44 0.153 -41.74831 6.682197 lag8 | -30.45896 11.39987 -2.67 0.009 -53.16377 -7.754145 lag9 | -30.07115 10.49391 -2.87 0.005 -50.97157 -9.170722 lag10 | -2.396095 27.59002 -0.09 0.931 -57.34637 52.55418 _cons | 14.27427 6.95233 2.05 0.043 .4275061 28.12104 ------------------------------------------------------------------------------ Absorbed degrees of freedom: -----------------------------------------------------+ Absorbed FE | Categories - Redundant = Num. Coefs | -------------+---------------------------------------| team_id | 77 77 0 *| Year | 16 1 15 | -----------------------------------------------------+ * = FE nested within cluster; treated as redundant for DoF computation . summ time_to_treat Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- time_to_tr~t | 1,178 .2928693 3.520779 -11 10 . g shifted_ttt = time_to_treat - r(min) . summ shifted_ttt if time_to_treat == -1 Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- shifted_ttt | 42 10 0 10 10 . local true_neg1 = r(mean) . reghdfe OverallBalanceDeficit ib`true_neg1'.shifted_ttt, a(team_id Year) vce(cluster team_id) (MWFE estimator converged in 5 iterations) HDFE Linear regression Number of obs = 1,178 Absorbing 2 HDFE groups F( 21, 76) = 2.55 Statistics robust to heteroskedasticity Prob > F = 0.0016 R-squared = 0.4236 Adj R-squared = 0.3630 Within R-sq. = 0.0277 Number of clusters (team_id) = 77 Root MSE = 29.9487 (Std. err. adjusted for 77 clusters in team_id) ------------------------------------------------------------------------------ | Robust OverallBal~t | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- shifted_ttt | 0 | -.4769937 13.51305 -0.04 0.972 -27.39057 26.43658 1 | -6.577794 13.5253 -0.49 0.628 -33.51576 20.36017 2 | -12.73715 18.76164 -0.68 0.499 -50.10419 24.62988 3 | -3.008794 11.56542 -0.26 0.795 -26.04332 20.02573 4 | -5.773172 9.715021 -0.59 0.554 -25.12231 13.57597 5 | -8.482715 10.97212 -0.77 0.442 -30.33558 13.37015 6 | -7.422983 9.017974 -0.82 0.413 -25.38384 10.53787 7 | -13.98219 8.643466 -1.62 0.110 -31.19714 3.232769 8 | -8.853627 8.223487 -1.08 0.285 -25.23212 7.524868 9 | -9.670522 7.500074 -1.29 0.201 -24.60821 5.26717 11 | -4.448779 7.645899 -0.58 0.562 -19.67691 10.77935 12 | -22.27183 7.321703 -3.04 0.003 -36.85426 -7.689393 13 | -16.29569 8.182697 -1.99 0.050 -32.59294 .0015674 14 | -17.22842 9.309728 -1.85 0.068 -35.77035 1.313513 15 | -17.84253 12.30589 -1.45 0.151 -42.35185 6.666782 16 | -15.0645 7.692217 -1.96 0.054 -30.38487 .2558819 17 | -23.63615 9.27095 -2.55 0.013 -42.10084 -5.171448 18 | -17.53306 12.15825 -1.44 0.153 -41.74831 6.682197 19 | -30.45896 11.39987 -2.67 0.009 -53.16377 -7.754145 20 | -30.07115 10.49391 -2.87 0.005 -50.97157 -9.170722 21 | -2.396095 27.59002 -0.09 0.931 -57.34637 52.55418 | _cons | 14.27427 6.95233 2.05 0.043 .4275061 28.12104 ------------------------------------------------------------------------------ Absorbed degrees of freedom: -----------------------------------------------------+ Absorbed FE | Categories - Redundant = Num. Coefs | -------------+---------------------------------------| team_id | 77 77 0 *| Year | 16 1 15 | -----------------------------------------------------+ * = FE nested within cluster; treated as redundant for DoF computation . g coef = . (1,178 missing values generated) . g se = . (1,178 missing values generated) . levelsof shifted_ttt, l(times) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 . foreach t in `times' { 2. replace coef = _b[`t'.shifted_ttt] if shifted_ttt == `t' 3. replace se = _se[`t'.shifted_ttt] if shifted_ttt == `t' 4. } (3 real changes made) (3 real changes made) (5 real changes made) (5 real changes made) (9 real changes made) (9 real changes made) (11 real changes made) (11 real changes made) (13 real changes made) (13 real changes made) (26 real changes made) (26 real changes made) (39 real changes made) (39 real changes made) (40 real changes made) (40 real changes made) (40 real changes made) (40 real changes made) (40 real changes made) (40 real changes made) (42 real changes made) (42 real changes made) (594 real changes made) (594 real changes made) (42 real changes made) (42 real changes made) (42 real changes made) (42 real changes made) (42 real changes made) (42 real changes made) (41 real changes made) (41 real changes made) (37 real changes made) (37 real changes made) (32 real changes made) (32 real changes made) (27 real changes made) (27 real changes made) (25 real changes made) (25 real changes made) (21 real changes made) (21 real changes made) (7 real changes made) (7 real changes made) . g ci_top = coef+1.96*se . g ci_bottom = coef - 1.96*se . keep time_to_treat coef se ci_* . duplicates drop Duplicates in terms of all variables (1,156 observations deleted) . sort time_to_treat . summ ci_top Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- ci_top | 22 8.454178 13.99646 -9.503092 51.68034 . local top_range = r(max) . summ ci_bottom Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- ci_bottom | 22 -33.38446 12.76922 -56.47253 0 . local bottom_range = r(min) . twoway (sc coef time_to_treat, connect(line)) (rcap ci_top ci_bottom time_to_treat)(function y = 0, range(time_to_treat)) (function y = 0, range(`bottom_range' `top_range') horiz), x > title("Time to Treatment") caption("95% Confidence Intervals Shown")
Comment