Skip to content

DID: Prettier and Unified Coefficient Names for DiD Methods #407

@s3alfisc

Description

@s3alfisc

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()

image

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()

image

For ATTs, we get

image

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 to f1::0::X1, etc.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions