-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Context
Currently, the coefficient names of the DiD methods follow formulaic
standard naming, which is very verbose.
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:
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
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
To Do
- Rename the regression coefficients from DID models (event_study, DID2s, lpdid), e.g. rename
C(f1, contr.treatment(base=1))[T.0.0]:X1
tof1::0::X1
, etc.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers
Type
Projects
Status
No status