-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LPDID: Setting Windows with Monthly Data #750
Comments
Hi, that's a bug and simply stems from the fact that the DID API isn't too well designed regarding the time variables. I'll have to take a closer look at this. Thanks for reporting! |
Thank you for the quick response! One other little thing to note on LPDID, of which you are likely aware, is that running iplot after estimation alters the LPDID object--specifically the index--so that I cannot re-run iplot without re-estimating the model (since I'm not sure how to manipulate the LPDID object--unlike a data frame I'm not able to set a new index). Basically, running iplot inserts a new index in the LPDID object: Thank you again! |
Thanks for reporting - looks like another bug! What is it that you are re-running? Is it running one of etable / summary / tidy / vcov post estimation that alters the model output? Could you provide a reproducible example with the |
It occurs when I run iplot (In my original message I had put "iplot" in angle brackets, and I just now noticed that doing so suppressed that bit of text...a key piece of information! Sorry about that!). I will come up with a reproducible example using the |
The first The second The second
|
Thanks @escherpf , I can reproduce this. The second evaluation of fit.tidy().head()
fit.iplot(figsize= [1200, 400], coord_flip=False).show() produces AttributeError: 'DataFrame' object has no attribute 'dtype' As a matter of fact, it seems that calling fit = pf.lpdid(
df_het,
yname="dep_var",
idname="unit",
tname="year",
gname="g",
vcov={"CRV1": "state"},
pre_window=-20,
post_window=20,
att=False
)
fit.iplot(figsize= [1200, 400], coord_flip=False).show()
fit.iplot(figsize= [1200, 400], coord_flip=False).show()
# AttributeError: 'DataFrame' object has no attribute 'dtype' I'll take a look at this in the next days. |
That's correct. Calling Thank you @s3alfisc ! |
The iplot error does not occur with fit = pf.did2s(
df_het,
yname="dep_var",
first_stage="~ 0 | unit + year",
second_stage="~i(rel_year, ref=-1.0)",
treatment="treat",
cluster="state",
)
fit.iplot(figsize= [1200, 400], coord_flip=False).show()
fit.iplot(figsize= [1200, 400], coord_flip=False).show() |
The issue with |
Currently doing some research on how the leading did libraries handle time / date data.
|
Generally I think that the error message "needs to be of format YYYYMMDD" doesn't make sense, the only think that is really required is that users pass a numeric and that gname and tname are in the same scale to do this comparison Line 87 in 4c59151
And we could also verify that dates are on the same scale by checking that values of the gname variable are included in tname or 0 or infinity? |
LPDID currently requires that date variable inputs (tname and gname) be in the format YYYYMM if one is using monthly data. This seems to cause some weirdness with setting the pre- and post-windows when one has monthly data spanning more than a year. In particular, with dates in the YYYYMM format (e.g., 202312 and 202401) the jump from December of one calendar year to January of the next is obviously not 1. If I set my pre- and post-window to values less than (minus and plus) 12, there's no problem: the command runs. But setting them to something like plus/minus 20 (again, in terms of months) and LPDID will not run and I get an error message like the one displayed below. On the other hand, if I set it to something large enough to cover the jump from one calendar year to the next (e.g., 96) the command runs and produces coefficients for all 96 leads and lags (I have about 28 years of data).
Is there something I'm missing here, or is this an known issue? Or just something that will persist until datetime formats are supported?
The text was updated successfully, but these errors were encountered: