the cross section dependence (cd) test

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

farnaz
Posts: 3
Joined: Wed Oct 15, 2008 12:41 pm

the cross section dependence (cd) test

Postby farnaz » Wed Oct 15, 2008 1:18 pm

how can I go through the cross section dependence (cd) test for panel data?

EViews Glenn
EViews Developer
Posts: 2642
Joined: Wed Oct 15, 2008 9:17 am

Re: the cross section dependence (cd) test

Postby EViews Glenn » Fri Oct 17, 2008 2:01 pm

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.

farnaz
Posts: 3
Joined: Wed Oct 15, 2008 12:41 pm

Re: the cross section dependence (cd) test

Postby farnaz » Sat Oct 18, 2008 4:40 pm

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

EViews Glenn
EViews Developer
Posts: 2642
Joined: Wed Oct 15, 2008 9:17 am

Re: the cross section dependence (cd) test

Postby EViews Glenn » Mon Oct 20, 2008 10:25 am

My earlier post shows how to perform both the Breusch-Pagan test and the Pesaran CD test.

eva
Posts: 4
Joined: Sat Jun 30, 2012 5:14 am

Re: the cross section dependence (cd) test

Postby eva » Sat Jun 30, 2012 5:51 am

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,

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12540
Joined: Tue Sep 16, 2008 5:38 pm

Re: the cross section dependence (cd) test

Postby EViews Gareth » Sat Jun 30, 2012 1:25 pm

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

eva
Posts: 4
Joined: Sat Jun 30, 2012 5:14 am

Re: the cross section dependence (cd) test

Postby eva » Sun Jul 01, 2012 7:08 am

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
Attachments
thesis-1.wf1
(109.04 KiB) Downloaded 481 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12540
Joined: Tue Sep 16, 2008 5:38 pm

Re: the cross section dependence (cd) test

Postby EViews Gareth » Sun Jul 01, 2012 12:31 pm

"New Zealand" has a space in it.
Follow us on Twitter @IHSEViews

wolly77
Posts: 32
Joined: Mon Oct 05, 2009 4:28 am

Re: the cross section dependence (cd) test

Postby wolly77 » Wed Jan 09, 2013 3:19 am

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.

EViews Glenn
EViews Developer
Posts: 2642
Joined: Wed Oct 15, 2008 9:17 am

Re: the cross section dependence (cd) test

Postby EViews Glenn » Wed Jan 09, 2013 12:14 pm

The null is independence.

codru
Posts: 13
Joined: Thu Jan 16, 2014 1:14 pm

Re: the cross section dependence (cd) test

Postby codru » Fri Jan 02, 2015 3:28 pm

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.

RheaMaria
Posts: 14
Joined: Fri Jan 09, 2015 5:35 pm

Re: the cross section dependence (cd) test

Postby RheaMaria » Wed Jan 21, 2015 3:58 am

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


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 9 guests