how to modify the CD test code

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

smseco
Posts: 5
Joined: Sat Sep 10, 2011 11:26 pm

how to modify the CD test code

Postby smseco » Mon Sep 12, 2011 8:18 am

how i can modify the following code for perform the CD test for a panel data variable named "g" in eviews7?

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))[/color]


i changed the " impor rd frd c" to "g c g(-1) g(-2) @trend " and the "id01 id02" to "crossid datied" is it true?

Code: Select all

' select the original panel page pageselect panel ' estimate the original equation with fixed effects equation eq01.ls(cx=f) g c g(-1) g(-2) @trend ' make the residuals in stacked form eq01.makeresid presid ' unstack into a new page page pageunstack(page=unstack) crossid datied @ 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))

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

Re: how to modify the CD test code

Postby EViews Gareth » Mon Sep 12, 2011 8:22 am

Did it work?

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

Re: how to modify the CD test code

Postby EViews Glenn » Mon Sep 12, 2011 9:43 am

I"m not quite clear as to what you are trying to do. Are you trying to test on G instead of the residuals of an equation?

smseco
Posts: 5
Joined: Sat Sep 10, 2011 11:26 pm

Re: how to modify the CD test code

Postby smseco » Tue Sep 13, 2011 3:14 am

Thanks for reply.
yes, it works. But i'm not sure about the validity of results.

pesaran (2004, pp. 21-23) intruduced a procedure to performing CD for "percapita output":
"We computed CD statistics both for countries within a given region, as well as
across countries from different regions, over the periods 1971-2000 and 1981-
2000. For each country, i, we first computed OLS residuals from regressions of
its log per capita output (yit) on an intercept, a linear trend, yi,t−1 and yi,t−2.
Using these residuals we then computed the various CD statistics summarized
in Table A."
I need to perform a similar "cross section dependence test" for a variable named G.

smseco
Posts: 5
Joined: Sat Sep 10, 2011 11:26 pm

Re: how to modify the CD test code

Postby smseco » Tue Sep 13, 2011 7:17 am

and here is the panel workfile.
Attachments
lng.wf1
(72.69 KiB) Downloaded 549 times

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

Re: how to modify the CD test code

Postby EViews Glenn » Tue Sep 13, 2011 10:09 am

Looks about right. The way to think about it is that the first regression that we have can be replaced by whatever you wnat. Get the residuals and then the remaining part does the actual test.

katrin
Posts: 16
Joined: Sat Jun 08, 2013 6:41 am

Re: how to modify the CD test code

Postby katrin » Tue Jun 18, 2013 3:04 am

Hi,
is there a possibility to perfom the pesaran cd test for pooled data? I've tried and failed until now. Can I perhaps modify the above code, or do I need something different?

I've got 15 cross-section identifiers and about 50 periods.
Many thanks

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

Re: how to modify the CD test code

Postby EViews Glenn » Tue Jun 18, 2013 10:33 am

Put your series in a group (say PRESID) and then run only the bottom part of the program starting at the line

Code: Select all

' compute the uncentered correlation and number of observations of the unstacked residuals by cross-section do presid.cov(out=a) ucor obs

katrin
Posts: 16
Joined: Sat Jun 08, 2013 6:41 am

Re: how to modify the CD test code

Postby katrin » Wed Jun 19, 2013 10:20 pm

Thanks for your reply.
It works :)


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 2 guests