Skip to content
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

DiD Event Study Code in Python Interactions in the Wrong Order #195

Open
sbecon opened this issue Feb 24, 2023 · 4 comments
Open

DiD Event Study Code in Python Interactions in the Wrong Order #195

sbecon opened this issue Feb 24, 2023 · 4 comments

Comments

@sbecon
Copy link

sbecon commented Feb 24, 2023

The diff-in-diff event study code in Python generate the interactions in the wrong order INX_0, INX_1, INX_10, INX_11, INX_12, ... instead of INX_0, INX_1, INX_2, ... INX_11, ...

The resulting figure also has evidence of this
Unknown-2

I think the best place to reorder these variables in the df is right before running the regression, but I have been getting tripped up with the factors.union line.

@NickCH-K
Copy link
Contributor

Hmm, shoot! Could you do a PR for this?

@sbecon
Copy link
Author

sbecon commented Feb 24, 2023

I haven't figured out how to fix it, Nick! Any ideas?

@pmx-chen
Copy link

pmx-chen commented Mar 9, 2023

should be
res = res.reindex(range(res.index.min(), res.index.max()+1)).fillna(0) when reindex the results.

Btw, the 'time_to_treat' has reverse sign: I suppose that '_nfd' is the treatment year, it shoudl be

    df['year'].sub(df['_nfd'])
        # missing values for _nfd implies no treatment
        .fillna(0)
        # so we don't have decimals in our factor names
        .astype('int'))```

@pmx-chen
Copy link

pmx-chen commented Mar 9, 2023

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants