Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

granger_test

Granger causality test.


Description

Granger test of predictive causality (between two time-series variables) using the lmtest::grangertest() function.

Usage

granger_test(formula, data, lags = 1:5, test.reverse = FALSE)

Arguments

formula

Model formula like y ~ x.

data

Data frame.

lags

Time lags. Default is 1:5.

test.reverse

Whether to test reverse causality. Default is FALSE.

Details

The Granger causality test can examine whether the lagged values of a predictor have any incremental role in predicting an outcome if controlling for the lagged values of the outcome itself. It compares the two models by using an F test.

Value

No return value.

See Also

Examples

granger_test(chicken ~ egg, data=lmtest::ChickEgg)
granger_test(chicken ~ egg, data=lmtest::ChickEgg, lags=1:10, test.reverse=TRUE)

bruceR

Broadly Useful Convenient and Efficient R Functions

v0.6.2
GPL-3
Authors
Han-Wu-Shuang Bao [aut, cre]
Initial release
2021-04-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.