Comments (9)
I think you're correct. It doesn't make sense to have time_to_treatment
==0 represent two different states. (Schrödringer's zero?) Now, from a practical perspective, I don't think it matters since the treat
and ib#shited_ttt
variables will cancel things it. But I agree it's logically confusing.
Taking a higher-level look at this event study page, there are several other things we could change. We shouldn't be using a proprietary data format (dta
) for one thing, and the R code as currently written won't work with the impending fixest 0.9.0 release. (It could also be considerably shortened.) I'll make some changes and then let someone else pitch in about the Stata code.
from lost-stats.github.io.
I've pushed a couple of updates. But really I think this page needs a closer look. I just ran the Stata implementation of Sun Abraham and got different results to the R version... I don't have time to troubleshoot now and it might just be a copy-paste error on my side. But I'm hoping @pdeffebach or @NickCH-K can double check.
Similarly, I tried the Callaway-Sant'Anna estimator and got different results once again. I spoke v. briefly to Pedro and he thinks it's likely due to covariates, which SA don't handle in their paper. Again, though, it could be user error on my part. Here's the code I was trying locally:
library(did)
## Change never treated to zero
dat[, year_treated := ifelse(treat==0, 0, `_nfd`)]
mod_cs = att_gt(yname = "asmrs",
gname = "year_treated",
idname = "stfips",
tname = "year",
xformla = ~ pcinc + asmrh + cases,
data = dat)
summary(mod_cs)
cs = aggte(mod_cs, type = "dynamic", na.rm = TRUE)
cs
ggdid(cs)
from lost-stats.github.io.
I'll look at this when I get a chance
from lost-stats.github.io.
Shifting the untreated treated-time to a big positive number seems fine to me; I do like the logic that the zeroes there let things drop out.
On the R side the sunab()
function looks neat! It's a bit of a concern it doesn't match Stata, as the Stata package is by Sun herself.
from lost-stats.github.io.
Yes. You have to assign to very positive number that is not included in the wanted interval. Keeping this as it is will apply the regression for states that treat=0 while we just want to include states with treat=1. I tried it and got different results.
from lost-stats.github.io.
@aalamer1 do you have a fixed version of the code?
from lost-stats.github.io.
@NickCH-K I am working on my own dataset but modified replace time_to_treat = 0 if missing(_nfd)
to be replace time_to_treat = 10000 if missing(_nfd).
Did you try in R code they posted? I tried to replicate it but generate errors of collinearity it is not working. I do not know how did they generate the graph and confirmed the results?
from lost-stats.github.io.
Hi all: In the code:
reghdfe asmrs ib`true_neg1'.shifted_ttt pcinc asmrh cases, a(stfips year) vce(cluster stfips)
Shouldnt there be the interaction term of " treat## ibtrue_neg1'.shifted_ttt" instead of just "ib
true_neg1'.shifted_ttt" ?
Thanks in advance!
from lost-stats.github.io.
Yes, I believe you're right
from lost-stats.github.io.
Related Issues (20)
- Broken links for data importing pages? HOT 1
- Code samples which don't pass tests HOT 9
- Encourage use of same datasets across implementations HOT 7
- An Example of Web Scraping in R HOT 2
- New name for the Generalized Least Squares category HOT 2
- Better syntax highlighting HOT 2
- Add to KNN page - R walkthrough HOT 2
- Causal Forest Walkthrough is wrong for the stata - R interface example HOT 1
- how to save the stargazer output table into a file/png using Python HOT 1
- Added as a contributer HOT 1
- Add vector autoregression and impulse response functions to granger causality section HOT 1
- Pushed color palette image files to wrong folder HOT 4
- Post contribution warning and possible mistake changing new page template HOT 2
- Fix marginal effects plot (with categorical interactions) page HOT 5
- Create page on package creation HOT 1
- Build failure HOT 8
- DiD Event Study Code in Python Interactions in the Wrong Order HOT 4
- Event study in Stata HOT 1
- Event study in stata with reghdfe
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lost-stats.github.io.