R/test_granger.R
pgrangertest.RdTest for Granger (non-)causality in panel data.
pgrangertest(
formula,
data,
test = c("Ztilde", "Zbar", "Wbar"),
order = 1L,
index = NULL
)a formula object to describe the direction of the
hypothesized Granger causation,
a pdata.frame or a data.frame,
a character to request the statistic to be returned,
either "Ztilde" (default),or "Zbar", alternatively, set to
"Wbar" for an intermediate statistic (see Details),
integer(s) giving the number of lags to include in the test's auxiliary regressions, the length of order must be either 1 (same lag order for all individuals) or equal to the number of individuals (to specify a lag order per individual),
only relevant if data is data.frame and not a
pdata.frame; if NULL, the first two columns of the
data.frame are assumed to be the index variables, for further
details see pdata.frame().
An object of class c("pgrangertest", "htest"). Besides
the usual elements of a htest object, it contains the data
frame indgranger which carries the Granger test statistics
per individual along the associated p-values, degrees of
freedom, and the specified lag order.
The panel Granger (non-)causality test is a combination of Granger tests (Granger 1969) performed per individual. The test is developed by Dumitrescu and Hurlin (2012) , a shorter exposition is given in Lopez and Weber (2017) .
The formula formula describes the direction of the (panel) Granger
causation where y ~ x means "x (panel) Granger causes y".
By setting argument test to either "Ztilde" (default) or
"Zbar", two different statistics can be requested. "Ztilde"
gives the standardised statistic recommended by Dumitrescu/Hurlin (2012) for
fixed T samples. If set to "Wbar", the intermediate Wbar statistic
(average of individual Granger chi-square statistics) is given which is used
to derive the other two.
The Zbar statistic is not suitable for unbalanced panels. For the Wbar statistic, no p-value is available.
The implementation uses lmtest::grangertest() from
package lmtest to perform the individual Granger tests.
Dumitrescu E, Hurlin C (2012). “Testing for Granger non-causality in heterogeneous panels.” Economic Modelling, 29(4), 1450 - 1460. ISSN 0264-9993, https://doi.org/10.1016/j.econmod.2012.02.014.
Granger CWJ (1969). “Investigating Causal Relations by Econometric Models and Cross-spectral Methods.” Econometrica, 37(3), 424–438. ISSN 00129682, 14680262.
Lopez L, Weber S (2017). “Testing for Granger causality in panel data.” Stata Journal, 17(4), 972-984. https://www.stata-journal.com/article.html?article=st0507.
lmtest::grangertest() for the original (non-panel)
Granger causality test in lmtest.
## not meaningful, just to demonstrate usage
## H0: 'value' does not Granger cause 'inv' for all invididuals
data("Grunfeld", package = "plm")
pgrangertest(inv ~ value, data = Grunfeld)
#>
#> Panel Granger (Non-)Causality Test (Dumitrescu/Hurlin (2012))
#>
#> data: inv ~ value
#> Ztilde = 3.2896, p-value = 0.001003
#> alternative hypothesis: Granger causality for at least one individual
#>
pgrangertest(inv ~ value, data = Grunfeld, order = 2L)
#>
#> Panel Granger (Non-)Causality Test (Dumitrescu/Hurlin (2012))
#>
#> data: inv ~ value
#> Ztilde = 1.6832, p-value = 0.09234
#> alternative hypothesis: Granger causality for at least one individual
#>
pgrangertest(inv ~ value, data = Grunfeld, order = 2L, test = "Zbar")
#>
#> Panel Granger (Non-)Causality Test (Dumitrescu/Hurlin (2012))
#>
#> data: inv ~ value
#> Zbar = 2.9657, p-value = 0.00302
#> alternative hypothesis: Granger causality for at least one individual
#>
# varying lag order (last individual lag order 3, others lag order 2)
(pgrt <- pgrangertest(inv ~ value, data = Grunfeld, order = c(rep(2L, 9), 3L)))
#>
#> Panel Granger (Non-)Causality Test (Dumitrescu/Hurlin (2012))
#>
#> data: inv ~ value
#> Ztilde = 1.8181, p-value = 0.06905
#> alternative hypothesis: Granger causality for at least one individual
#>
# chisq statistics per individual
pgrt$indgranger
#> firm Chisq p-value df lag
#> 1 1 1.8255237 0.401414049 2 2
#> 2 2 4.3694800 0.112506980 2 2
#> 3 3 0.7983334 0.670878856 2 2
#> 4 4 3.3069760 0.191381208 2 2
#> 5 5 11.0631807 0.003959687 2 2
#> 6 6 10.8343468 0.004439678 2 2
#> 7 7 1.3410752 0.511433558 2 2
#> 8 8 0.2900525 0.864999607 2 2
#> 9 9 4.4068769 0.110422824 2 2
#> 10 10 4.0173070 0.259601337 3 3