How to do granger causality test after running a panel vector autoregression in R (using the panelvar package)?
In order to run the panel VAR, one could do the following:
library(plm)
library(panelvar)
set.seed(12345)
x = rnorm(240)
z = x + rnorm(240)
y = rep(rnorm(15), each=16) + 2*x + 3*z + rnorm(240)
country = rep(c("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O"), each=16 )
year = rep(seq(1995, 2010), 15)
panel = cbind.data.frame(country,year,x,z,y)
model <- pvargmm(dependent_vars = c("y", "x", "z"),
lags = 1,
transformation = "fod",
data = panel,
panel_identifier=c("country", "year"),
steps = c("twostep"),
system_instruments = FALSE,
max_instr_dependent_vars = 99,
max_instr_predet_vars = 99,
min_instr_dependent_vars = 2L,
min_instr_predet_vars = 1L,
collapse = TRUE
)
My question then is how to perform the granger causality test (panelvar does not offer this as a function).
It seems that one would need to use the function pgrangertest
from the plm
package. However, I am not sure what the "formula" would be, since a pVAR model is different from a simple linear model. Also, should the "order" be the number of lags found to be best after running our pVAR with several lag options and then selecting the one that provided the best model fit (based on BIC, AIC, etc provided by the Andrews_Lu_MMSC function)?
pgrangertest(inv ~ value, data = Grunfeld, order = 2L)
In other words, I need to replace "inv ~ value" for something else, and I am not clear on how to do that.
Given that I am interested in the interrelationship between y, x, and z, should I run the pgrangertest six times? Would the following make sense?
pgrangertest(y ~ x, data = panel, order = 2L)
pgrangertest(y ~ z, data = panel, order = 2L)
pgrangertest(x ~ z, data = panel, order = 2L)
pgrangertest(x ~ y, data = panel, order = 2L)
pgrangertest(z ~ x, data = panel, order = 2L)
pgrangertest(z ~ y, data = panel, order = 2L)
I know that the pgrangertest
only allows for two variables at a time, but should not I control for the third one as well?