*! version 1.0.0 09jun2026

Title

xttestpanel csd -- Cross-sectional dependence tests for panel-data models

Syntax

xttestpanel csd [depvar indepvars] [if] [in]
[, model(fe|re|pool) graph]

Postestimation form (no varlist) reuses the last xtreg; see
the overview.

Description

xttestpanel csd tests the null of cross-sectional independence (errors
uncorrelated across panel units). It computes the pairwise residual correlations and
reports:

o Pesaran (2004) CD - the standard CD test based on the average
pairwise correlation; ~ N(0,1).

o Baltagi-Kao-Peng (2016) bias-corrected CD - a
serial-correlation-robust rescaling of CD, which corrects the size distortion that
serial correlation in the errors induces in the ordinary CD test.

o Breusch-Pagan (1980) LM - the sum of squared pairwise
correlations; ~ chi2(N(N-1)/2); appropriate when T is large relative to N.

o Pesaran scaled LM - the standardized LM for large panels; ~ N(0,1).

The mean absolute and mean signed pairwise correlations are also reported.

Note: the BKP statistic is implemented as a serial-correlation-robust correction
to CD using the panel's lag-1 residual autocorrelation; the exact finite-sample
constants of Baltagi, Kao & Peng (2016) may differ.

Options

model(fe|re|pool) working model; default fe.

graph heatmap of the residual cross-unit correlation matrix (uses
heatplot if installed; otherwise the matrix is listed).

Stored results

r(cd) Pesaran CD statistic

r(p_cd) its p-value

r(bkp) bias-corrected CD statistic

r(p_bkp) its p-value

r(bplm) Breusch-Pagan LM statistic

r(p_bplm) its p-value

r(abs_rho) mean absolute pairwise correlation

Examples

. xttestpanel csd ln_wage age tenure hours, graph

. xtreg ln_wage age tenure hours, fe

. xttestpanel csd

References

Pesaran, M.H. 2004/2015. Econometric Reviews 34: 1089-1117.

Baltagi, B.H., C. Kao, and B. Peng. 2016. Econometrics 4: 44.

Breusch, T.S., and A.R. Pagan. 1980. Review of Economic Studies 47: 239-253.

Author

Merwan Roudane - merwanroudane920@gmail.com -
github.com/merwanroudane