ms_condgrangertest function

Test for Conditional Granger Causality

Test for Conditional Granger Causality

Faster implementation of the vector version of lmtest::grangertest() with conditioning on the history of a third variable. The function assumes time series always have the same start date and periodicity, which is true for the data in this package.

ms_condgrangertest(x, y, z, order = 1, na.action = stats::na.omit, ...)

Arguments

  • x: response vector of observations.
  • y: explanatory vector of observations.
  • z: conditioning vector of observations
  • order: number of lags (in frames).
  • na.action: a function for eliminating NAs after aligning the series x and y.
  • ...: passed to lmtest::waldtest().

Returns

Anova object

Examples

data(wages, package = "lmtest") diff_wages <- diff(wages) # Granger tests lmtest::grangertest(diff_wages[, 'w'], diff_wages[, 'CPI'], order = 3) ms_grangertest1(diff_wages[, 'w'], diff_wages[, 'CPI'], order = 3) ms_grangertest2(diff_wages[, 'w'], diff_wages[, 'CPI'], order = 3) ms_condgrangertest(diff_wages[, 'w'], diff_wages[, 'CPI'], diff_wages[, 'u'], order = 3)

See Also

Other Granger Causality: autoplot.GrangerTime(), get_granger_interactions(), granger_test(), map_to_granger_test(), ms_grangertest1(), ms_grangertest2(), plot.GrangerInteraction(), plot_influence_diagram()

  • Maintainer: Tuomas Eerola
  • License: MIT + file LICENSE
  • Last published: 2023-06-09

Useful links