help xthst v. 1.5 - 11. Feburary 2022
SJ21-1: st0627

Title

xthst - testing for slope homogeneity in large panels.

Syntax

xthst depvar indepvars [if] [,partial(varlist_p)
noconstant
ar
hac
bw(integer)
whitening
kernel(qs|bartlett|truncated)
crosssectional(varlist_cr
[,cr_lags(numlist)])
nooutput
comparehac
]

depvar and indepvars may contain time-series operators; see tsvarlist.

Data must be xtset before using xthst; see xtset.

depvar is the dependent variable of the model to be tested,
indepvar the independent variables.

varlist_p are the variables to be partialled out,
varlist_cr are variables added as cross-sectional averages.

Contents

Options

Description

Econometric Model

Saved Values

Examples

References

Version History

About

Description

xthst performs a test of slope homogeneity in panels with
a large number observations of the cross-sectional (N) and time (T) dimension.
The null hypothesis of the test is of homogenous slopes.
This implies all slope coefficients are identical across cross-sectional units.

The test is a standardized version of Swamey's test for slope homogeneity presented by Peasaran and Yamagata (2008).
The cross-section dimension (N) and the time dimension (T), are required to be large.
Slope heterogeneity yields consistent results if the true model has homogenous slopes.
However the estimates are inefficient.
If the true model consists of heterogeneous slopes, imposing slope homogeneity
yields inconsistent and biased results.

The test implicitly estimates two models and compares them.
The restricted model is the weighted fixed effects estimator, which imposes
slope homogeneity. The unrestricted model, the model under the alternative,
is a cross-sectional unit specific OLS regression model.

The test is based the difference of the two models.
Large values of the test statistic imply a disagreement between fixed effects and unit specific
estimates and therefore the null of slope homogeneity can be rejected.

xthst can be used for both balanced and unbalanced panels.
The program supports models with strictly exogenous regressors and an AR(p) model.
For the latter, an additional assumption is required: (N,T) jointly converge to
infinity, meaning that N/T needs to be constant.
The test allows for non-normally distributed errors, such as serial correlated errors.
xthst uses the HAC consistent test statistic derived by Blomquist and Westerlund (2013).
In addition, Bersvendsen and Ditzen (2020) show using simulation
results that by adding cross sectional averages to the model,
the test works for situations with cross-section dependence in the error term and variables.

xthst can check for cross-sectional dependence using xtcd2.
In addition it can show results of the standard delta test and the hac robust version
to help finding the optiomal set of options.
For differences between the options and their impact on results,
see the simulations in Bersvendsen and Ditzen (2020).

Econometric Model

Based on Pesaran and Yamagata (2008), consider the following model with k = k1 + k2 regressors

y_it = alpha_i + x1_it * beta1_i + x2_it * beta2_i + e_it

or

y_it = z1_it * theta_i + x2_it * beta2_i + e_it

where z1_it = (1, x1_it), heta_i = (alpha_i, beta1_i},
x1_it contains k1 regressors and x2_it contains k2.
Suppose the coefficient of interest are those in beta_i,
then the hypothesis of slope homogeneity is:

H0: beta2_i = beta2, for all i = 1,...,N

The derived test statistic by Pesaran and Yamagata (2008) is:

Delta = sqrt(N) ((1/N * S2_tilde - k_2)/sqrt(2*k_2))

where, under the H0, the statistic is asymptotically Delta ~ N(0,1) distributed.

S2_tilde is defined as in equation 13 in Peasaran and Yamagata (2008):

S2_tidle = sum(i=1,N) (b2_i - b2_wfe)'((X2_i' * M1_i * X2_i)/sigma2_i)(b2_i - b2_wfe),

where b2_i is the estimate of beta2_i obtained from individual least squares regression.
The regressors which are not of interest, including the constant,
are assumed to be heterogeneous and are
collected in Z1_i and partialled using the projection matrix
M1_i = I_T - Z1_i(Z1_i'Z1_i)Z1_i'.
The sigma2_i is the standard error of regression of the fixed effects regression,
b2_wfe is the latter FE coefficient estimates weighted by sigma2_i.

If one are interested in testing slope homogeneity for both beta1_i and beta2_i,
the same test statistic is computed but only the constant is partialled out.
Therefore, k would replace k1 and k2 in the computations and X_i = (X1_i, X2_i) would replace X2_i.
The same result holds for an AR(p) model, see Pesaran and Yamagata (2008).

A HAC consistent test statistic is derived by Blomquist and Westerlund (2013).
In this case S2_tilde is replaced by S_hac:

S_hac = sum(i=1,N) T*(b_i - b)' (Q_i,T * inv(V_i,T) * Q_i,T) (b_i - b)

where b_i being the OLS estimator for cross-section unit i and,

b = inv(sum(i=1,N) T*Q_i,T * inv(V_i,T) * Q_i,T )*(sum(i=1,N) Q_i,T * inv(V_i,T) * X_i * M_t * y_i).

In the equation above, Q_i,T = (X_i'*M_t*X_i) / Ti.
M_t is the projection matrix which partials out the constant or variables assumed to have heterogeneous slopes.
Heteroskedasticity and serial correlation are dealt with by the following HAC estimator:

V_i,T = L_i(0) + sum(j=1,bw)(kr(j/bw)[L_i(j) + L_i(j)']),

where, bw is the selected bandwidth and kr the chosen kernel.
Available kernels are Bartlett (default), Quadratic Spectral (QS) and Truncated.
L_i(j) is the correlation between the residual of a fixed effects regression
multiplied with the demeaned explanatory regressors in t and in t-j.
If not specified, the bandwith is automatically selected following
Andrews and Monahan (1992) and Newey West (1994).

Options

noconstant suppresses the individual heterogeneous constant, alpha_i.

partial(varlist_p) requests exogenous regressors in varlist_p to be partialled out.
The constant is automatically partialled out, if included in the model.
Regressors in varlist will be included in z_it, explained in Econometric Model.
These regressors are assumed to have heterogeneous slopes.

ar allows for an AR(p) model. The degree of freedom of S2_tilde is
adjusted.
May not be combined with hac.

hac implements the HAC consistent test by Blomquist and Westerlund (2013).
If kernel and bw are not specified, kernel is set to bartlett.
May not be combined with ar.

kernel(kernel) specifies the kernel function used in calculating the HAC consistent test statistic.
Available kernels: bartlett, qs (quadratic spectral) and truncated.
Is only required in combination with hac.

bw(#) bandwidth equal to # for the HAC consistent test statistic,
where # is an integer greater than zero.
Is only required in combination with hac.
If not set then the automatic bandwidth selection from
Andrews and Monahan (1992) and Newey West (1994) is used.

whitening performs prewhitening to reduce small-sample bias in HAC estimation,
see Andrews and Monahan (1992).
Is only required in combination with hac.

crosssectional(varlist_cr [,cr_lags(numlist)])
defines the variables which are added as cross-sectional averages to the model to approximate cross-sectional dependence.
Variables in varlist_cr are partialled out.
cr_lags(numlist) 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)

nooutput omits output.

comparehac compares the standard delta test to the HAC robust version.
First the standard delta test is run, then the HAC robust version.
Results for both tests are displayed.
If the tests disagree a message is posted.
In addition the base of all variables are tested for cross-sectional dependence
using xtcd2 (requires findit xtcd2).
If cross-sectional dependence is found, a message is posted.
The options crosssectional(), partial() and noconstant apply to both test.
All HAC related options are only used for the HAC robust run.

This option is only for testing purposes and should not replace
further testing.

Saved Values

xthst stores the following in r():

Scalars
r(bw) bandwidth

Macros
r(crosssectional) variables of which cross-section averages are added
r(partial) variables partialled out
r(kernel) used kernel

Matrices
r(delta) delta and adjusted delta
r(delta_p) p-values of above

Examples

An example dataset taken from the Penn World Tables 8 is available
for download here.
The dataset contains yearly observations from 1960 until 2007 and is already xtset.
The dataset contains real GDP (log_rgdpo), human capital (log_hc),
physical captial (log_ck) and population growth
added with break even investments of 5% (log_ngd).

We want to test whether slope coefficients in a simple Solow-type growth
model are homo- or heterogeneous.
If our model excludes the lag of the dependent variable (for exemplified purpose),
the command line is:

xthst d.log_rgdpo log_hc log_ck log_ngd.

The p-values for the non-adjusted and adjusted Delta test imply that the
null of slope homogeneity can be rejected.

In the next step, the first lag
of log GDP is added and an ARDL(1,0) model estimated:

xthst d.log_rgdpo L.d.log_rgdpo log_hc log_ck log_ngd.

In case the assumption is that all variables except the lag of GDP are heterogeneous,
the partial(varlist_partial) option can be used.
In this case all variables defined varlist_partial are partialled out
and assumed to be heterogeneous:

xthst d.log_rgdpo L.d.log_rgdpo log_hc log_ck log_ngd, partial(log_hc log_ck log_ngd).

The test confirms that the coefficient of the lag of GDP is heterogeneous,
however the test statistic decreased in comparison to the model above.

In a dynamic macro dataset it is likely that errors exhibit serial correlation.
To account for autocorrelation in the residual, the option hac can
be employed to use the HAC robust standard errors following
Blomquist, Westerlund (2013):

xthst d.log_rgdpo L.d.log_rgdpo log_hc log_ck log_ngd, hac.

Instead of the bartlett kernel, we can use the Quadratic-Spehere kernel with,
say, a bandwidth of 6 by using the options kernel() and bw():

xthst d.log_rgdpo L.d.log_rgdpo log_hc log_ck log_ngd, hac kernel(qs).

To guide the researcher it is possible to directly compare the test results
from the standard delta test and the hac robust version.
The option performs both tests and - if installed - checks
with xtcd2 for cross-sectional dependence.

xthst d.log_rgdpo L.d.log_rgdpo log_hc log_ck log_ngd, comparehac.

In large panels cross-sectional dependence is likely, see
xtdcce2, xtcd2 and xtcse2.
xthst can remove cross-sectional dependence by adding cross-sectional averages.
The cross-sectional averages are partialled out.

The option crosssectional(varlist_csa[, lags(numlist)])
defines the variables to be added as cross-sectional averags and the number of lags.
For example we add the cross-sectional averages of the base of all variables and
use 1 lag for log GDP, 2 lags for physical capital and 3 for the other variables,
the command line is:

xthst d.log_rgdpo L.d.log_rgdpo log_hc log_ck log_ngd, cr(d.log_rgdpo log_hc log_ck log_ngd, cr_lags(1 3 2 3)).

As a final example, the AR(p) adjusted test from Pesaran, Yamagata (2008)
can be employed using the option ar:

xthst d.log_rgdpo L(1/3).d.log_rgdpo, ar.

References

Andrews, D. W. K. and J. C. Monahan. 1992.
An Improved Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimator.
Econometrica 60(4), p. 953 - 966.

Bersvendsen, T. and J. Ditzen. 2020.
xthst: Testing for slope homogeneity in Stata.
CEERP Working Paper Series No. 011.
Download.

Blomquist, J. and J. Westerlund. 2013. Testing slope homogeneity in large panels with serial correlation.
Economics Letters 121, pp 374 - 378.

Newey, W. K. and K. D. West. 1994. Automatic Lag Selection in Covariance Matrix Estimation.
Review of Economic Studies 61(4), pp. 631-653.

Pesaran, M. H. and T. Yamagata. 2008. Testing slope homogeneity in large panels.
Journal of Econometrics 142, pp 50 - 93.

About

Tore Bersvendsen (Department of Research and innovation, Kristiansand Municipality, Norway)

Email: Tore.Bersvendsen@kristiansand.kommune.no

Jan Ditzen (Free University of Bozen-Bolzano)

Email: jan.ditzen@unibz.it

Web: www.jan.ditzen.net

We are grateful to Jochen Jungeilges
for providing many helpful comments and discussions.
Johan Blomquist and Joakim Westerlund kindly provided their Gauss Code for
cross-checking.
An anonymous referee suggested the option comparehac.
All remaining errors are our own.

Please cite as:

Bersvendsen, Ditzen. 2021. Testing for slope heterogeneity in Stata. The Stata Journal 21(1), pp. 1-30.

Version History

This version: 1.4 - 08 January 2021

- If option crosssectional() used, xthst used the variables defined by
crosssectional() to test for slope heterogeneity.

This version: 1.3 - 13 February 2020

- Added comparehac option.

Version 1.2 - 27.February 2020

- Corrected output when cross-sectional averages used.

- Corrections and additions to help file.

Version 1.1 - 17. January 2020

- Improved Speed.

- Bug fix in small sample adjustment for S and S_HAC.

- Bug fix if hac used, first auto correlation was miscalculated.