granger_causality: Granger causality test (multivariate).

View source: R/bruceR-stats_5_advance.R

granger_causalityR Documentation

Granger causality test (multivariate).

Description

Granger test of predictive causality (between multivariate time series) based on vector autoregression model using vars::VAR(). Its output resembles the output of the vargranger command in Stata (but here using an F test).

Usage

granger_causality(
  varmodel,
  var.y = NULL,
  var.x = NULL,
  test = c("F", "Chisq"),
  file = NULL,
  check.dropped = FALSE
)

Arguments

varmodel

VAR model fitted using vars::VAR().

var.y, var.x

[Optional] Defaults to NULL (all variables). If specified, then perform tests for specific variables. Values can be a single variable (e.g., "X"), a vector of variables (e.g., c("X1", "X2")), or a string containing regular expression (e.g., "X1|X2").

test

F test and/or Wald \chi^2 test. Defaults to both: c("F", "Chisq").

file

File name of MS Word (".doc").

check.dropped

Check dropped variables. Defaults to FALSE.

Details

Granger causality test (based on VAR model) examines whether the lagged values of a predictor (or predictors) help to predict an outcome when controlling for the lagged values of the outcome itself. Granger causality does not represent a true causal effect.

Value

A data frame of results.

See Also

ccf_plot()

granger_test()

Examples

# R package "vars" should be installed
library(vars)
data(Canada)
VARselect(Canada)
vm = VAR(Canada, p=3)
model_summary(vm)
granger_causality(vm)


bruceR documentation built on Aug. 21, 2025, 5:38 p.m.