Testing for Autocorrelation
Learn to apply the Ljung-Box test for autocorrelation.
Motivation
Sometimes, we’ll need to know if there is any autocorrelation of any form in our series at all. In other words, we will be interested in whether or not all autocorrelations up to some lag are 0. The most common case arises when evaluating the results of a model, such as an ARIMA model.
ARIMA models require that prediction errors (or residuals) are independent and identically distributed (IID) with a constant mean and variance, i.e., white noise. In this definition, independent means that the residuals are not serially correlated. If an ARIMA model is not producing this type of residual, it fails to capture all the underlying patterns in the data. In this lesson, we will go through some tests that will let us assess if our data is autocorrelated.
Note: The logic and methods that we explore in this lesson for the autocorrelation of a series can be equally applied to the partial autocorrelation of the series.
The Ljung-Box test
The Ljung-Box (LB) test is a commonly used test in econometrics and finance to assess the presence of autocorrelation in a time series. Its null hypothesis is that all autocorrelations up to lag
The alternative hypothesis,
The LB test has a cumulative nature, as it is a function of the sum of several autocorrelation coefficients. We can see this cumulative nature in the definition of the LB test statistic below:
In the equation above,