*! version 1.0.2 19jul2024

*! Sebastian Kripfganz, www.kripfganz.de

Title

xtdpdserial -- Panel data serial correlation tests

Syntax

Syntax 1

xtdpdserial [varname] [if] [in] [, options]

Syntax 2

xtdpdserial [varname] [if] [in] [, statistics(statistics) noresiduals]

options

Main
pm compute portmanteau test

difference compute test based on first differences

sdifference compute test based on seasonal differences

order(#) restrict maximum order of serial correlation

lagrange(#_1 [#_2]) restrict range of lags to be used

[full]collapse compute collapsed version of the test

noforward ignore forward-looking covariance restrictions

nobackward ignore backward-looking covariance restrictions

noresiduals do not check for regression residuals; seldom used

Syntax 1 computes a single test statistic as specified.

In Syntax 2, statistics can be one or more of

stat[c][(#_1 [#_2])]

where stat refers to one of the statistics below, which correspond to the minimum abbreviations of the respective Syntax 1 options.
The optional element c requests a collapsed version of the test (for statistics d or sd).
The optional syntax component (#_1) with one argument is equivalent to specifying order(#_1) from Syntax 1.
With two arguments, (#_1 #_2) is equivalent to specifying lagrange(#_1 #_2) from Syntax 1.

stat

pm compute portmanteau test

c|fullc compute collapsed portmanteau test

d compute test based on first differences

sd compute test based on seasonal differences

The default is Syntax 2 with statistics(pm sdc dc fullc).

You must xtset your data before using xtdpdserial; see [XT] xtset.

varname may contain time-series operators; see tsvarlist.

xtdpdserial is a community-contributed program. The current version requires Stata version 13 or higher; see version history and updates.

If varname is not specified, xtdpdserial can be used as a postestimation command for regress, xtreg, fe, and xtreg, re,
as well as the community-contributed commands xtdpdbc and xtdpdgmm.

Description

xtdpdserial implements serial correlation tests for linear panel data models that fall into the framework of the portmanteau test developed by Jochmans (2020).
Special cases are the Arellano and Bond (1991) and Yamagata (2008) tests, and further variants proposed by Kripfganz, Demetrescu, and Hosseinkouchack (2024) designed to improve the power of the test.

By default, these are postestimation tests for serial correlation in the idiosyncratic error component e_it from a linear error components model with combined error term u_i + e_it, where u_i is the group-specific error component.
The test accounts for the estimation error in the regression residuals. If varname is specified, the command applies a standalone test to the specified variable instead of residuals.

Applied to regression residuals, these tests allow the independent variables in the regression model to be strictly exogenous, predetermined, or endogenous,
as long as the estimator is consistent under the null hypothesis of serially uncorrelated errors. The tests are robust to heteroskedasticity by construction.

Options

Main

pm requests to compute the portmanteau test using all available covariance restrictions, as proposed by Jochmans (2020).

difference requests to compute the test with covariance restrictions entirely based on first differences, as proposed by Arellano and Bond (1991) and Yamagata (2008).

sdifference requests to compute the tests with restrictions on the covariances between first differences and seasonal differences, as proposed by Kripfganz, Demetrescu, and Hosseinkouchack (2024).

order(#) requests to exclude covariance restrictions that are unaffected by serial correlation of up to order #. By default, arbitrary higher-order serial correlation is allowed under the alternative hypothesis.
order(#) is equivalent to lagrange(2 #), unless option difference is also specified, in which case it is equivalent to lagrange(2 #-1).

lagrange(#_1 [#_2]) limits the range of lags of varlist to be used in the backward-looking covariance restrictions. By default, lagrange(2 .), all available lags from lag 2 onwards are used.
Alternative lower and upper bounds can be specified with #_1 and #_2, respectively. A missing value for #_2 requests all available lags to be used starting with #_1.
lagrange(#_1) with only one argument is equivalent to lagrange(#_1 #_1) with two identical arguments. If option difference is specified, the lag range refers to lags of first differences.

collapse or fullcollapse request to compute a collapsed version of the test, which involves sums of covariance restrictions, to limit the degrees of freedom,
as proposed by Kripfganz, Demetrescu, and Hosseinkouchack (2024). With fullcollapse, the degrees of freedom are reduced to 1.

noforward requests to ignore forward-looking covariance restrictions. This option is implied by option difference but otherwise seldom used.

nobackward requests to ignore backward-looking covariance restrictions. This option is seldom used.

noresiduals requests to skip checks whether varname is collinear with the regression residuals from the previously estimated model. This option is not recommended.
If applied to regression residuals, the command should instead be used as a postestimation command without explicitly specifying varname. Otherwise, the test results will be invalid.

Remarks

Remarks are presented under the following headings:

Portmanteau test

Dimensionality reduction

Tests based on first differences

Tests based on seasonal differences

Portmanteau test

Using Stata's time-series operators, the portmanteau test proposed by Jochmans (2020) evaluates the T(T-1)/2-1 covariance restrictions

Cov (L#.ue, D.e) = 0 for # = 2, 3, ... and # = -1

under the null hypothesis of no serial correlation in the idiosyncratic error component e of a linear model with error component structure ue = u + e, where u is the time-invariant group-specific error component.
Covariance restrictions with positive lag orders # = 2, 3, ... are referred to as backward looking, while the covariance restrictions with the negative lag order # = -1 are referred to as forward looking.

The portmanteau test requires at least 3 consecutive observations over time. It can be more powerful than traditional tests based on first differences, especially when T (the maximum number of observations per group) is very small.
However, because the number of covariance restrictions increases quadratically with T, it can quickly lose power even for moderately small T, especially when N (the number of groups) is only moderately large.

Dimensionality reduction

To avoid power problems, several strategies can be employed to limit the degrees of freedom of the test, as proposed by Kripfganz, Demetrescu, and Hosseinkouchack (2024).
Collapsing, implemented with option collapse, linearly combines the covariance restrictions into fewer ones by averaging them across time periods.
Full collapsing with option fullcollapse goes one step further by also averaging across lag orders #, creating a test with only 1 degree of freedom.

Another strategy is curtailing the maximum order of serial correlation that is detectable by the test. This is done with option order(#) or, equivalently, option lagrange(2 #).
This restricts the maximum lag order in the covariance restrictions. Collapsing and curtailing can be combined.

Tests based on first differences

Tests based on first differences

Cov (L#D.e, D.e) = 0 for # = 2, 3, ...

are immune to power distortions from large variances of the group-specific error component u because D.ue = D.e. However, they have low power against highly autocorrelated alternatives close to a random walk.
These tests require T >= 4.

The Arellano and Bond (1991) tests are collapsed versions (with 1 degree of freedom) of these first-difference tests with a single choice of the lag order #.
They can be obtained by combining the Syntax 1 options difference collapse lagrange(# #).
The Yamagata (2008) test is a joint test for all possible lag orders, obtained by jointly specifying difference collapse without a restriction of the lag range.

Note that a maximum serial correlation of order # in the idiosyncratic error component e in levels corresponds to a maximum serial correlation of order #-1 in the first-differenced errors D.e.
It is for this reason that option order(#) corresponds to lagrange(2 #-1) when specified with option difference.

Tests based on seasonal differences

Tests based on seasonal differences (also referred to as sandwich differences)

Cov (FS(#+1).e, D.e) = 0 for # = 2, 3, ...

are also unaffected by high variances of u because S.ue = S.e. They retain power even under a random-walk alternative, and they have been shown to often be more powerful than the portmanteau test,
partly due to their more conservative use of degrees of freedom. These tests have been proposed by Kripfganz, Demetrescu, and Hosseinkouchack (2024). They can be implemented with Syntax 1 option sdifference.
Option collapse is generally recommended as well. These tests also require T >= 4.

Example

Setup

. webuse abdata

Fixed-effects estimator

. xtreg n w k, fe vce(r)

Jochmans portmanteau test for no autocorrelation

. xtdpdserial, pm

Arellano-Bond tests for no autocorrelation in first differences of order 2, 3, or 4

. xtdpdserial, d c l(2)

. xtdpdserial, d c l(3)

. xtdpdserial, d c l(4)

Yamagata test for no autocorrelation in first differences of arbitrary order

. xtdpdserial, d c

Kripfganz-Demetrescu-Hosseinkouchack tests for no autocorrelation

. xtdpdserial, sd c o(2)

. xtdpdserial, sd c

All of the previous tests together

. xtdpdserial, s(pm dc(2 2) dc(3 3) dc(4 4) dc sdc(2) sdc)

Saved results

xtdpdserial with Syntax 1 saves the following in r():

Scalars

r(chi2) value of the test statistic

r(df) degrees of freedom

r(p) p-value

xtdpdserial with Syntax 2 saves the following in r():

Scalars

r(chi2_#) value of the #-th test statistic

r(df_#) degrees of freedom of the #-th test

r(p_#) p-value of the #-th test

Version history and updates

xtdpdserial is a community-contributed program. To determine the currently installed version, type

. which xtdpdserial, all

To update the xtdpdserial package to the latest version, type

. //www.kripfganz.de/stata/") replace"'

Author

Sebastian Kripfganz, University of Exeter, http://www.kripfganz.de

References

Arellano, M., and S. R. Bond. 1991.
Some tests of specification for panel data: Monte Carlo evidence and an application to employment equations.
Review of Economic Studies 58: 277-297.

Jochmans, K. 2020.
Testing for correlation in error-component models.
Journal of Applied Econometrics 35: 860-878.

Kripfganz, S., M. Demetrescu, and M. Hosseinkouchack. 2024.
Serial correlation testing in error component models with moderately small T.
Manuscript.

Yamagata, T. 2008.
A joint serial correlation test for linear panel data models.
Journal of Econometrics 146: 135-145.