I have noticed that in some of my event study regressions, depending on which R package I use I get different results regarding the violation of parallel pretrends. Specifically, I ran an event study regression using the "fixest" package, which indicated that the treatment and control groups were not on parallel trends before treatment, whereas the "did" package by Callaway and Sant'Anna showed that both groups were on the same trend pre-treatment, i.e. the coefficients were around zero. All treated units were treated at the same time, so it couldn't be because of staggered treatment effects.
I then generated some other data to see whether this issue was limited to my dataset. I generated a dataset of "treated" and "untreated" observations over 10 periods, with 100 observations per group (2000 observations in total), where the observations of the untreated group are around zero in every period, but the observations of the treated group linearly grow from -5 to 5 over the 10 periods (see plot).
I would therefore expect the coefficients of the event study regression to also indicate a violation of parallel trends, with no change in trend at the time of treatment (5). Indeed, the fixest package shows exactly this:
However, when I run the regression in the did package, I get this:
where for some reasons the pre-trends are just filtered out. Does anyone have any idea what's happening here? I tried to figure it out from the publication, but I couldn't find anything that would apply to this situation. Here's the R code to reproduce the example:
library(did) library(ggplot2) ## Generate data period <- rep(1:10, 200) id <- rep(1:200, each = 10) group <- rep(0:1, each = 1000) values0 <- 0 + rnorm(1000, mean = 0, sd = 1) values1 <- period[1001:2000] - 5 + rnorm(1000, mean = 0, sd = 1) values <- c(values0, values1) first_treated <- rep(c(0,6), each = 1000) df <- data.frame(cbind(period, id, group, values, first_treated)) ## Plot data ggplot(df, aes(period, values, colour = group)) + geom_point(alpha = 0.3) + theme_classic() ## Run fixest estimation iplot(feols(values ~ i(period, group, ref = c(5)), data=df)) ## Run did estimation did_test <- att_gt(yname = "values", idname = "id", tname = "period", gname = "first_treated", data = df) did_test <- aggte(did_test, type = "dynamic", na.rm = TRUE) ggdid(did_test)