Granger Causality Test in R
ฝัง
- เผยแพร่เมื่อ 7 ก.พ. 2025
- Granger-Causality Test in R
The Granger Causality test is used to examine if one time series may be used to forecast another
Null Hypothesis (H0): Time series x does not Granger-cause time series y
Alternative Hypothesis (HA): Time series x Granger-causes time series y
library(lmtest)
#load ChickEgg dataset
data(ChickEgg)
?ChickEgg
View(ChickEgg)
#perform Granger-Causality test
grangertest(chicken ~ egg, order = 3, data = ChickEgg)
#knowing the number of eggs is useful for predicting the future number of chickens.
#perform Granger-Causality test in reverse
grangertest(egg ~ chicken, order = 3, data = ChickEgg)
Beautifully explained. Thank you very much!
Thanks
So is negative degrees of freedom bad? Because it seems weird, but I see you also get it. I know it's because the two columns in the dataframe or two time-series are the same length. Even if you do order = 1, you get -1 degrees of freedom for example. Do people ever like exclude the first observations of one time series and keep the other the same to not get negative degrees of freedom??