Page 1 of 1

the cross section dependence (cd) test

Posted: Wed Oct 15, 2008 1:18 pm
by farnaz
how can I go through the cross section dependence (cd) test for panel data?

Re: the cross section dependence (cd) test

Posted: Fri Oct 17, 2008 2:01 pm
by EViews Glenn
how can I go through the cross section dependence (cd) test for panel data?
The question is a bit vague, but I'm assuming that you mean the Pesaran (2004) CD test. There are two variants, an ordered (p) and non-ordered one. I'm only going to be discussing the non-ordered one here, but the extension to the ordered is pretty straightforward. A related test statistic is the original Breusch-Pagan CD statistic.

None of these statistics are particularly difficult to compute in EViews, the only real issue is that EViews 6 does not compute correlations across panel units as an in-built operation. What you can do is to take the residuals from your panel equation and unstack them in a new workfile page, then compute the correlations amongst the unstacked series.

The following code snippet shows how to do this operation in a couple of steps, and then performs the actual computation of the BP and Pesaran statistics. The statistics and p-values are saved in scalars, but you could put them in tables instead if desired.

I've done a bit of quick validation of the Pesaran results, but haven't had a chance to check the BP results against anything. The usual disclaimers about using at your own risk apply.

The code below assumes that the original data are in a workfile page called panel. When completed, the results will be in a new page called stacked. To change back to the original page, issue a "pageselect panel" command...Note also that this code assumes that you are using EViews 6. You can compute the unbalanced pairwise correlations in EViews 5, but it's a lot more work.

I should point out that the workfile that I am using as an example below is structured using the cross-section ID series ID01 and period ID series ID02.

Code: Select all

' select the original panel page pageselect panel ' estimate the original equation with fixed effects equation eq01.ls(cx=f) impor rd frd c ' make the residuals in stacked form eq01.makeresid presid ' unstack into a new page page pageunstack(page=unstack) id01 id02 @ presid ' compute the uncentered correlation and number of observations of the unstacked residuals by cross-section do presid.cov(out=a) ucor obs ' get number of groups scalar n = @columns(acorr) ' get vech of observations vector t = @vech(aobs) ' adjust correlation matrix to zero out diagonals acorr = acorr - @identity(n) ' get the vech of the correlation matrix and the squared vech vector vcor = @vech(acorr) vector vcor2 = @epow(vcor, 2) ' compute the scaled Breusch-Pagan LM stat (generalized slightly for unbalanced) scalar cdlm = @inner(vcor2, t) - n*(n-1)/2 cdlm = cdlm / @sqrt(n * (n-1)) scalar cdlmpval = 2*@cnorm(-@abs(cdlm)) ' compute the Pesaran CD test vector sqrtt = @sqrt(t) scalar cd= @inner(vcor, sqrtt) cd = cd * @sqrt(2 / (n * (n-1))) scalar cdpval = 2*@cnorm(-@abs(cd))
Hope that this answers your question.

Re: the cross section dependence (cd) test

Posted: Sat Oct 18, 2008 4:40 pm
by farnaz
hi
Thank you for your reply.
Actualy I meant the cross section dependence (cd) test from Pesaran (2004). could it be poosible to give me step by step gudance for that in eviews please. I am trying to perform this test through 6 banks and between my defined dependent and on one of my high correlated independent variable.
Thank you in advance
Kindregards
Farnaz

Re: the cross section dependence (cd) test

Posted: Mon Oct 20, 2008 10:25 am
by EViews Glenn
My earlier post shows how to perform both the Breusch-Pagan test and the Pesaran CD test.

Re: the cross section dependence (cd) test

Posted: Sat Jun 30, 2012 5:51 am
by eva
hi,

I've tried to do this test (adapted to my workfile) and it always gives me the same error message when I try to unstack the residuals:
'series sepecified for unstacking does not have valid values for forming series name'
What do I do wrong?

thank you,

Re: the cross section dependence (cd) test

Posted: Sat Jun 30, 2012 1:25 pm
by EViews Gareth
The series you are using for stacking does not contain entries that are valid as series names. The values cannot start with a number, not have spaces in them, and not contain certain special characters.

Re: the cross section dependence (cd) test

Posted: Sun Jul 01, 2012 7:08 am
by eva
hi,

Thank you for your response.
I don't think any of this is the case. I use country names for unstacking.
I have attached the workfile I'm using. id01 = country and id02 = dateid in my case.

thank you in advance

Re: the cross section dependence (cd) test

Posted: Sun Jul 01, 2012 12:31 pm
by EViews Gareth
"New Zealand" has a space in it.

Re: the cross section dependence (cd) test

Posted: Wed Jan 09, 2013 3:19 am
by wolly77
Hi guys,

a simple question. What is the null hypothesis in this test constructed in Eviews? A p-value = 0.35 implies that the cross sections are dependent? Thank you.

Re: the cross section dependence (cd) test

Posted: Wed Jan 09, 2013 12:14 pm
by EViews Glenn
The null is independence.

Re: the cross section dependence (cd) test

Posted: Fri Jan 02, 2015 3:28 pm
by codru
Hello,
I want to test for cross-sectional independence. I am running a multi-equation model using the system object and SURE as an estimator. My panel data is unabalanced. I work with data for several countries, and for each country I have 2 equations and at least 20 annual observations. Is there any add-in for a CD test for system objects? If not what is the best way to proceed?
thank you, c.

Re: the cross section dependence (cd) test

Posted: Wed Jan 21, 2015 3:58 am
by RheaMaria
Hi I've been trying to follow your instructions for a cross section dependence test and the Breusch Pagan test. However when I try to get the number of groups using the code

scalar n = @columns(acorr)

I get the error message saying 'acorr is not defined'. Could you please advise me how to sort this out so I can compute the test statistics?

Also, is the add-in for cross sectional dependence valid to use for panel data?

Thanks
Rhea