staggered
staggered copied to clipboard
Better compatibility with other event study estimators
From making did2s::event_study
I noticed most functions use g = 0 as the never-treated group, but you all default to g = Inf. An easy fix is to allow for both by changing line 874 to:
df[, "g"] <- df[,g]
df[df$g == 0, "g"] <- Inf
https://github.com/jonathandroth/staggered/blob/c84eb4011b669e9b3eacbf66dfe4955c6a06cb79/R/compute_efficient_estimator_and_se.R#L829-L881
If you want to be safe, in case y actually has year 0 for whatever reason
if(!any(0 %in% unique(df[, y])) {
df[df$g == 0, "g"] <- Inf
}
Thanks for the suggestion, @kylebutts!
I think we should add an option neverTreatedValue with default = Inf. Then you use-case would be neverTreatedValue =0. I personally find the convention of using 0 for never treated very odd and do not like hardcoding it. But I'd be happy with a warning
if( 0 %in% unique(df$g) & ! (0 %in% df$y) * neverTreatedValue = 0){ warning("Some observations have g=0. If you meant to use g=0 to denote never treated, set neverTreatedValue = 0")
I don't have bandwidth right now but will try to do this in a few weeks