4

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?

Helix123
  • 3,502
  • 2
  • 16
  • 36
Miranda
  • 148
  • 13

1 Answers1

0

This is just a suggestion, so it may or may not help. Although the function only allows for 2 variables, you might be able to explore exactly what the function is doing to discover the "formula" and adapt/modify it to your needs using edit(pgrangertest). Analogously, you can overcome errors about colinearity for the function grangertest by manually specifying the type of test you want to use and mimicking what the actual function is doing (see my own question and answer here). Perhaps that would allow you to specify all the variables you want? Also, the other question here might be helpful too (though it's about regular multivariate granger)

Alternatively, try emailing the creator of the package. It's a longshot, but it could also be super helpful and they might be able to actually solve your issue.

thehand0
  • 1,123
  • 4
  • 14