5
$\begingroup$

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

enter image description here

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:

enter image description here

However, when I run the regression in the did package, I get this:

enter image description here

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)
$\endgroup$

2 Answers 2

2
$\begingroup$

As it turns out, the issue was resolved when setting the reference period as "universal" instead of "varying", which is a problem when you have long-running linear pretrends as in this example. Here is a link with more information.

$\endgroup$
1
$\begingroup$

As you answered already, this is related to the fact that you are using the a varying base period. You want to use the universal base period. By default, Stata uses a "short-gap-varying base". You can re-estimate using the long2 option in the csdid command.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.