Open s3alfisc opened 2 months ago
Currently, the coefficient names of the DiD methods follow formulaic standard naming, which is very verbose.
formulaic
Here is an example:
import pyfixest as pf fit = pf.feols("Y ~ i(f1, X1, ref = 1)", data = pf.get_data()) fit.coef().head() # C(f1, contr.treatment(base=1))[T.0.0]:X1 -1.069505 # C(f1, contr.treatment(base=1))[T.2.0]:X1 -1.803860 # C(f1, contr.treatment(base=1))[T.3.0]:X1 -1.529129 # C(f1, contr.treatment(base=1))[T.4.0]:X1 -2.039220
The lpdid function does better:
lpdid
import pandas as pd from pyfixest.did.estimation import lpdid, did2s url = "https://raw.githubusercontent.com/s3alfisc/pyfixest/master/pyfixest/did/data/df_het.csv" df_het = pd.read_csv(url) lpdid_df = lpdid( df_het, yname="dep_var", idname="unit", tname="year", gname="g", vcov={"CRV1": "state"}, pre_window=-20, post_window=20, att=False ) lpdid_df.tidy().head()
while did2s produces
did2s
fit_did2s = did2s( df_het, yname="dep_var", first_stage="~ 0 | unit + year", second_stage="~i(rel_year, ref=-1.0)", treatment="treat", cluster="state", ) fit_did2s.tidy().head()
For ATTs, we get
C(f1, contr.treatment(base=1))[T.0.0]:X1
f1::0::X1
I can take this.
Very cool! I've assigned this to you =) Let me know if I can help you in any way!
Context
Currently, the coefficient names of the DiD methods follow
formulaic
standard naming, which is very verbose.Here is an example:
The
lpdid
function does better:while
did2s
producesFor ATTs, we get
To Do
C(f1, contr.treatment(base=1))[T.0.0]:X1
tof1::0::X1
, etc.