fect: Fixed Effects Counterfactual Estimators

Stata package for A Practical Guide to Counterfactual Estimators for Causal Inference with Time-Series Cross-Sectional Data

Authors: Licheng Liu (MIT); Ye Wang (NYU); Yiqing Xu(Stanford); Ziyi Liu(Uchicago); Shijian Liu (Duke)

Date: May. 1, 2023

Package: fect

Main Reference: A Practical Guide to Counterfactual Estimators for Causal Inference with Time-Series Cross-Sectional Data

Version: 1.0.2 Please report bugs!


Contents

  1. Installation
  2. Data
  3. Estimation
  4. Model Selection
  5. Uncertainty Estimates
  6. Wald Test
  7. Equivalence Test
  8. Placebo Test
  9. Carryover Test

Installation

As a pre-requisite, the reghdfe package needs to be installed. Users are recommended to update it to the latest version.

. ssc install reghdfe, replace

We provide 2 methods for the installation of fect:

Installation from Github.

You can install the development version of the package by typing the following commands in your STATA console:

. cap ado uninstall fect

. net install fect, from(https://raw.githubusercontent.com/xuyiqing/fect_stata/master/) replace

Manual Installation.

If you can’t install the package using the first method, you can manually install it:

  1. Download the zip file from: https://github.com/xuyiqing/fect_stata
  2. Unzip the file
  3. Type the following commands in your STATA console:

    . cap ado uninstall fect

    . net install fect, all replace from(full_local_path)

Data

Two datasets are shipped with the fect package. If you manually install the package following the second method, these sample datasets will be copied into your current directory during installation. In this demo, we will primarily use simdata1. It follows a staggered adoption treatment assignement mechanism, which contains 100 treated units, 100 control units and 35 time periods. The treatment kicks in a staggered adoption fashion from period 21. This package can estimate the average treatment effect (ATT) of the treatment D on the outcome Y, only using information of the outcome, the treatment indicator and the covariates (X1 and X2) from observations under the control status. First we load the data.

. clear

. set more off

. use "https://raw.githubusercontent.com/xuyiqing/fect_stata/master/simdata.dta"
(Written by R)

Note

If the data couldn’t be accessed in this way(), users can directly download it to the local and use it.

Estimation

In the current version of fect, users can use five methods to make counterfactual predictions by specifying the method option: fe(fixed effect), ife(interactive fixed effects), mc(matrix completion), bspline(unit-specific bsplines) and polynomial(unit-specific time trends). Now we will illustrate the main grammar and options in fect.

Fixed Effects(FE)

In order to estimate the ATT, users should specify the outcome variable, the unit indicator, the time indicator, the treatment indicator and covariates in the command. As an example, the following command will estimate the average treatment effect(ATT) using the two-way fixed effects(FE) model. The force option (can be “none”, “unit”, “time”, and “two-way”) specifies the additive component(s) of the fixed effects included in the model. The default option is “two-way” (including both unit and time fixed effects). After the estimation, users can then access the stored results by calling e-class commands. The estimated average treatment effects are saved in e(ATT), the average treatment effects by period are saved in e(ATTs), and the estimated coefficients of covariates are saved in e(coefs). All of them are matrices.

. fect Y, treat(D) unit(id) time(time) cov(X1 X2) method("fe") force("two-way")
Balanced Panel Data
Treatment has reversals.

. mat list e(ATT)

e(ATT)[1,2]
          ATT          N
r1  5.1207255       1503

. mat list e(ATTs)

e(ATTs)[61,3]
              s           n         ATT
 r1         -33           4   -1.707191
 r2         -32           9   .32789236
 r3         -31          12  -.04478373
 r4         -30          12  -.58875483
 r5         -29          15  -.65898991
 r6         -28          16  -.48323637
 r7         -27          19   -.8636198
 r8         -26          21  -.52921683
 r9         -25          27   .15541384
r10         -24          32  -.19860056
r11         -23          41  -1.0113511
r12         -22          46  -.95313215
r13         -21          52  -.65739173
r14         -20          57   -.7430768
r15         -19          63  -.25396791
r16         -18          75  -.67184937
r17         -17          79  -.47272217
r18         -16          88  -.27878821
r19         -15          96  -.35461316
r20         -14         104  -.29302686
r21         -13         112  -.46073678
r22         -12         122  -.51191843
r23         -11         127  -.54138118
r24         -10         131  -.19160587
r25          -9         134  -.16707277
r26          -8         146  -.25274819
r27          -7         156   .09271089
r28          -6         165   .34297997
r29          -5         173   .26571748
r30          -4         181   .26015314
r31          -3         187   .37300619
r32          -2         196   .73107994
r33          -1         207   .56655067
r34           0         226    1.094766
r35           1         226   1.7362964
r36           2         190   1.8819788
r37           3         161   2.7365479
r38           4         134   3.3721704
r39           5         114    4.304564
r40           6         101   4.7405396
r41           7          88   5.5957561
r42           8          76   6.0143576
r43           9          68   6.3740425
r44          10          58    7.594193
r45          11          51   8.6471014
r46          12          39   9.2710648
r47          13          33   8.9919758
r48          14          28   11.329398
r49          15          25   12.122083
r50          16          22    12.00482
r51          17          19   12.353776
r52          18          15    14.62495
r53          19          14   14.517463
r54          20          11   17.197647
r55          21           9   14.125473
r56          22           7   17.783506
r57          23           4    14.31261
r58          24           3     16.0986
r59          25           2   18.746426
r60          26           1   17.663391
r61          27           1   19.479353

. mat list e(coefs)

e(coefs)[1,3]
         cons         X1         X2
r1  10.815435  1.0151907  2.9369101

After the estimation, fect will draw a graph visualizing the estimated average treatment effects by period.

For the reference, the true population average effects in simdata1 rise from 1 to 3 from the first post-treatment period to the last. The bar plot at the bottom of the plot shows the number of treated units for each time period.

Interactive Fixed Effects(IFE)

In addition to the two-way fixed effects model, fect also supports the interactive fixed effects (IFE) model. For the IFE approach, users need to specify the number of factors(default to 1) using option r(). For example, the following command will estimate the average treatment effects using an IFE model with 2 factors.

. fect Y, treat(D) unit(id) time(time) cov(X1 X2) method("ife") force("two-way") r(2)
Balanced Panel Data
Treatment has reversals.

Users can access the results in the same way as in the FE model.

. mat list e(ATT)

e(ATT)[1,2]
          ATT          N
r1  2.4813125       1503

. mat list e(ATTs)

e(ATTs)[61,3]
              s           n         ATT
 r1         -33           4  -1.8048058
 r2         -32           9   .56776232
 r3         -31          12   .77159399
 r4         -30          12  -.23196878
 r5         -29          15  -.28729102
 r6         -28          16   .45734009
 r7         -27          19  -.65307075
 r8         -26          21  -.09092191
 r9         -25          27   .37530303
r10         -24          32  -.08828661
r11         -23          41  -.22279368
r12         -22          46  -.37711635
r13         -21          52   .06362801
r14         -20          57  -.09413088
r15         -19          63    .4263092
r16         -18          75  -.06633208
r17         -17          79   .06671321
r18         -16          88   .22042425
r19         -15          96   .10811507
r20         -14         104   .03206609
r21         -13         112  -.04292748
r22         -12         122  -.02033657
r23         -11         127  -.33243692
r24         -10         131   -.0956533
r25          -9         134   .08146083
r26          -8         146  -.18607108
r27          -7         156   .12186389
r28          -6         165   .22258899
r29          -5         173  -.10148041
r30          -4         181  -.05990592
r31          -3         187   .00198579
r32          -2         196   .11663363
r33          -1         207  -.12682247
r34           0         226   .09615821
r35           1         226   .33361962
r36           2         190   .59126097
r37           3         161   1.1401325
r38           4         134   1.4976728
r39           5         114   2.1788592
r40           6         101   2.2844243
r41           7          88   2.9082348
r42           8          76   2.9424522
r43           9          68    2.907923
r44          10          58   3.8535397
r45          11          51   4.5668797
r46          12          39   4.8646436
r47          13          33   4.0786037
r48          14          28    6.157485
r49          15          25   6.6641221
r50          16          22   6.4193182
r51          17          19   6.6314425
r52          18          15   9.3378716
r53          19          14   8.6405611
r54          20          11   11.139565
r55          21           9   8.9785242
r56          22           7   10.427698
r57          23           4   6.0703249
r58          24           3   10.994654
r59          25           2   8.6603546
r60          26           1   4.1112123
r61          27           1  -1.5031422

. mat list e(coefs)

e(coefs)[1,3]
         cons         X1         X2
r1    12.3126  .99705171  2.9785836

Note: When running on a large dataset, the IFE model may be time-consuming. One makeshift is to use a larger tolerance criterion for convergence (by setting the option tol() in the command), but it may yield a less accurate estimation.

Matrix Completion(MC)

For the MC method, users also need to specify a hyper-parameter (the penalty term) lambda(default to 1) in the command. For example, the following command will estimate the average treatment effect using a MC model with lambda equal to 0.004.

. fect Y, treat(D) unit(id) time(time) cov(X1 X2) method("mc") lambda(0.004)
Balanced Panel Data
Treatment has reversals.

. mat list e(ATT)

e(ATT)[1,2]
          ATT          N
r1  4.2059017       1503

. mat list e(coefs)

e(coefs)[1,3]
         cons         X1         X2
r1  11.942683  1.0101182  2.9578248

Model Selection

This package ships a cross-validation procedure to help determine the tuning parameter in ife, mc, bspline and polynomial models.The cross-validation procedure is ran for k folds (default to 10, can be set in the option kfold()) and the candidate tuning parameter corresponding to the minimal mean squared prediction error(mspe) will be selected. In each round, some observations are removed as the testing set to evaluate the prediction ability of the model with a certain tuning parameter. To alleviate the concern of the serial correlation within a unit, users can remove a consecutive number of observations from a unit as elements in the testing set in order to avoid over fitting caused by serial correlation. The consecutive number is specified in the option cvnobs() (default to 3). After the cross-validation, the mean squared prediction error for each hyper-parameter is saved in e(CV) and the minimum of it is saved as e(min_mspe).

The cross-validation procedure will be implemented in the following scenarios:

1, If users cannot determine which method to use, the cross-validation procedure with method set to “both” can automatically determine the method based on both methods’ out-of-sample predication performance. In this case, the algorithm selects the IFE method, which is the correct model specification. Note that FE is a special case of IFE when r=0. Users can set the maximum number of factors for searching in the ife model in option r() and the number of grids of lambda(s) in nlambda() (default to 10). For the mc model, a lambda normalized by the maximum singular value of the demeaned outcome will be computed and presented too.

. fect Y, treat(D) unit(id) time(time) cov(X1 X2) method("both")  r(4) nlambda(15)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Cross Validation...
fe r=0 force=two-way mspe=7.1809
ife r=1 force=two-way mspe=5.3337
ife r=2 force=two-way mspe=4.9286
ife r=3 force=two-way mspe=6.1259
ife r=4 force=two-way mspe=7.4436
mc: lambda=.0131 lambda.norm=1 mspe=7.1809
mc: lambda=.0077 lambda.norm=.5878 mspe=6.2177
mc: lambda=.0045 lambda.norm=.3455 mspe=5.3057
mc: lambda=.0027 lambda.norm=.2031 mspe=5.257
mc: lambda=.0016 lambda.norm=.1194 mspe=5.4018
mc: lambda=.0009 lambda.norm=.0702 mspe=5.4229
mc: lambda=.0005 lambda.norm=.0412 mspe=5.468
mc: lambda=.0003 lambda.norm=.0242 mspe=5.5654
mc: lambda=.0002 lambda.norm=.0143 mspe=5.7811
mc: lambda=.0001 lambda.norm=.0084 mspe=6.8763
mc: lambda=.0001 lambda.norm=.0049 mspe=7.1219
mc: lambda=0 lambda.norm=.0029 mspe=7.146
mc: lambda=0 lambda.norm=.0017 mspe=7.1603
mc: lambda=0 lambda.norm=.001 mspe=7.1687
mc: lambda=0 lambda.norm=.0006 mspe=7.1737
Choose the fe/ife model, r = 2.

. di e(min_mspe)
4.9285903

. matrix list e(CV)

e(CV)[5,2]
            r       mspe
r1          0  7.1808753
r2          1  5.3336873
r3          2  4.9285903
r4          3  6.1258554
r5          4  7.4435616

2, When the option lambda has a numlist input and the option method is set to “mc”, the results will be compared across all lambdas.

. fect Y, treat(D) unit(id) time(time) cov(X1 X2) method("mc") lambda(0.001 0.002 0.003 0.004 0.005)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Cross Validation...
mc: lambda=.001 lambda.norm=.0762 mspe=5.419
mc: lambda=.002 lambda.norm=.1524 mspe=5.3601
mc: lambda=.003 lambda.norm=.2285 mspe=5.2282
mc: lambda=.004 lambda.norm=.3047 mspe=5.2227
mc: lambda=.005 lambda.norm=.3809 mspe=5.4114
optimal lambda=.004, lambda.norm=.3047 in mc model

. matrix list e(CV)

e(CV)[5,2]
       lambda       mspe
r1       .001   5.419004
r2       .002  5.3600631
r3       .003  5.2282238
r4       .004  5.2227316
r5       .005  5.4114327

3, When the option cv is on, the mspe of the specified method will be calculated. For the ife method, models with number of factors ranging from 0 to r() will be compared. For the mc method, mspe for the specified lambda will be computed, no matter whether lambda() has a numlist input or not. Users can also restrict the testing set to observations only from treated units by setting the option cvtreat on.

. fect Y, treat(D) unit(id) time(time) cov(X1 X2) method("ife") r(4) cv cvtreat
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Cross Validation...
fe r=0 force=two-way mspe=7.0922
ife r=1 force=two-way mspe=5.3907
ife r=2 force=two-way mspe=5.0741
ife r=3 force=two-way mspe=6.4472
ife r=4 force=two-way mspe=7.814
optimal r=2 in fe/ife model

Uncertainty Estimates

The algorithm produces uncertainty estimates when se is on. One can use the non-parametric bootstrap procedure by setting vartype() to “bootstrap” (also the default setting). Note that it only works well when the treatment group is relatively large, e.g. larger than 40. The number of bootstrap runs is set by nboots(). Alternatively, users can obtain uncertainty estimates using the jackknife method by by setting vartype() to “jackknife”. The algorithm obtains standard errors by iteratively dropping one unit (the entire time-series) from the dataset. After the estimation, users can then access the stored results by calling e-class commands. The estimated average treatment effects are saved in e(ATT), the average treatment effects by period are saved in e(ATTs), and the estimated coefficients of covariates are saved in e(coefs).

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) method("ife") r(2) se nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times

. mat list e(ATT)

e(ATT)[1,6]
            ATT            N           sd  Lower_Bound  Upper_Bound       pvalue
r1    2.4813125         1503    .29249887     1.858035    3.1063349            0

. mat list e(ATTs)

e(ATTs)[61,7]
                s             n           ATT        ATT_sd   ATT_p_value  ATT_Lower_~d  ATT_Upper_~d
 r1           -33             4    -1.8048058     1.2549045     .15037684     -4.147047     1.0064423
 r2           -32             9     .56776232     .57916659     .32693353    -.57720953     1.4243432
 r3           -31            12     .77159399     .57830387     .18212645     -.3914623     1.8914434
 r4           -30            12    -.23196878     .86351317     .78821152    -1.9127718     1.4675541
 r5           -29            15    -.28729102     .43486118     .50883681    -1.0983554     .64912993
 r6           -28            16     .45734009     .34042183     .17912593    -.32205355     1.1765143
 r7           -27            19    -.65307075     .45309544      .1494848    -1.4408845     .12835258
 r8           -26            21    -.09092191     .32648364     .78063744    -.71074247     .52104908
 r9           -25            27     .37530303     .35837829      .2949954    -.21755818     1.0415277
r10           -24            32    -.08828661     .30354255     .77116287    -.63972026     .47916076
r11           -23            41    -.22279368     .31058931     .47317317    -.92216605     .37168387
r12           -22            46    -.37711635     .29214752     .19675839    -.93795127     .26240644
r13           -21            52     .06362801     .25467348     .80270988    -.38066697     .58702719
r14           -20            57    -.09413088     .23231947     .68534625    -.66326171     .34009486
r15           -19            63      .4263092     .24770063      .0852388    -.01053051     .97148943
r16           -18            75    -.06633208     .21530908     .75802267    -.45253757     .36556518
r17           -17            79     .06671321     .19223225     .72855765    -.24807569     .41706622
r18           -16            88     .22042425     .18701272     .23853393    -.18464531     .51329368
r19           -15            96     .10811507     .15733089     .49196759     -.1883955     .44237232
r20           -14           104     .03206609     .17273417     .85272837    -.25693306     .38461468
r21           -13           112    -.04292748     .17506436     .80629402    -.39645416     .26947775
r22           -12           122    -.02033657     .16757755     .90340894    -.26792824     .33683538
r23           -11           127    -.33243692     .15596838     .03305309    -.62077802    -.07588479
r24           -10           131     -.0956533     .14677495     .51459444    -.34039944      .2352234
r25            -9           134     .08146083     .16255766     .61628699    -.21466675     .41504714
r26            -8           146    -.18607108     .13484567     .16762306    -.41186127      .1140512
r27            -7           156     .12186389     .12961122     .34710148    -.16904013     .33761257
r28            -6           165     .22258899     .13828871     .10748602    -.03210924     .47705862
r29            -5           173    -.10148041     .14416279     .48147681    -.39597395     .14969328
r30            -4           181    -.05990592     .13441336     .65582532    -.38275689     .21777703
r31            -3           187     .00198579     .12284544     .98710281     -.2607851     .22961496
r32            -2           196     .11663363     .11176399     .29668403     -.0771024     .34344757
r33            -1           207    -.12682247     .11264054     .26020601    -.31522363     .09627791
r34             0           226     .09615821     .10508803     .36017832    -.12416665     .28858447
r35             1           226     .33361962     .15427083     .03057519     .03243579     .63679063
r36             2           190     .59126097     .18150148     .00112355     .23195274     .92405683
r37             3           161     1.1401325     .19872843     9.629e-09     .73268718     1.4954313
r38             4           134     1.4976728     .22969368     7.016e-11     1.0601922     1.8550415
r39             5           114     2.1788592     .24557282             0     1.7347155     2.7389178
r40             6           101     2.2844243      .2823683     6.661e-16     1.7727293     2.8251567
r41             7            88     2.9082348     .34879869             0     2.2454345     3.5481269
r42             8            76     2.9424522     .39908403     1.668e-13     2.2734694     3.7938328
r43             9            68      2.907923     .44433475     5.972e-11     2.1682198     3.9612787
r44            10            58     3.8535397     .61914599     4.848e-10     2.6393723     5.1285205
r45            11            51     4.5668797     .68726039     3.031e-11     3.2751679     5.9540162
r46            12            39     4.8646436     .72378403     1.803e-11     3.4608545     6.3833179
r47            13            33     4.0786037     .82312578     7.232e-07     2.6466856     5.5247722
r48            14            28      6.157485     1.0570449     5.705e-09     4.1124411     8.1851845
r49            15            25     6.6641221     1.1441873     5.734e-09       4.32832     9.7116489
r50            16            22     6.4193182     1.3378479     1.601e-06     3.7678056     9.1443167
r51            17            19     6.6314425     1.1936327     2.765e-08     4.5241537     8.7537003
r52            18            15     9.3378716     1.6280131     9.708e-09     6.4421215      12.73391
r53            19            14     8.6405611     1.5490716     2.434e-08     5.4992981     12.046502
r54            20            11     11.139565      2.038944     4.671e-08     7.1498675     15.308917
r55            21             9     8.9785242     2.1760974     .00003692     4.4423828     12.906717
r56            22             7     10.427698     2.6637383     .00009052     4.0076323     15.056395
r57            23             4     6.0703249      3.981204     .12732247    -3.0370929     12.167927
r58            24             3     10.994654     3.0989969     .00038845     7.5918298     19.716324
r59            25             2     8.6603546     3.9691534     .02911582     1.4971259     14.525501
r60            26             1     4.1112123     2.4125166      .0883591     .49248168     10.400097
r61            27             1    -1.5031422     3.2839763      .6471535    -8.9249649     4.3931537

. mat list e(coefs)

e(coefs)[3,5]
             coef           sd      p_value  lower_bound  upper_bound
cons    12.312599    .34418586            0    11.517027    12.854612
  X1    .99705172     .0311473            0    .93131256    1.0500249
  X2    2.9785836    .02942648            0    2.9135377    3.0270903

For better visuals, users can limit the period relative to the treatment in the plot to [-14,5]. Users can also change the label of the x-axis, the y-axis and the title by using the options xlabel(), ylabel() and title(), respectively.

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) method("ife") r(2) se preperiod(-14) offperiod(5) xlabel("s") ylabel
> ("ATTs") vartype("jackknife")
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Jackknifing...

Exitting Plot

If the treatment has reversals, users can choose to plot the dynamic effects of “exitting” the treatment by turning on the option exit.

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) method("ife") r(2) se exit
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
ATT Estimation: Already Bootstrapped 200 Times

Equivalence Test

Users can evaluate whether the identification assumption is likely to be valid by conducting an equivalence test. It checks whether the 90% confidence intervals for estimated ATTs at pre-treatment period exceed a pre-specified range. While users can check the values of confidence intervals, fect give a visualization of the equivalence test. When the option equiTest is on, all of the pre-treatment residual average, the equivalence confidence intervals(0.36 times the residual standard deviation) and the minium bounds will be drawn. The test range is also specified in the option preperiod(). Below, we visualize the result of the equivalence test for each of the three estimators using our simulated data. These figures show that both the IFE and MC methods pass the equivalence test while the FE method does not. An goodness-of-fit F-test for the pre-treatment periods is also performed.

FE model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("fe") preperiod(-14) offperiod(0) equiTest nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
-----------------------------------------------------------------------------------------------------------------------
Equivalence Test
Equivalence Test...Fail at s=-2
Equivalence Test...Fail at s=-1
Equivalence Test...Fail at s=0
Equivalence Test...Fail
F = 2.5177438
Equivalence F-Test...Pass

IFE model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("ife") r(2) preperiod(-14) offperiod(0) equiTest nboots(10
> 0)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
-----------------------------------------------------------------------------------------------------------------------
Equivalence Test
Equivalence Test...Pass
F = .07067194
Equivalence F-Test...Pass

MC model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("mc") lambda(0.004) preperiod(-14) offperiod(0) equiTest n
> boots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
-----------------------------------------------------------------------------------------------------------------------
Equivalence Test
Equivalence Test...Pass
F = .27478298
Equivalence F-Test...Pass

PlaceboTest

In addition to them, fect provides a placebo test to alleviate the concern of over-fitting in the pre-trend. Users can specify a range of pre-treatment periods as “placebo periods” in the option placeboperiod() to remove observations in the specified range for model fitting, and then test whether the estimated ATT in this range is significantly different from zero. By default, we set [-2, 0] as the placebo periods (placeboperiod(3)) and the plot will display the p-value of the placebo test. Below, we visualize the result of the placebo test for each of the three estimators using our simulated data. These figures show that only the IFE method pass the placebo test test.

FE model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("fe") placeboTest nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Placebo Test...
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
Placebo Test Fail

IFE model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("ife") r(2) placeboTest nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Placebo Test...
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
Placebo Test Pass

MC model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("mc") lambda(0.004) placeboTest nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Placebo Test...
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
Placebo Test Fail

CarryoverTest

Under a general treatment pattern where treatments may exit and switch off, fect provides a carryover test to alleviate the concern that the treatment effect would presist for some time after its exit. Users can specify a range of post-treatment periods as “carryover periods” in the option carryoverperiod() to remove observations in the specified range for model fitting, and then test whether the estimated ATT in this range is significantly different from zero. By default, we set [0, 2] as the carryover periods (carryoverperiod(3)) and the plot will display the p-value of the carryover test. Below, we visualize the result of the carryover test for each of the three estimators using a DIFFERENT simulated data with a more general treatment pattern. These figures show that only the IFE method pass the carryover test test.

FE model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("fe") carryoverTest nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Carryover Test...
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
Carryover Test Pass

IFE model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("ife") r(2) carryoverTest nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Carryover Test...
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
Carryover Test Pass

MC model

. fect Y,  treat(D) unit(id) time(time) cov(X1 X2) se method("mc") lambda(0.004) carryoverTest nboots(100)
Balanced Panel Data
Treatment has reversals.
-----------------------------------------------------------------------------------------------------------------------
Carryover Test...
Bootstrapping...
ATT Estimation: Already Bootstrapped 100 Times
Carryover Test Pass

Note:

When running on huge dataset, the fect R version is faster than the Stata version and thus will be a better choice, this is because we use C++ and parallel computing in R to accelerate the computation.