7 Cheatsheet
In this chapter, we provide an overview of the main functionalities of the fect package, including the required inputs, available plot types, key options, and testing capabilities across various methods.
7.1 Methods
Inputs for fect(methods = "___")
| Method | Model for \(\hat{Y}(0)\) | References |
|---|---|---|
| fe | Standard two-way fixed effects model | Liu, Wang & Xu (2022), Borusyak, Jaravel & Spiess (2024) |
| ife | Interactive fixed effects model | Gobillon & Magnac (2016), Xu (2017) |
| mc | Matrix completion method | Athey et al. (2021) |
| polynomial | Two-way fixed effects model with unit-specific trends | – |
| cfe | “Complex” or multi-level fixed effects | – |
| gsynth | Interactive fixed effects model | Xu (2017) |
7.2 Plot Types
Inputs for plot(fect_object, type = "___")
| Type | Description | Applicable Methods |
|---|---|---|
| box | Box plot of ATT by period. | fe, ife, mc, gsynth, polynomial, cfe |
| calendar | CATT by calendar time. | fe, ife, mc, gsynth, polynomial, cfe |
| heterogenous or hte | CATT by a covariate. | fe, ife, mc, gsynth, polynomial, cfe |
| counterfactual or ct | Observed vs. imputed outcome for treated units. | fe, ife, mc, gsynth |
| equiv | Pretreatment residuals with equivalence intervals. | fe, ife, mc, gsynth, polynomial, cfe |
| exit | Period-wise ATT relative to treatment exit. | fe, ife, mc, polynomial, cfe |
| factors | Estimated factors (factor-based methods). | ife, gsynth |
| gap or es | Event-study plot: ATT by pre- and post-treatment periods. | fe, ife, mc, gsynth, polynomial, cfe |
| loadings | Estimated factor loadings (factor-based methods). | ife, gsynth |
| status | Treatment status by period for all units. | fe, ife, mc, gsynth, polynomial, cfe |
| sens | Rambachan & Roth (2023) sensitivity analysis for treatment effects. |
fect_sens() function applied to fe, ife, mc, gsynth, polynomial, cfe |
| sens_es | Event-study sensitivity analysis for treatment effects. |
fect_sens() function applied to fe, ife, mc, gsynth, polynomial, cfe |
| cumul | Cumulative treatment effects over time. |
effect() function applied to fe, ife, mc, gsynth, polynomial, cfe |
7.3 Tests as Options
Inputs for fect(...)
| Input | Description | Applicable Methods |
|---|---|---|
loo |
Leave-one-period-out goodness-of-fit test (TRUE/FALSE). |
fe, ife, mc, gsynth |
carryoverTest |
Tests for carryover effects in post-treatment periods (TRUE/FALSE). |
fe, ife, mc |
carryover.period |
Range of post-treatment periods for the carryover test (vector). | fe, ife, mc |
permute |
Permutation test (TRUE/FALSE). |
fe, ife, mc, gsynth |
m |
Block length for permutation test (m=2 by default). |
fe, ife, mc, gsynth |
CV |
Cross-validation for factor-based methods. | ife, mc, gsynth |
7.4 Required and Optional Inputs
A check mark (✓) indicates that the method requires or accepts the input.
7.4.1 Required Inputs
| Input | fe | ife | mc | gsynth | polynomial | cfe |
|---|---|---|---|---|---|---|
Y (outcome) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
D (treatment) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
X (covariates) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
data |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
index (unit & time IDs) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
sfe (simple additive FEs) |
– | – | – | – | – | ✓ |
cfe (complex FEs) |
– | – | – | – | – | ✓ |
7.4.2 Optional Inputs
| Input | fe | ife | mc | gsynth | polynomial | cfe |
|---|---|---|---|---|---|---|
W (weight) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
se (uncertainty) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
nboots (# bootstrap reps) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
force (FE structure) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
lambda(Hyper-parameter sequence) |
– | – | ✓ | ✓ | – | – |
nlambda(Length of hyper-parameter sequence) |
– | – | ✓ | ✓ | – | – |
r (# factor) |
– | ✓ | – | ✓ | – | – |
k ( # cross-validation rounds) |
– | ✓ | ✓ | ✓ | – | – |
degree (degree of the interacted fixed effects) |
– | – | – | – | ✓ | – |
7.4.3 Important Options
| Input | Options | Applicable Methods |
|---|---|---|
force |
Fixed effects structure: “none”, “unit”, “time”, “two-way” (default) | fe, ife, mc, poly, cfe, gsynth |
vartype (when method = "gsynth") |
Uncertainty estimator: “parametric” (default), “bootstrap”, “jackknife” | gsynth |
vartype (otherwise) |
Uncertainty estimator: “bootstrap” (default), “jackknife” | fe, ife, mc, polynomial, cfe |
criterion |
Model selection criterion: “mspe” (default), “gmspe”, “moment”, “pc”. | ife, mc, polynomial, cfe, gsynth |
7.5 Notes
Most methods share core inputs (
Y,D,X,data,index).Method
polynomialandcfeallow either “jackknife” or “bootstrap” for uncertainty estimates.Factor-based methods (
ife,gsynth) can userandkfor factor selection and cross validation. We can implement a similar process usingmcorgsynthwithlambdaandnlambda.carryoverTestandlooare available infe,ife,mc,polynomial, andcfebut not ingsynth.forceallows various levels of fixed effects ("none","unit","time","two-way").fect includes several built-in values for optional arguments that often require an integer or boolean input. All boolean arguments (such as
parallel,se, orCV) are set toFALSEby default to speed up computation. Below is a complementary table listing parameters that require numeric inputs.
| Inputs | Description | Default |
|---|---|---|
degree |
The degree of the interacted fixed effects(int) | 2 |
nboots |
Number of bootstrap runs (int) | 200 |
k |
Sets the number of cross-validation rounds(int) | 10 |
r |
Sets the number of factors | 0; c(0,5) when CV |
m |
Specifies the block length for the permutation test | 2 |
nlambda |
Length of hyper-parameter sequence | 10 |
- With an integer input for
nlambda, fect can randomly generate appropriate hyper-parameter sequence.
Enjoy using fect!