[R] Granger-causality test using vars package

T.Riedle tr206 at kent.ac.uk
Sun Jan 22 14:11:19 CET 2017


Dear R-users,

I am trying to compute the test statistics for Granger-causality for a VAR(p) model using the "vars" package. I simply used the example proposed by the vars vignette and added the code for the Granger-causality. The code looks as follows



library(vars)

Canada<-Canada[, c("prod", "e", "U", "rw")]
p1ct<-VAR(Canada, p=1, type = "both")

causality(p1ct, cause = c("prod","e","U","rw"))



Unfortunately I get the error

Error in `[<-`(`*tmp*`, i, w[i], value = 1) : subscript out of bounds



Does any body know what is wrong with the code? I would like to create a matrix containing the F-values and the corresponding significance. How can I do that?

	[[alternative HTML version deleted]]



More information about the R-help mailing list