*! version 4.0.0 07 Jan 2023
help rcm

Title

rcm -- efficient implementation of regression control method (RCM), aka panel data approach (PDA) for program evaluation (Hsiao et al., 2012)

Syntax

rcm depvar [indepvars],
trunit(#)
trperiod(#)
[options]

Model
counit(numlist:numlist) control units to be used as the donor pool

preperiod(numlist:numlist) pre-treatment periods before the intervention occurred

postperiod(numlist:numlist) post-treatment periods when and after the intervention occurred

Optimization
scope(p_min p_max) range of the number of selected predictors

method(sel_method) method for selecting the suboptimal model

criterion(sel_criterion) criterion for selecting the optimal model

estimate(est_method) method for estimating post-selection coefficients

grid(#_g [, ratio(#) min(#)]) set of possible lambdas with #_g grid points

fold(#_k) #_k fold cross-validation

seed(int) seed used by the random number generator

fill(fil_method) method used to fill in missing values

Placebo Test
placebo([unit unit(numlist) period(numlist) cutoff(#_c)]) placebo test using fake treatment unit and/or time

Reporting
frame(framename) create a Stata frame storing generated variables in wide form including counterfactual predictions, treatment effects, and results from placebo tests if implemented

nofigure Do not display figures. The default is to display all figures.

savegraph([prefix], [asis replace]) Save all produced graphs to the current path.

xtset panelvar timevar must be used to declare a panel dataset in the usual long form; see [XT] xtset.
rcm automatically reshapes the panel dataset from long to wide form suitable for implementing regression control method.

depvar and indepvars must be numeric variables, and abbreviations are not allowed.

Description

rcm efficently implements regression control method (RCM), aka panel data approach for program evaluation (Hsiao et al., 2012),
which exploits cross-sectional correlation to construct counterfactual outcomes for a single treated unit by linear regression (OLS), lasso or post-lasso OLS.
Available methods for model selection include best subset, lasso, forward stepwise and backward stepwise regression, while available selection criteria include AICc, AIC, BIC, MBIC and CV (cross-validation).
Covariates (indepvars) are allowed to further improve counterfactual prediction as proposed by Hsiao and Zhou (2019).
The rcm command produces a series of graphs for visualization along the way.
For statistical inference, both in-space placebo test using fake treatment units and in-time placebo test using a fake treatment time can be implemented.
For a detailed guidence to the usage of rcm, you may refer to Yan and Chen (2021).

Required Settings

rcm automatically reshapes the panel dataset from long to wide form before implementation,
where depvar of the treated unit is transformed to be the response and depvar of the control units are transformed to be predictors.
If indepvars are specified, indepvars of all units are transformed to be predictors during this process.

trunit(#) the unit number of the treated unit (i.e., the unit affected by intervention) as given in the panel variable specified in xtset panelvar. Note that only a single unit number can be specified.

trperoid(#) the time period when the intervention occurred.
The time period refers to the time variable specified in xtset timevar, and must be an integer (see examples below).
Note that only a single time period can be specified.

Options

The model selection consists of two steps that rcm performs automatically. Understanding the steps is helpful for specifying options.

Step 1: Select the suboptimal models

rcm selects a series of suboptimal models, each contains a unique subset of predictors.
The exact procedure for selecting the suboptimal model depends on the selection method specified by method(sel_method).
Available selection methods include best subset, lasso, forward stepwise and backward stepwise selections; see below for details.

Step 2: Select the optimal model from the suboptimal models

rcm selects the optimal model from the suboptimal models by information criterion or cross-validation as specified by criterion(sel_criterion).
The allowable sel_criterion include aicc, aic, bic, mbic and cv (only available for method(lasso)).
By default, there is no restriction on the number of predictors in selecting the optimal model, but the allowable number of predictors can be specified by scope(p_min p_max) to limit its range.

After model selection, rcm use the optimal model for counterfactual prediction and estimation of treatment effects.
estimate(est_method) specifies the method used to estimate the optimal model, and the allowable sel_criterion include ols (such as OLS or post-lasso OLS) and lasso (directly uses lasso for prediction); see details below.

Model

counit(numlist:numlist) a list of unit numbers for the control units as numlist given in the panel variable specified in xtset panelvar.
The list of control units specified constitute what is known as the "donor pool". If no counit is specified,
the donor pool defaults to all available units other than the treated unit.
The previous option ctrlunit(numlist:numlist) is deprecated, but continues to work just like the current option counit(numlist:numlist).

preperiod(numlist:numlist) a list of pre-treatment periods as numlist given in the time variable specified in xtset timevar.
If no preperiod is specified, preperiod defaults to the entire pre-intervention period,
which ranges from the earliest time period available in the time variable to the period immediately prior to the intervention.

postperiod(numlist:numlist) a list of post-treatment periods (when and after the intervention occurred) as numlist given in the time variable specified in xtset timevar.
If no postperiod is specified, postperiod defaults to the entire post-intervention period, which ranges from the time period when the intervention occurred to the last time period available in the time variable.

Optimization

scope(p_min p_max) specifies the allowable range for the number of predictors in the optimal model. rcm selects the optimal model from the suboptimal models containing p_min to p_max predictors.
p_min and p_max are two numbers that specify the lower and upper bounds of the number of predictors, and the defaults are 1 and the number of all predictors respectively.
If there is no model with the number of predictors in the specified range, p_min and p_max are automatically changed to the default to expand the selection.

method(sel_method) specifies the method used for selecting the suboptimal model.
sel_method may be best(the default), lasso, forward, or backward.

best (best subset regression) is the default, which considers different numbers of predictors in each iteration of OLS estimation,
and select the suboptimal model with the highest R-squared for each specified number of predictors. We use the "leaps and bounds" algorithm (Furnival and Wilson, 1974) to speed up the process of best subset selection.
Nevertheless, it may still be too time-consuming when there are many predictors,
or more predictors than the number of pre-treatment periods.
In that case, you may wish to try method(lasso)(recommended), method(forward), or method(backward).
Alternatively, you may restrict indepvars, and/or the donor pool by the option counit(numlist:numlist).

lasso (lasso regression) sets a grid for lambda (known as the tuning or penalty parameter),
and fits the corresponding lasso regressions on that grid as the suboptimal models. Specifically, lambda iterates from lambda_ to lambda_; see [LASSO] lasso.

forward (forward stepwise regression) starts with the smallest model, adds a predictor in each iteration of OLS estimation,
and selects the model with the highest R-squared as the suboptimal model for each iteration. If method(best) is feasible, then method(forward) is NOT recommended.

backward (backward stepwise regression) starts with the largest possible model,
drops a predictor in each iteration of OLS estimation, and selects the model with the highest R-squared as the suboptimal model for each iteration.
If method(best) is feasible, then method(backward) is NOT recommended. Note that method(backward) is not applicable in the high-dimensional case, where the number of predictors exceeds the number of pre-treatment periods.

criterion(sel_criterion) specifies the criterion for selecting the optimal model from all suboptimal models, which may be aicc (the default), aic, bic, mbic or cv.

aicc is the defalut, which specifies the corrected Akaike information criterion (AICc) as the criterion for selecting the optimal model; see Hsiao et al. (2012) for details.

aic specifies Akaike information criterion (AIC) as the selection criterion.

bic specifies Bayesian information criterion (BIC) as the selection criterion.

mbic specifies the modified Bayesian information criterion (MBIC) as the selection criterion; see Wang et al. (2009) and Shi and Huang (2021) for details.

cv specifies cross-validation mean squared error (CVMSE) as the selection criterion.
Note that criterion(cv) only applies to method(lasso), and the option fold(#) determines the the number of folds for cross-validation (see details below).

estimate(est_method) specifies the method used to estimate the optimal model for counterfactual prediction, which may be ols (the default) or lasso.

ols is the default, which estimates the optimal model either by OLS, or post-lasso OLS, whichever is applicable. The latter corresponds to the combination of method(lasso) and estimate(ols).

lasso directly uses lasso to estimate the optimal model for counterfactual prediction. Note that estimate(lasso) only applies to method(lasso).

grid(#_g [, ratio(#) min(#)]) is a rarely used option specifying the
set of possible lambdas with #_g grid points, where ratio(#) specifies lambda_/lambda_, and min(#) specifies lambda_.
These parameters are transmitted to the Stata command lasso; see [LASSO] lasso for details.
Note that this option only applies to method(lasso).

fold(#_k) specifies cross-validation with #_k folds, where #_k must be an integer >= 3 and <= T0 (the number of pre-treatment periods). This option only applies to the combination of method(lasso) and criterion(cv).
The default is fold(T0), which corresponds to leave-one-out cross-validation (LOOCV).

seed(int) the seed used by the random number generator for reproducible results, which defaults to 1.
This option is only useful for criterion(cv).

fill(fil_method) is a rarely used option that specifies the method to fill in missing values.
If fill(mean) is specified, missing values are replaced by sample means for each unit.
If fill(linear) is specified, then missing values are replaced by linear interpolation for each unit.
Beware that these two methods for filling in missing values are rough, and only provided for convenience. If no fill(fil_method) is specified, then missing values are left unchanged.

Note that rcm generally allows for missing values in the pre-treatment periods, although it may be difficult to perform cross-validation for lasso.
However, if the selected predictors include missing values in the post-treatment periods, then there will be missing values in the counterfactual predictions and treatment effects as well.

Placebo Test

placebo([unit unit(numlist) period(numlist) cutoff(#_c)]) specifies the types of placebo tests to be performed; otherwise, no placebo test will be implemented.

unit and unit(numlist) specifies placebo tests using fake treatment units in donor pool,
where unit uses all fake treatment units and unit(numlist) uses a list of fake treatment units specified by numlist.
These two options iteratively assign the treatment to control units where no intervention actually occurred,
and calculate the p-value of the treatment effect. Note that only one of unit and unit(numlist) can be specified.

period(numlist:numlist) specifies placebo tests using fake treatment times. This option assigns the treatment to time periods previous to the intervention, when no treatment actually ocurred.

cutoff(#_c) specifies a cutoff threshold that discards fake treatment units with pre-treatment MSPE #_c times larger than that of the treated unit, where #_c must be a real number greater than or equal to 1.
This option only applies when unit or unit(numlist) is specified. If this option is not specified, then no fake treatment units are discarded.

Reporting

frame(framename) creates a Stata frame storing generated variables in wide form including counterfactual predictions, treatment effects, and results from placebo tests if implemented. The frame named framename is replaced if it already exists, or created if not.

nofigure Do not display figures. The default is to display all figures for estimation results and placebo tests if available.

savegraph([prefix], [asis replace]) automatically and iteratively calls the graph save to save all produced graphs to the current path,
where prefix specifies the prefix added to _graphname to form a file name, that is, the graph named graphname is stored as prefix_graphname.gph.
asis and replace are options passed to graph save; for details, see [G-2] graph save.
Note that this option only applies when nofigure is not specified.

Example 1: estimating the impact of political integration of Hong Kong with mainland China in 1997q3 (Hsiao et al., 2012)

. use growth, clear

. xtset region time

* Show the unit number of Hong Kong and treatment periods

. label list

. display tq(1997q3)

. display tq(2003q4)

* Replicate results in Hsiao et al.(2012) with specified control units and designated post-treatment periods

. rcm gdp, trunit(9) trperiod(150) counit(4 10 12 13 14 19 20 22 23 25) postperiod(150/175)

* Use post-lasso OLS with LOOCV and all control units,
and create a Stata frame "growth_wide" storing generated variables in wide form including counterfactual predictions, treatment effects, and results from placebo tests if implemented

. rcm gdp, trunit(9) trperiod(150) postperiod(150/175) method(lasso) criterion(cv) frame(growth_wide)

* Change to the generated Stata frame "growth_wide"

. frame change growth_wide

* Change back to the default Stata frame

. frame change default

* Implement a placebo test using all fake treatment units in the donor pool

. rcm gdp, trunit(9) trperiod(150) postperiod(150/175) method(lasso) criterion(cv) placebo(unit)

Example 2: estimating the impact of economic integration between Hong Kong and mainland China in 2004q1 (Hsiao et al., 2012)

. use growth, clear

. xtset region time

* Show the unit number of Hong Kong and the treatment period

. label list

. display tq(2004q1)

* Replicate results in Hsiao et al.(2012) with all control units

. rcm gdp, trunit(9) trperiod(176) method(best)

* Use post-lasso OLS with LOOCV, and create a Stata frame "growth_wide" storing generated variables in wide form

. rcm gdp, trunit(9) trperiod(176) method(lasso) criterion(cv) frame(growth_wide)

* Implement placebo tests using all fake treatment units in the donor pool, and fake treatment time 2002q1

. display tq(2002q1)

. rcm gdp, trunit(9) trperiod(176) method(lasso) criterion(cv) placebo(unit period(168))

Example 3: estimating the impact of German reunification in 1990 (Abadie et al., 2015)

. use repgermany.dta, clear

. xtset country year

* Show the unit number of West Germany

. label list

* Use post-lasso OLS with 10-fold cross-validation without covariates

. rcm gdp, tru(17) trp(1990) me(lasso) cr(cv) fold(10)

* Use three covariates as additional predictors

. rcm gdp infrate trade industry, tru(17) trp(1990) me(lasso) cr(cv) fold(10)

* Fill in missing values by sample means for each units, and implement placebo tests using the fake treatment units with pre-treatment MSPE 10 times smaller than or equal to that of the treated unit

. rcm gdp infrate trade industry, tru(17) trp(1990) me(lasso) cr(cv) fold(10) fill(mean) placebo(unit cut(10))

* Fill in missing values by sample means for each units, and implement a placebo test with fake treatment time 1980

. rcm gdp infrate trade industry, tru(17) trp(1990) me(lasso) cr(cv) fold(10) fill(mean) placebo(period(1980))

* Fill in missing values by linear interpolation for each units, and create a Stata frame "WestGermany_wide" storing generated variables in wide form

. rcm gdp infrate trade industry, tru(17) trp(1990) me(lasso) cr(cv) fold(10) fill(linear) frame(WestGermany_wide)

Stored results

rcm stores the following in e():

Scalars

e(T) number of observations in the dataset in wide form

e(T0) number of observations in the pre-treatment periods with the dataset in wide form

e(T1) number of observations in the post-treatment periods with the dataset in wide form

e(K_preds_all) number of all predictors

e(K_preds_sel) number of predictors selected for the optimal model

e(aicc) AICc of the optimal model fitted in the pre-treatment periods

e(aic) AIC of the optimal model fitted in the pre-treatment periods

e(bic) BIC of the optimal model fitted in the pre-treatment periods

e(mbic) MBIC of the optimal model fitted in the pre-treatment periods

e(cvmse) CVMSE of the optimal model fitted in the pre-treatment periods

e(mae) mean absolute error of the model fitted in the pre-treatment periods

e(mse) mean squared error of the model fitted in the pre-treatment periods

e(rmse) root mean squared error of the model fitted in the pre-treatment periods

e(r2) R-squared of the model fitted in the pre-treatment periods

e(att) average treatment effect on the treated unit

Macros

e(panelvar) name of the panel variable

e(timevar) name of the time variable

e(varlist) names of the dependent variable and independent variables

e(respo) name of the response

e(preds_all) names of all predictors

e(preds_sel) names of the predictors selected for the optimal model

e(unit_all) all units

e(unit_tr) treatment unit

e(unit_ctrl) control units

e(time_all) entire periods

e(time_tr) treatment period

e(time_pre) pre-treatment periods

e(time_post) post-treatment periods

e(regcmd) regress

e(regcmdline) regression command of the optimal model

e(scope) allowable range for the number of predictors to be selected

e(method) method for selecting the suboptimal models

e(criterion) criterion for selecting the optimal model from all suboptimal models

e(estimate) method for estimating the optimal model for counterfactual predictions

e(seed) seed used by the random number generator for reproducible results

e(frame) name of Stata frame storing generated variables in wide form

e(graph) names of all produced graphs

e(properties) b V

Matrices

e(b) coefficient vector of the optimal model estimated in the pre-treatment periods

e(V) variance-covariance matrix of the coefficient estimators of the optimal model fitted in the pre-treatment periods

e(info) matrix containg information of the suboptimal models

e(mspe) matrix containg pre-treatment MSPE, post-treatment MSPE, ratios of post-treatment MSPE to pre-treatment MSPE, and ratios of pre-treatment MSPE of control units to that of the treatment unit

e(pval) matrix containg estimated "treatment effects" and p-values from placebo tests using fake treatment units

Reference

Abadie, Alberto, Alexis Diamond, and Jens Hainmueller. 2015. Comparative Politics and the Synthetic Control Method.
American Journal of Political Science 59(2): 495-510.

Hsiao, Cheng, H. Steve Ching, and Shui Ki Wan. 2012. A Panel Data Approach for Program Evaluation: Measuring the Benefits of Political and Economic Integration of Hong Kong with Mainland China.
Journal of Applied Econometrics 27(5): 705-740.

Hsiao, Cheng, and Qiankun Zhou. 2019. Panel Parametric, Semiparametric, and Nonparametric Construction of Counterfactuals.
Journal of Applied Econometrics 34(4): 463-481.

Furnival, George M., and Robert W. Wilson, Jr. 1974. Regressions by Leaps and Bounds.
Technometrics 16(4): 499-511.

Shi, Zhentao and Jingyi Huang. 2021. Forward-selected panel data approach for program evaluation.
Journal of Econometrics forthcoming.

Wang, Hanseng, Bo Li and Chenlei Leng. 2009. Shrinkage tuning parameter selection with a diverging number of parameters.
Journal of Royal Statistical Society, Series B 71(3): 671-683.

Yan, Guanpeng, and Qiang Chen (2022). rcm: A command for the regression control method. The Stata Journal 22(4): 842–883.

Author

Guanpeng Yan, Shandong University, CN

guanpengyan@yeah.net

Qiang Chen, Shandong University, CN

www.econometrics-stata.com

qiang2chen2@126.com