Granger test of predictive causality (between multivariate time series)
based on vector autoregression (VAR
) model.
Its output resembles the output of the vargranger
command in Stata (but here using an F test).
granger_causality(
varmodel,
var.y = NULL,
var.x = NULL,
test = c("F", "Chisq"),
file = NULL,
check.dropped = FALSE
)
VAR model fitted using the vars::VAR()
function.
[optional] Default is 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"
).
F test and/or Wald c("F", "Chisq")
.
File name of MS Word (.doc
).
Check dropped variables. Default is FALSE
.
A data frame of results.
The Granger causality test (based on VAR model) examines whether the lagged values of a predictor (or predictors) have any incremental role in predicting an outcome if controlling for the lagged values of the outcome itself.
# NOT RUN {
# "vars" package should be installed and loaded.
library(vars)
data(Canada)
VARselect(Canada)
vm=VAR(Canada, p=3)
model_summary(vm)
granger_causality(vm)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab