Granger causality test

When saying that A causes B, this means that A is the reason that B happens. This is the common definition of causality: which one causes the next one. The Granger causality test is used to determine whether one time series is a factor and offers useful information in forecasting the second one. In the following code, a dataset called ChickEgg is used as an illustration. The dataset has two columns, number of chicks and number of eggs, with a timestamp:

> library(lmtest)> data(ChickEgg)> dim(ChickEgg)[1] 54 2> ChickEgg[1:5,]     chicken egg[1,] 468491 3581[2,] 449743 3532[3,] 436815 3327[4,] 444523 3255[5,] 433937 3156

The question is: could we use this year's egg numbers to predict the next year's chicken numbers? If this ...

Get Hands-On Data Science with Anaconda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.