granger_causality¶
Defined in fynance.features.engineering
- granger_causality(x, y, lag=1)[source]
Granger-causality F-test: does
xhelp predicty?Compares a restricted autoregression of
yon its own lags with an unrestricted one that also includes lags ofx. A small p-value meansxGranger-causesy(adds predictive power beyondy’s past).- Parameters:
- x, ynp.ndarray
One-dimensional series of equal length.
- lagint, optional
Number of lags. Default 1.
- Returns:
- f_statfloat
F statistic of the restricted-vs-unrestricted comparison.
- p_valuefloat
Associated p-value (low →
xGranger-causesy).