I'm working on some code to determine granger causalities for a set of financial and public interest data. I've run into a bit of an issue with the syntax of the causality()
function within the VAR
package. Here's a sample of code and its potential result:
data = cbind(x, y, z, price, vol)
data_VAR = VAR(data, type="both", lag.max=30, ic="AIC")
causality(data_VAR, cause="x")$Granger
Granger causality H0: x do not Granger-cause y z price vol
data: VAR object data_VAR
F-Test = 1.6696, df1 = 120, df2 = 185, p-value = 0.0008476
This will give me results against the hypothesis that x does not granger cause changes in y
, z
, price
and vol
.
If I wanted to test x
and y
as variables that granger cause the others, what would the syntax be? According to the documentation I found online, it's possible to run this with multiple variables as the "causers" if you will, but based on the code for the function, I can't seem to figure out exactly how multiple variables could be read.
Thanks for any help in advance!
You need to put all the causes into a vector.
> library(vars)
> data(Canada)
> var.2c <- VAR(Canada, p = 2, type = "const")
> causality(var.2c, cause = c("e", "prod"))$Granger
Granger causality H0: e prod do not Granger-cause rw U
data: VAR object var.2c
F-Test = 6.8545, df1 = 8, df2 = 292, p-value = 2.919e-08