Applying Granger Causality Tests in Rolling Windows
Summary
The document asks how to examine whether changes in the PCE index help explain daily stock return changes over time. The proposed approach is rolling Granger causality: repeatedly apply a two-variable Granger causality test to a moving window of observations, then compare the results across windows. The question specifically concerns implementing this procedure in Python and whether the concept is appropriate.
The answer points to a time-series testing function and describes iterating over an array to extract each window-sized subset for analysis. This gives a basic implementation outline, but it does not provide a complete runnable solution, explain how to interpret changing test results, or address model choices such as lag length and window size. Granger causality tests assess predictive relationships conditional on their model specification; the discussion does not establish that PCE causes stock returns in an economic sense or provide empirical findings.
Key ideas
- A rolling Granger causality analysis repeats a two-variable test over successive data windows.
- The example compares daily stock return changes with daily PCE index changes.
- A moving array slice can supply observations for each repeated test.
- Interpretation depends on model choices, and the discussion reports no empirical results.
Tags
Full text
# How to implement rolling granger causality
# How to implement rolling granger causality
I am investigating two time series where the first is the daily closing stock price changes and the other is the daily changes in the PCE index.
I want to investigate how much the PCE index explains the returns by using a rolling granger causality like this one:
I can't find a way to get a rolling granger causality in python. Would someone mind helping me out or do I need to rethink the concept?
## Answer by IDontKnowCode (score 1)
https://quant.stackexchange.com/a/71446
I believe this may be of help: https://www.statsmodels.org/dev/generated/statsmodels.tsa.stattools.grangercausalitytests.html
This allows you to run a granger causality of two variables. As for rolling, use a rolling index loop over an array:
```
for i in range(window, max_idx):
sub_view = my_array[i-window:i+1,:]
# use function here
```Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.