help for xtcsd

Test for cross-sectional dependence in panel data models

xtcsd , [pesaran friedman frees abs show]

xtcsd is a post-estimation command for use with cross-section time-series data following fe or re models. You must tsset your data before using xtcsd; see help tsset.


xtcsd tests for cross-sectional dependence in Fixed Effects of Random Effects panel data models. One of method's options pesaran friedman or frees must be specified.

A standard assumption in panel data models (xtreg) is that the error terms are independent across cross-sections. This assumption is employed for identification purposes rather than descriptive accuracy. In the context of large T and small N, the LM test statistic proposed by Breusch and Pagan (1980) can be used to test for cross-sectional dependence (see help xttest2). However, in most cases, cross-sectional time-series data sets come in the form of small T and large N. In this case the Breusch-Pagan test is not valid.

xtcsd test the hypothesis of cross-sectional independence in panel data models with small T and large N by implementing two semi-parametric tests proposed by Friedman (1937) and Frees (1995,2004), as well as the parametric testing procedure proposed by Pesaran (2004). xtcsd with option pesaran can handle balanced as well as unbalanced panels.


pesaran test for cross-sectional dependence following the methods shown in Pesaran (2004). Pesaran's statistic follows a standard normal distribution and it is able to handle balanced and unbalanced panels.

friedman test for cross-sectional dependence using Friedman's chi-square distributed statistic. For unbalanced panels Friedman's test uses only the observations available for all cross-sectional units.

frees test for cross-sectional dependence using Frees' Q distribution (T-asymptotically distributed). For unbalanced panels Frees' test uses only the observations available for all cross-sectional units.

abs computes the average absolute value of the off-diagonal elements of the cross-sectional correlation matrix of residuals.

show shows the cross-sectional correlation matrix of residuals.


The small sample comparative performance of these tests under various model specifications is examined in Sarafidis and De Hoyos (2006).


. use "http://www.econ.cam.ac.uk/phd/red29/xtcsd_baltagi.dta"

. xtreg lngsp lnpcap lnpc lnemp unemp, fe

. xtcsd, frees

. xtcsd, pesaran show

. xtreg lngsp lnpcap lnpc lnemp unemp, re

. xtcsd, friedman show abs


Frees, E.W. (1995) `Assessing cross-sectional correlations in panel data', Journal of Econometrics, 64, 393-414.

Frees, E.W. (2004) `Longitudinal and panel data: analysis and applications in the social sciences', Cambridge University Press.

Friedman, M. (1937) `The use of ranks to avoid the assumption of normality implicit in the analysis of variance', Journal of the American Statistical Association, 32, 675-701.

Pesaran, M.H. (2004) `General diagnostic tests for cross section dependence in panels', Cambridge Working Papers in Economics, 0435, University of Cambridge.

Sarafidis, V. and De Hoyos, R.E. (2006) `On testing for cross sectional dependence in panel data models', mimeo, University of Cambridge.


Our code benefited greatly from Christopher Baum's xttest2. Thanks to David Drukker for very useful suggestions.


Rafael E. De Hoyos, Faculty of Economics, University of Cambridge. red29@cam.ac > .uk

Vasilis Sarafidis, Discipline of Econometrics and Business Statistics, Universi > ty of Sydney. V.Sarafidis@econ.usyd.edu.au

Also see

Manual: [U] 23 Estimation and post-estimation commands [XT] xtreg

Online: help for xttest2 (if installed), bpagan (if installed), ivreg2 (if inst > alled)