Granger Causality Operator
operator.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Notes
else: warn(msg)
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section See Also
else: warn(msg)
GrangerCausality
GrangerCausality (x_vars:Union[list,pandas.core.series.Series,numpy.ndarr ay,Iterable[numbers.Number],Any,List[int],List[Union[bo ol,numpy.bool_,Literal[0],Literal[1]]],pandas.core.inde xes.base.Index,NoneType]=None, y_vars:Union[list,pandas .core.series.Series,numpy.ndarray,Iterable[numbers.Numb er],Any,List[int],List[Union[bool,numpy.bool_,Literal[0 ],Literal[1]]],pandas.core.indexes.base.Index,NoneType] =None, shift:Optional[int]=10, test:Optional[str]='ssr_chi2test', lag_order:Optional[int]=1, max_lag:Optional[tuple]=(1,), n_jobs:Optional[int]=-1)
Computes Granger Causality Check Granger Causality of all possible combinations of the Time series.
The rows are the response variable, columns are predictors. The values in the table are the P-Values. P-Values lesser than the significance level (0.05), implies the Null Hypothesis that the coefficients of the corresponding past values is zero, that is, the X does not cause Y can be rejected.
Type | Default | Details | |
---|---|---|---|
x_vars | Union | None | A subset of response variable (features) to compute granger’s causality test with. If not provided, defaults to df.index.values i.e. all rows in df . |
y_vars | Union | None | A subset of response variable (features) to compute granger’s causality test with. If not provided, defaults to df.index.values i.e. all rows in df . |
shift | Optional | 10 | number to shift df ’s values by |
test | Optional | ssr_chi2test | the kind of statistical test to use |
lag_order | Optional | 1 | how long to lag |
max_lag | Optional | (1,) | if None coerced to (1, ) |
n_jobs | Optional | -1 | number of cpu threads to use during calculation |
Returns | pd.DataFrame | Pandas DataFrame with shape (len(x_vars), len(y_vars)) containing theminimum p-value from Granger’s Causation Tests |