I’m excited to announce that an R package {fewtfe}
implementing fused extended two-way fixed effects is now available on my GitHub! To install it, simply use
remotes::install_github("gregfaletto/fetwfePackage")
library(fetwfe)
The function fetwfe()
in the package takes in a panel data set and does the following for you:
- Do some basic cleanup, like removing units treated in the first time period and replacing any time-varying covariates with their value in the first time period.
- Create the necessary design matrix for the methodology, including all interaction terms.
- If the noise variances for the exogenous noise and unit-level random effects are not known, estimate them.
- Carry out the generalized least squares transformation on the design matrix and response.
- Carry out a change of coordinates and complete a bridge regression on the transformed coordinates, since this is equivalent to applying the FETWFE penalty in the original feature space (as discussed on slide 22 of these slides and in Appendix F of the paper). Then transform these estimated coefficients back to the original feature space. This is all done over a range of values of the penalty parameter \(\lambda\).
- Select a single value of \(\lambda\) using BIC. The estimated coefficients corresponding to this \(\lambda\) are the estimated FETWFE coefficients.
- Calculate estimates of some aggregated treatment effects of interest—the average treatment effect on the treated units (the estimand from Equation 4.11 in the current draft of the paper) and the cohort-specific average treatment effects (Equation 4.10).
- If the model was estimated using an \(L_q\) penalty with \(q < 1\) (\(q\) is an input to
fewfe()
), calculate standard errors for each of these estimators to allow the construction of confidence intervals. - Return all of this stuff along with some other helpful outputs.
See the specifications for the inputs and outputs on the GitHub page. The documentation for the function (which is paraphrased on the GitHub page, and which you can also get from the command
?fetwfe
in R when the package is loaded) has more details on using the function.
Feel free to reach out over email, LinkedIn, or Bluesky if you have any questions or run into any issues using the package. You can also create an issue if you think there’s a bug in the package or you’d like to request a feature.