e1983 wrote:Hi. I was curious if someone could point me to an example or discussion regarding the granger causality tests in panel data?
OPEN DATA "D:\Electro New\panel rearragment 2012-7-8.xlsx"
CALENDAR(M) 2003:2
DATA(FORMAT=XLSX,ORG=COLUMNS,right=100) 2003:02 2012:04
pform x
# individual_1 to individual_96
calendar(m,panel=2012:3) 2003:2
all 96//2012:3
pform(repeat) p_new
# p
pform(repeat) n_new
# n
*Panel causallity analysis
dec vec[string] individual(2)
input individual(2)
individual_1
individual_2
* Number of lags
com p=3
* Joint test.
*
sweep(group=%indiv(t),var=hetero)
# x
# constant x{1 to p} p{1 to p} n{1 to p}
compute loglunr=%logl,nregunr=%nregsystem
sweep(group=%indiv(t),var=hetero)
# x
# constant x{1 to p}
compute loglres=%logl,nregres=%nregsystem
cdf(title="Heterogeneous Panel Causality Test") chisqr 2.0*(loglunr-loglres) nregunr-nregres
compute jointtest=%cdstat,jointsignif=%signif
*
* Individual causality tests. The individual log likelihood ratios sum
* to the joint test.
*
report(action=define,title="Panel Causality Test")
do i=1,96
linreg(noprint,smpl=%indiv(t)==i) x
# constant x{1 to p} p{1 to p} n{1 to p}
exclude(noprint)
# p{1 to p} n{1 to p}
compute lr=log((1+p*%cdstat/%ndf))*%nobs
report(row=new,atcol=1) individual_1 lr %chisqr(lr,p)
end do i
report(row=new,atcol=1) "OVERALL" jointtest jointsignif
report(atcol=2,tocol=2,action=format,picture="*.###")
report(atcol=3,tocol=3,action=format,picture="*.#####")
report(action=show)
pregress(method=random) commodity / resids
# constant p n
lin(define=spread) commodity / resids
# constant p n
Users browsing this forum: No registered users and 1 guest