[R] Granger-causality test using vars package

Pfaff, Bernhard Dr. Bernhard_Pfaff at fra.invesco.com
Mon Jan 23 10:12:04 CET 2017

Dear T.Riedle,

you cannot assign *all* variables as a cause at once. Incidentally, in your example, you missed a 'data(Canada)'.
Having said this, you can loop over the variables names and extract the statistic/p-values. These are contained as named list elements 'statistic' and 'p.value' in the returned list object 'Granger' which is of informal class 'htest'.

Best wishes,

-----Ursprüngliche Nachricht-----
Von: R-help [mailto:r-help-bounces at r-project.org] Im Auftrag von T.Riedle
Gesendet: Sonntag, 22. Januar 2017 14:11
An: R-help at r-project.org
Betreff: [EXT] [R] Granger-causality test using vars package

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


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]]

R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Confidentiality Note: The information contained in this ...{{dropped:10}}

More information about the R-help mailing list