insongkim / PanelMatch

111 stars 34 forks source link

PE.results[["estimates"]] provides output for t+0 only #133

Closed darrgerr closed 7 months ago

darrgerr commented 8 months ago

I'd like to thank the authors of the package for its introduction. I also wish to clarify the issue I've been dealing with within the last few days.

I am trying to estimate the effects of appointment of a university leader (appointed_new) on university's performance (growth_f), I run the following code:

PM.results <- PanelMatch(lag = 4, time.id = "year", unit.id = "new_id", 
                         treatment = "appointed_new", refinement.method = "mahalanobis", 
                         data = dtb_psm, match.missing = TRUE, 
                         covs.formula = ~ vpm + n_staff_mon,
                         verbose = TRUE, exact.match.variables = list("special_status", "u_spec"),
                         size.match = 5, qoi = "att" ,outcome.var = "growth_f",
                         forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE)

When I run covariate balance (I have also done it with no refinement method), I can see output for all 4 lags:

> get_covariate_balance(PM.results$att, data = dtb_psm, covariates = c("vpm", "n_staff_mon"), plot = FALSE)
           vpm n_staff_mon
t_4 0.06799907  0.04820720
t_3 0.06818579  0.02313124
t_2 0.08272747  0.03660561
t_1 0.10501971  0.03450425

However, when I use PanelEstimate, the output is rather strange:

PE.results <- PanelEstimate(sets = PM.results, data = dtb_psm, se.method = "bootstrap", number.iterations = 1000, confidence.level= .95)
PE.results[["estimates"]]
      t+0 
-160.4326 

I have searched for potential reason everywhere, rerun my code looking for a typo, however, could not find an issue. Hence, I thought that the problem might be within the package itself. Is it the case? Ready to provide code and data. Thank you

darrgerr commented 7 months ago

At this point, I got the answer. I should have added the part 'lead = 0:4' to get the estimates for all lags.

PM.results <- PanelMatch(lag = 4, time.id = "year", unit.id = "new_id", 
                         treatment = "appointed_new", refinement.method = "mahalanobis", 
                         data = dtb_psm, match.missing = TRUE, 
                         covs.formula = ~ vpm + n_staff_mon, 
                         verbose = TRUE, exact.match.variables = list("special_status", "u_spec"),
                         size.match = 5, qoi = "att" ,outcome.var = "growth_f",
                         lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE)

PE.results <- PanelEstimate(sets = PM.results, data = dtb_psm, se.method = "bootstrap", number.iterations = 1000, confidence.level= .95)

PE.results[["estimates"]]