Ljung–Box test

# Ljung–Box test

Discussion
 Ask a question about 'Ljung–Box test' Start a new discussion about 'Ljung–Box test' Answer questions from other users Full Discussion Forum

Encyclopedia
The Ljung–Box test is a type of statistical test of whether any of a group of autocorrelation
Autocorrelation
Autocorrelation is the cross-correlation of a signal with itself. Informally, it is the similarity between observations as a function of the time separation between them...

s of a time series
Time series
In statistics, signal processing, econometrics and mathematical finance, a time series is a sequence of data points, measured typically at successive times spaced at uniform time intervals. Examples of time series are the daily closing value of the Dow Jones index or the annual flow volume of the...

are different from zero. Instead of testing randomness
Randomness
Randomness has somewhat differing meanings as used in various fields. It also has common meanings which are connected to the notion of predictability of events....

at each distinct lag
Lag
Lag is a common word meaning to fail to keep up or to fall behind. In real-time applications, the term is used when the application fails to respond in a timely fashion to inputs...

, it tests the "overall" randomness based on a number of lags, and is therefore a portmanteau test
Portmanteau test
A portmanteau test is a type of statistical hypothesis test in which the null hypothesis is well specified, but the alternative hypothesis is more loosely specified. Tests constructed in this context can have the property of being at least moderately powerful against a wide range of departures from...

.

This test is sometimes known as the Ljung–Box Q test, and it is closely connected to the Box–Pierce test (which is named after George E. P. Box
George E. P. Box
- External links :* from a at NIST* * * * * *** For Box's PhD students see*...

and David A. Pierce). In fact, the Ljung–Box test statistic was described explicitly in the paper that lead to the use of the Box-Pierce statistic, and from which that statistic takes its name. The Box-Pierce test statistic is a simplified version of the Ljung–Box statistic for which subsequent simulation studies have shown poor performance.

The Ljung–Box test is widely applied in econometrics
Econometrics
Econometrics has been defined as "the application of mathematics and statistical methods to economic data" and described as the branch of economics "that aims to give empirical content to economic relations." More precisely, it is "the quantitative analysis of actual economic phenomena based on...

and other applications of time series analysis

## Formal definition

The Ljung–Box test test can be defined as follows.
H0: The data are independently distributed (i.e. the correlations in the population from which the sample is taken are 0, so that any observed correlations in the data result from randomness of the sampling process).
Ha: The data are not independently distributed.

The test statistic is:
where n is the sample size, is the sample autocorrelation at lag k, and h is the number of lags being tested. For significance level α, the critical region for rejection of the hypothesis of randomness is

where is the α-quantile
Quantile
Quantiles are points taken at regular intervals from the cumulative distribution function of a random variable. Dividing ordered data into q essentially equal-sized data subsets is the motivation for q-quantiles; the quantiles are the data values marking the boundaries between consecutive subsets...

of the chi-squared distribution with h degrees of freedom.

The Ljung–Box test is commonly used in autoregressive integrated moving average
Autoregressive integrated moving average
In statistics and econometrics, and in particular in time series analysis, an autoregressive integrated moving average model is a generalization of an autoregressive moving average model. These models are fitted to time series data either to better understand the data or to predict future points...

(ARIMA) modeling. Note that it is applied to the residuals
Errors and residuals in statistics
In statistics and optimization, statistical errors and residuals are two closely related and easily confused measures of the deviation of a sample from its "theoretical value"...

of a fitted ARIMA model, not the original series, and in such applications the hypothesis actually being tested is that the residuals from the ARIMA model have no autocorrelation. When testing ARIMA models, no adjustment to the test statistic or to the critical region of the test are made in relation to the structure of the ARIMA model.

## Box-Pierce test

The Box-Pierce test uses the test statistic, in the notation outlined above, given by
and it uses the same critical region as defined above.

Simulation studies have shown that the Ljung–Box statistic is better for all sample sizes including small ones.