r - Granger causality ordering variable -


i trying compute granger causality var using vars package. know order of variable important in var compute irf, here have different result granger causality. here reproducible example:

test <- structure(c(324l, 444l, 456l, 451l, 484l, 535l, 625l, 622l, 532l,  623l, 619l, 642l, 550l, 643l, 629l, 709l, 781l, 792l, 858l, 979l,  974l, 1039l, 1062l, 1167l, 1345l, 1600l, 1789l, 1912l, 1965l,  2086l, 2350l, 2507l, 2186l, 2224l, 2235l, 2435l, 1923l, 2035l,  2253l, 2365l, 2214l, 2554l, 2714l, 2773l, 2777l, 2897l, 3060l,  3053l, 2426l, 2714l, 2953l, 2925l, 3233l, 3494l, 3724l, 4137l,  4147l, 4275l, 4726l, 4910l, 114l, 131l, 137l, 136l, 157l, 174l,  207l, 165l, 168l, 189l, 176l, 187l, 138l, 153l, 176l, 183l, 196l,  229l, 263l, 281l, 263l, 310l, 310l, 313l, 283l, 291l, 324l, 367l,  410l, 423l, 470l, 452l, 465l, 529l, 559l, 602l, 657l, 729l, 721l,  747l, 781l, 815l, 861l, 863l, 817l, 839l, 875l, 855l, 825l, 947l,  1038l, 1086l, 1190l, 1235l, 1347l, 1435l, 1495l, 1482l, 1645l,  1769l, 61l, 84l, 106l, 100l, 123l, 112l, 131l, 151l, 105l, 121l,  127l, 167l, 166l, 164l, 153l, 212l, 228l, 236l, 264l, 316l, 223l,  245l, 267l, 301l, 288l, 276l, 284l, 351l, 378l, 395l, 460l, 530l,  479l, 483l, 472l, 528l, 399l, 456l, 477l, 480l, 500l, 526l, 550l,  636l, 513l, 567l, 607l, 595l, 565l, 593l, 632l, 614l, 719l, 747l,  874l, 1011l, 905l, 857l, 947l, 956l), .dim = c(60l, 3l), .dimnames = list(     null, c("h", "m", "s")), index = structure(c(1996, 1996.08333333333,  1996.16666666667, 1996.25, 1996.33333333333, 1996.41666666667,  1996.5, 1996.58333333333, 1996.66666666667, 1996.75, 1996.83333333333,  1996.91666666667, 1997, 1997.08333333333, 1997.16666666667, 1997.25,  1997.33333333333, 1997.41666666667, 1997.5, 1997.58333333333,  1997.66666666667, 1997.75, 1997.83333333333, 1997.91666666667,  1998, 1998.08333333333, 1998.16666666667, 1998.25, 1998.33333333333,  1998.41666666667, 1998.5, 1998.58333333333, 1998.66666666667,  1998.75, 1998.83333333333, 1998.91666666667, 1999, 1999.08333333333,  1999.16666666667, 1999.25, 1999.33333333333, 1999.41666666667,  1999.5, 1999.58333333333, 1999.66666666667, 1999.75, 1999.83333333333,  1999.91666666667, 2000, 2000.08333333333, 2000.16666666667, 2000.25,  2000.33333333333, 2000.41666666667, 2000.5, 2000.58333333333,  2000.66666666667, 2000.75, 2000.83333333333, 2000.91666666667 ), class = "yearmon"), class = "zoo") 

i follow toda-yamamoto procedure following code:

varselect(test, lag.max=14) var<-var(test, p=2, season=12) serial.test(var) var<-var(test, p=3, season=12)  atester<-c(1) #test causality of industry on others variables wald.test(b=coef(var$varresult[[1]]), sigma=vcov(var$varresult[[1]]), terms=atester) #test causality of finance on others variables wald.test(b=coef(var$varresult[[1]]), sigma=vcov(var$varresult[[1]]), terms=atester+1) #test causality of consulting on others variables wald.test(b=coef(var$varresult[[1]]), sigma=vcov(var$varresult[[1]]), terms=atester+2) 

my result different if change order of variable in var , don't understand why.

edit : apparently made huge mistake , had change in code :

 wald.test(b=coef(var$varresult[[1]]), sigma=vcov(var$varresult[[1]]), terms=atester)     #test causality of finance on others variables     wald.test(b=coef(var$varresult[[**2**]]), sigma=vcov(var$varresult[[**2**]]), terms=atester+1)     #test causality of consulting on others variables     wald.test(b=coef(var$varresult[[**3**]]), sigma=vcov(var$varresult[[**3**]]), terms=atester+2) 

it looks me specify terms= argument wrong. here follows brief explanation examples aod::wald.test() , vars::causality():

if want test "m,s not granger-cause h" then

wald.test(b=coef(var$varresult[[1]]), sigma=vcov(var$varresult[[1]]), terms=c(2,3,5,6,8,9)) 

which obtain directly vars-package by:

causality(var,c("m","s")) 

if want test "s not granger-cause h,m" along:

wald.test(     b=reduce(rbind,coef(var))[c(1:9,22:30),1],      sigma=vcov(var)[c(2:10,23:31),c(2:10,23:31)],      terms=c(3,6,9,12,15,18) ) 

where requieres little more work because of difference in variable ordering. in vars directly specify:

causality(var,"s") 

at last if want bivariate granger causality tests, use function in msbvar:

library(msbvar) granger.test(test, p=3)  

hope helps.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -