🚀 Try Zilliz Cloud, the fully managed Milvus, for free—experience 10x faster performance! Try Now>>

Milvus
Zilliz

What is the Granger causality test in time series analysis?

The Granger causality test is a statistical method used to determine if one time series can predict another. It operates on the principle that if past values of variable X improve the prediction of variable Y beyond what’s possible using only past values of Y, then X “Granger-causes” Y. This is not about true causality in a philosophical sense but focuses on predictive relationships within the data. The test involves fitting linear regression models to lagged values of the variables and comparing their explanatory power using an F-test. For example, if analyzing stock prices and interest rates, you’d check whether lagged interest rate values add meaningful information to predict stock price movements.

To implement the test, you first ensure the time series is stationary (mean and variance don’t change over time). Next, you select an appropriate number of lags (past observations) for both variables. For instance, if using daily sales data and advertising spend, you might test whether advertising from the past 7 days helps predict today’s sales. The core steps involve: (1) fitting a model that predicts Y using its own lags, (2) fitting another model that adds lags of X, and (3) comparing the two using an F-test to see if X’s lags significantly improve the prediction. Tools like Python’s statsmodels or R’s lmtest package automate these calculations. A key practical consideration is avoiding overfitting by choosing too many lags, which can be addressed using criteria like AIC or BIC.

However, Granger causality has limitations. It assumes linear relationships and stationarity, and it can’t account for unobserved variables that might influence both X and Y. For example, if weather affects both ice cream sales and beach attendance, Granger causality might falsely suggest ice cream sales predict beach visits. It also works only in a bivariate context unless extended to multivariate models. Developers should use it as a preliminary tool to identify potential predictive relationships, not as proof of causation. Pairing it with domain knowledge and other methods (like impulse response analysis in VAR models) often yields more robust insights for time series forecasting or causal inference tasks.

Like the article? Spread the word