the cross section dependence (cd) test
Moderators: EViews Gareth, EViews Moderator
the cross section dependence (cd) test
how can I go through the cross section dependence (cd) test for panel data?

 EViews Developer
 Posts: 2642
 Joined: Wed Oct 15, 2008 9:17 am
Re: the cross section dependence (cd) test
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 nonordered one. I'm only going to be discussing the nonordered one here, but the extension to the ordered is pretty straightforward. A related test statistic is the original BreuschPagan 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 inbuilt 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 pvalues 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 crosssection 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 crosssection
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 BreuschPagan LM stat (generalized slightly for unbalanced)
scalar cdlm = @inner(vcor2, t)  n*(n1)/2
cdlm = cdlm / @sqrt(n * (n1))
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 * (n1)))
scalar cdpval = 2*@cnorm(@abs(cd))
Hope that this answers your question.
Re: the cross section dependence (cd) test
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
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

 EViews Developer
 Posts: 2642
 Joined: Wed Oct 15, 2008 9:17 am
Re: the cross section dependence (cd) test
My earlier post shows how to perform both the BreuschPagan test and the Pesaran CD test.
Re: the cross section dependence (cd) test
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,
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,

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12540
 Joined: Tue Sep 16, 2008 5:38 pm
Re: the cross section dependence (cd) test
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.
Follow us on Twitter @IHSEViews
Re: the cross section dependence (cd) test
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
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
 Attachments

 thesis1.wf1
 (109.04 KiB) Downloaded 481 times

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12540
 Joined: Tue Sep 16, 2008 5:38 pm
Re: the cross section dependence (cd) test
"New Zealand" has a space in it.
Follow us on Twitter @IHSEViews
Re: the cross section dependence (cd) test
Hi guys,
a simple question. What is the null hypothesis in this test constructed in Eviews? A pvalue = 0.35 implies that the cross sections are dependent? Thank you.
a simple question. What is the null hypothesis in this test constructed in Eviews? A pvalue = 0.35 implies that the cross sections are dependent? Thank you.

 EViews Developer
 Posts: 2642
 Joined: Wed Oct 15, 2008 9:17 am
Re: the cross section dependence (cd) test
The null is independence.
Re: the cross section dependence (cd) test
Hello,
I want to test for crosssectional independence. I am running a multiequation 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 addin for a CD test for system objects? If not what is the best way to proceed?
thank you, c.
I want to test for crosssectional independence. I am running a multiequation 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 addin 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
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 addin for cross sectional dependence valid to use for panel data?
Thanks
Rhea
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 addin for cross sectional dependence valid to use for panel data?
Thanks
Rhea
Who is online
Users browsing this forum: No registered users and 8 guests