help xtdcce2fast v. 1.00 - August 2021
SJ18-3: st0536

Title

xtdcce2fast - estimating heterogeneous coefficient models using common correlated effects in a dynamic panel
with a large number of observations over groups and time periods.
A faster version of xtdcce2

Syntax

xtdcce2fast depvar [indepvars] [if] [in] ,
crosssectional(varlistcr1 [,options1])
[
globalcrosssectional(varlistcr2 [,options1])
clustercrosssectional(varlistcr3 [,options1])
pooled(varlist)
cr_lags(string)
nocrosssectional
lr(varlist)
lr_options(string)
noconstant
pooled
pooledconstant
pooledvce(string)
fullsample
notable
nocd
postframe
nopost
]

Options for cross-sectional averages

options1 Description

cr_lags(numlist) number of lags of cross-section averages

clustercr(varlist) name of cluster variable(s), only for clustercrosssectional

Data has to be xtset before using xtdcce2fast; see tsset.
varlists may contain time-series operators, see tsvarlist.
xtdcce2fast requires the moremata package.

Contents

Description

Options

Saved Values

Postestimation commands

Examples

References

About

Description

xtdcce2fast estimates a heterogeneous coefficient model in a large panel with dependence between cross sectional units.
A panel is large if the number of cross-sectional units (or groups) and the number of time periods are going to infinity.

It fits the following estimation methods:

i) The Mean Group Estimator (MG, Pesaran and Smith 1995).

ii) The Common Correlated Effects Estimator (CCE, Pesaran 2006),

iii) The Dynamic Common Correlated Effects Estimator (DCCE, Chudik and Pesaran 2015)

iv) The regularised CCE (rCCE, Juodis 2022), and

For a dynamic model, several methods to estimate long run effects are possible:

a) The Cross-Sectional Augmented Distributed Lag (CS-DL, Chudik et. al 2016) estimator which directly estimates the long run coefficients
from a dynamic equation,

b) The Cross-Sectional ARDL (CS-ARDL, Chudik et. al 2016) estimator using an ARDL model and,

c) The Cross-sectional Augmented Error Correction model.

For a further discussion see Ditzen (2021).
xtdcce2fast automatically tests for cross sectional dependence (see xtcd2).

For an overview of the models and their explanation see xtdcce2.

xtdcce2fast is an optimized version for speed and large datasets.
In comparison to xtdcce2 it does not perform any collinearity checks
does not support instrumental variable regressions.
Pooled regressions are possible, but only for the entire set of variables.
It also stores some estimation results in mata rather than e() to
circumvent some restrictions on matrix dimensions in Stata, see limits.

Options

crosssectional(varlistcr1 [,cr_lags(#) rcce[(criterion(string) scale npc(real)]]) defines the variables which are added as cross sectional averages to the equation.
Variables in crosssectional() may be included in pooled(), exogenous_vars(), endogenous_vars() and lr().
Variables in crosssectional() are partialled out, the coefficients not estimated and reported.

crosssectional(_all) adds all variables as cross sectional averages.
No cross sectional averages are added if crosssectional(_none) is used, which is equivalent to nocrosssectional.
crosssectional() is a required option but can be substituted by nocrosssectional.

If cr(..., cr_lags()) is used, then the global option cr_lags() (see below) is ignored.

rcce[criterion(string) scale nps(real)] invokes regularized cross-section averages from Juodis (2022) for static panels.
The number of common factors in the cross-section averages is estimated and
then the respective number of eigenvectors from the cross-section averages is used. For more details see details.

Detailed Options are:

criterion(er|gr) specifies criterion to identify number of common factors using the ER or GR criterion from Ahn and Horenstein (2013), see xtnumfac.
scale scales cross-section averages, see Juodis (2022).
npc(real) specifies number of eigenvectors without estimating it. Cannot be combined with criterion.

globalcrosssectional(varlistcr1 [,cr_lags(#)]) define global cross-section averages.
global cross-section averages are cross-section averages based on observeations which are excluded using if statements.
If cr(..., cr_lags()) is used, then the global option cr_lags() (see below) is ignored.

clusterosssectional(varlistcr1 [,cr_lags(#)] clustercr(varlist)) are clustered or local cross-section averages.
That is, the cross-section averages are the same for each realisation of the variables defined in clustercr().
For example, we have data observations regions of multiple countries, defined by variable country
Now we want to add cross-section averages for each country.
We can define those by using the option clustercr(varlist , clustercr(country)).

If cr(..., cr_lags()) is used, then the global option cr_lags() (see below) is ignored.

cr_lags(integers) sets the number of lags of the cross sectional averages.
If not defined but crosssectional() contains a varlist, then only contemporaneous cross sectional averages are added but no lags.
cr_lags(0) is the equivalent.
The number of lags can be different for different variables, where the order is the same as defined in cr().
For example if cr(y x) and only contemporaneous cross-sectional averages of y but 2 lags of x are added,
then cr_lags(0 2).

nocrosssectional suppresses adding any cross sectional averages
Results will be equivalent to the Mean Group estimator.

noconstant suppresses the constant term.

pooled treats all variables as homogenous coefficients.
The constant is still heterogenous.

pooledvce(np|nw) which variance estimator to use,
np is the default and the non parametric estimator from Pesaran (2006).
nw is the HAC robust Newey West type estimator.

pooledconstant homogenous constant.

xtdcce2fast is able to estimate long run coefficients.
Three models are supported:
The CS-ECM (see xtdcce2, ecm, with heterogenous long run relationship),
CS-DL (see xtdcce2, csdl)
and CS-ARDL method (see xtdcce2, ardl) as developed in Chudik et. al 2016.
No options for the CS-DL model are necessary.

lr(varlist) specifies the variables to be included in the long-run cointegration vector.
The first variable(s) is/are the error-correction speed of adjustment term.
The default is to use the pmg model.
In this case each estimated coefficient is divided by the negative of the long-run cointegration vector (the first variable).
If the option ardl is used, then the long run coefficients are estimated as the sum over the coefficients relating to a variable,
divided by the sum of the coefficients of the dependent variable.

lr_options(string), options for the long run coefficients. Options are:

ardl estimates the CS-ARDL estimator. For further details see xtdcce2, ardl.
ecm estimates the CS-ECM estimator, the default.
nodivide coefficients are not divided by the error correction speed of adjustment vector. Equation (7) is estimated, see xtdcce2, pmg.
nominus does not subtract -1 from the coefficient of the dependent variable.

cd calculate CD test. For details about the CD test see xtcd2.

fullsample uses entire sample available for calculation of cross sectional averages.
Any observations which are lost due to lags will be included in calculating the
cross sectional averages (but are not included in the estimation itself).
The option does not remove any if statements.
This means, that if an if removes certain cross-sectional units from
the estimation sample, xtdcce2 will not use those (as specified by if),
even if fullsample is used.

notable do not display output.

nocd do not calculate CD test statistic, see xtcd2.

postframe save predicted values to frame. Speeds up predict.

nopost do not save/post predicted values.

Saved Values

xtdcce2 stores the following in e():

Scalars
e(N) number of observations
e(N_g) number of groups (cross sectional units)
e(T) number of time periods
e(K_mg) number of regressors (excluding variables partialled out)
e(r2_mg) pooled or mean group R-squared adjusted
e(cd) CD test statistic
e(cdp) p-value of CD test statistic
e(Tmin) minimum time (only unbalanced panels)
e(Tbar) average time (only unbalanced panels)
e(Tmax) maximum time (only unbalanced panels)

Macros
e(tvar) name of time variable
e(idvar) name of unit variable
e(depvar) name of dependent variable
e(indepvar) name of independent variables
e(cmd) command line
e(cmdline) command line including options
e(cr_lags structure of lags of cross-section averages
e(csa) cross-section averages
e(gcr_lags structure of lags of global cross-section averages
e(gcsa) global cross-section averages
e(ccr_lags structure of lags of clustered/local cross-section averages
e(ccsa) clustered/local cross-section averages
e(ccsa_cluster) cluster variable(s) for clustered cross-section averages

Matrices
e(b) coefficient vector
e(V) variance-covariance matrix

Mata
xtdcce2fast_bi coefficient vector, unit specific estimates
xtdcce2fast_Vi variance-covariance matrix, unit specific estimates

Functions
e(sample) marks estimation sample

Postestimation Commands

predict, estat and estat bootstrap can be used after xtdcce2fast.

predict

The syntax for predict is:

predict [type] newvar [if] [in] [ options ]

Options Description

xb calculate linear prediction on partialled out variables
xb2 calculate linear prediction on non partialled out variables
residuals calculate residuals (e(i,t))
cfresiduals calculate residuals including the common factors (u(i,t))
coefficients a variable with the estimated cross section specific values for all coefficients is created. The name of the new variable is newvar_varname.
se as coefficient, but with standard error instead.
cov(v1 v2) returns the covariance of the coefficients of v1 and v2.
replace replace the variable if existing.

For a detailed discussion of the postestimation options see xtddce2 postestimation.

estat

estat ebistructure displays the structure for each cross-sectional unit.
It indicates if a coefficient was estimated, dropped, set to zero and if the coefficient
is pooled.

Examples

An example dataset of the Penn World Tables 8 is available for download here.
The dataset contains yearly observations from 1960 until 2007 and is already tsset.
To estimate a growth equation the following variables are used:
log_rgdpo (real GDP), log_hc (human capital), log_ck (physical capital) and log_ngd (population growth + break even investments of 5%).

Mean Group Estimation

To estimate equation (3), the option nocrosssectional is used.
In order to obtain estimates for the constant, the option reportconstant is enabled.

xtdcce2fast d.log_rgdpo L.log_rgdpo log_hc log_ck log_ngd , nocross.

Common Correlated Effect

Common Correlated effects (static) models can be estimated in several ways.
The first possibility is without any cross sectional averages related options:

xtdcce2fast d.log_rgdpo log_hc log_ck log_ngd , cr(_all).

To check if residuals still exhibit cross-sectional dependence,
the test for cross-section dependence can be included:

xtdcce2fast d.log_rgdpo log_hc log_ck log_ngd , cr(_all) cd.

Dynamic Common Correlated Effect

The lagged dependent variable is added to the model again.
To estimate the mean group coefficients consistently, the number of lags is set to 3:

xtdcce2fast d.log_rgdpo L.log_rgdpo log_hc log_ck log_ngd , cr(d.log_rgdpo L.log_rgdpo log_hc log_ck log_ngd) cr_lags(3).

Error Correction Models (CS-ECM)

Variables of the long run cointegration vector are defined in lr(varlist), where the first variable is the error correction speed of adjustment term.
Following the example from Blackburne and Frank (2007) with the jasa2 dataset
(the dataset is available at here from Pesaran's webpage).

xtdcce2fast d.c d.pi d.y if year >= 1962 , lr(L.c pi y) cr(_all) cr_lags(2)

Cross-Section Augmented Distributed Lag (CS-DL)

Chudik et. al (2013) estimate the long run effects of public debt on output growth
(the data is available here
on Kamiar Mohaddes' personal webpage).
In the dataset, the dependent variable is d.y and the independent variables are the inflation rate (dp) and debt to GDP ratio (d.gd).
For an ARDL(1,1,1) only the first difference of dp and d.gd are added as further covariates.
Only a contemporaneous lag of the cross-sectional averages (i.e. cr_lags(0)) of the dependent variable and
3 lags of the independent variables are added.
The lag structure is implemented by defining a numlist rather than a number in cr_lags().
For the example here cr_lags(0 3 3) is used, where the first
number refers to the first variable defined in cr(), the second to the second etc.

To replicate the results in Table 18, the following command line is used:

xtdcce2fast d.y dp d.gd d.(dp d.gd), cr(d.y dp d.gd) cr_lags(0 3 3) fullsample

For an ARDL(1,3,3) model the first and second lag are of the first differences are added by putting L(0/2) in front of the d.(dp d.gd):

xtdcce2fast d.y dp d.gd L(0/2).d.(dp d.gd), cr(d.y dp d.gd) cr_lags(0 3 3) fullsample

Note, the fullsample option is used to reproduce the results in Chudik et. al (2013).

Cross-Section Augmented ARDL (CS-ARDL)

Chudik et. al (2013) estimate besides the CS-DL model a CS-ARDL model.
To estimate this model all variables are treated as long run coefficients and thus added to varlist in lr(varlist).
xtdcce2fast first estimates the short run coefficients and the calculates then long run coefficients,
following Equation 10.
The option lr_options(ardl) is used to invoke the estimation of the long run coefficients.
Variables with the same base (i.e. forming the same long run coefficient) need to be either
enclosed in parenthesis or tsvarlist operators need to be used.
In Table 17 an ARDL(1,1,1) model is estimated with three lags of the cross-sectional averages:

xtdcce2fast d.y , lr(L.d.y dp L.dp d.gd L.d.gd) lr_options(ardl) cr(d.y dp d.gd) cr_lags(3) fullsample

xtdcce2fast calculates the long run effects identifying the variables by their base.
For example it recognizes that dp and L.dp relate to the same variable.
If the lag of dp is called ldp, then the variables need to be enclosed in parenthesis.

Estimating the same model but as an ARDL(3,3,3) and with enclosed parenthesis reads:

xtdcce2fast d.y , lr((L(1/3).d.y) (L(0/3).dp) (L(0/3).d.gd) ) lr_options(ardl) cr(d.y dp d.gd) cr_lags(3) fullsample

which is equivalent to coding without parenthesis:

xtdcce2fast d.y , lr(L(1/3).d.y L(0/3).dp L(0/3).d.gd) lr_options(ardl) cr(d.y dp d.gd) cr_lags(3) fullsample

References

Ahn, S. C., & Horenstein, A. R. (2013).
Eigenvalue ratio test for the number of factors.
Econometrica, 81(3), 1203-1227.

Baum, C. F., M. E. Schaffer, and S. Stillman 2007.
Enhanced routines for instrumental variables/generalized method of moments estimation and testing.
Stata Journal 7(4): 465-506

Blackburne, E. F., and M. W. Frank. 2007.
Estimation of nonstationary heterogeneous panels.
Stata Journal 7(2): 197-208.

Chudik, A., K. Mohaddes, M. H. Pesaran, and M. Raissi. 2013.
Debt, Inflation and Growth: Robust Estimation of Long-Run Effects in Dynamic Panel Data Model.

Chudik, A., and M. H. Pesaran. 2015.
Common correlated effects estimation of heterogeneous dynamic panel data models with weakly exogenous regressors.
Journal of Econometrics 188(2): 393-420.

Chudik, A., K. Mohaddes, M. H. Pesaran, and M. Raissi. 2016.
Long-Run Effects in Large Heterogeneous Panel Data Models with Cross-Sectionally Correlated Errors
Essays in Honor of Aman Ullah. 85-135.

Bai, J. and Ng, S. 2004.
A panic attack on unit roots and cointegration. Econometrica 72: 1127-1177.

Ditzen, J. 2018. Estimating Dynamic Common Correlated Effcts in Stata. The Stata Journal, 18:3, 585 - 617.

Ditzen, J. 2021. Estimating long run effects and the exponent of cross-sectional dependence: an update to xtdcce2. The Stata Journal 21:3.

Eberhardt, M. 2012.
Estimating panel time series models with heterogeneous slopes.
Stata Journal 12(1): 61-71.

Holly, S., Pesaran, M. H., Yamagata, T. 2010.
A spatio-temporal model of house prices in the USA.
Journal of Econometrics 158: 160 - 172.

Feenstra, R. C., R. Inklaar, and M. Timmer. 2015.
The Next Generation of the Penn World Table. American Economic Review. www.ggdc.net/pwt

Jann, B. 2005.
moremata: Stata module (Mata) to provide various functions.
Available from http://ideas.repec.org/c/boc/bocode/s455001.html.

Juodis A. 2022.
A regularization approach to common correlated effects estimation.
Journal of Applied Econometrics, 37(4), 788–810.

Pesaran, M. H. 2006.
Estimation and inference in large heterogeneous panels with a multifactor error structure.
Econometrica 74(4): 967-1012.

Pesaran, M. H., and R. Smith. 1995.
Econometrics Estimating long-run relationships from dynamic heterogeneous panels.
Journal of Econometrics 68: 79-113.

Roodman, D., Nielsen, M. Ø., MacKinnon, J. G., & Webb, M. D. 2019.
Fast and wild: Bootstrap inference in Stata using boottest.
The Stata Journal, 19(1), 4–60.

Shin, Y., M. H. Pesaran, and R. P. Smith. 1999.
Pooled Mean Group Estimation of Dynamic Heterogeneous Panels.
Journal of the American Statistical Association 94(446): 621-634.

Westerlund, J., Perova, Y., Norkute, M. 2019. CCE in fixed-T panels.
Journal of Applied Econometrics: 1-6.

Author

Jan Ditzen (Free University of Bozen-Bolzano)

Email: jan.ditzen@unibz.it

Web: www.jan.ditzen.net

Please cite as follows:

Ditzen, J. 2018. xtdcce2: Estimating dynamic common correlated effects in Stata. The Stata Journal. 18:3, 585 - 617.

or

Ditzen, J. 2021. Estimating long run effects and the exponent of cross-sectional dependence: an update to xtdcce2. The Stata Journal 21:3

The latest versions can be obtained via net from https://github.com/JanDitzen/xtdcce2.

Version History

This version: 1.0 - 16. August 2021

Also see

See also: xtdcce2, xtcd2, xtcse2, ivreg2, xtmg, xtpmg, moremata