bcallaway11 / did

Difference in Differences with Multiple Periods, website: https://bcallaway11.github.io/did
287 stars 91 forks source link

universal as base_period for data with gap years #185

Open XiangShawnZhang opened 8 months ago

XiangShawnZhang commented 8 months ago

This is a problem that I have discussed with Brant via Email. I want to leave the emails between us as an issue here and hope this can be addressed in the near future.

Question: The aggregation of the dynamic treatment effects works well on the base_period = "varying"; When I change the option of base_period = “universal”, the att_gt works; but when it aggregates to the dynamic treatment effects, it reports error of “Error in inffunc1[, whichones] %*% weights.agg : invalid object passed to as_cholmod_sparse”

Exp_CSDID <- did::att_gt(yname = "share_income", gname = "T_Timing", idname = "id", tname = "year", xformla = ~ NULL, data = Expenditure, allow_unbalanced_panel = T, control_group = "notyettreated", base_period = "universal", clustervars = "ID_VILLAGE")

  dynamic_base <- did::aggte(Exp_CSDID, type = "dynamic")
  **Error in inffunc1[, whichones] %*% weights.agg : invalid object passed to as_cholmod_sparse**

Brant's reply: Thanks for the message. This is a surprising issue to me --- I expect them to work in the same cases. If you look at the ATT(g,t)'s themselves, are there any differences in terms of which ones are computed?

My reply: Please see the att_gt() results below. image

Brant's reply: Yes, this is helpful. It looks like the year 2020 is not included in your data (is that correct?). I'm guessing that is the source of the issues here. I suspect that this is an actual bug in our code (though note that this is a pretty hard case as "event time" is rather complicated here). I can add this as an issue on GitHub, but it may take a while for us to fully resolve this.

bcallaway11 commented 8 months ago

Got it, thanks!