Skip to content
All library documents

Apply the Ljung–Box Test to Returns, Not Price Levels

Article Quant Q&A · Author: Ice

Summary

This note addresses why a Ljung–Box test on stock closing prices can produce p-values near zero across many samples. The test evaluates a null of no serial dependence; rejecting that null indicates evidence of autocorrelation. Price levels commonly inherit dependence from one observation to the next, so testing them can make rejection unsurprising and tell little about whether price changes are serially predictable.

The answer recommends applying the test to returns rather than raw prices when investigating serial correlation in market data. The document does not specify a return definition, lag-selection method, or adjustments for model fitting, and it does not report test results on returns. The recommendation therefore clarifies the input series for a more informative diagnostic but does not establish that returns will be independent or that any particular trading strategy follows from the test.

Key ideas

  • The Ljung–Box test evaluates a null hypothesis of no serial dependence in the tested series.
  • A near-zero p-value indicates rejection of that null, not a lack of autocorrelation.
  • Price levels tend to depend on prior levels, making them a poor choice for this diagnostic.
  • Testing returns instead can provide a more informative check for serial correlation, though the result depends on the data and test setup.

Tags

Full text
# How to apply Ljung Box Test?


# How to apply Ljung Box Test?












I am checking the closing prices(about 9000+ prices) of the stocks data to test for randomness.

The test I am using is Ljung Box test, in MFE toolbox for MATLAB,

I used 300 data of closing prices, and 8 lags. Q = test statistics. pval = pvalue.

[Q, pval] = ljungbox(closingPrices,lags);

However, no matter which 30 intervals of 300, I keep getting all the p-value as zero, meaning, reject null hypothesis and conclude that there is no serial correlation.

i tried with different types of stocks, but all the p-value are all zero, which made the Ljung Box's test not very interesting.

May i know if I had used the Ljung Box Test wrongly?

If you have any comments, please enlighten me, thank you very much.

## Answer by SRKX (score 3, accepted)

https://quant.stackexchange.com/a/9145

In the Ljung-Box test, the null hypothesis is:

$H_0$: The data are independently distributed

So, your p-values of 0 indeed indicate that you should reject the null hypothesis, but it means that your data is not independently distributed, and in particular that there is some significant autocorrelation in the process.

This is obviously the case, because you use prices!!! The price at time $t_{i+1}$ clearly depends of the price at time $t_i$.

In order to have an interesting result, you need to test the returns of the price series, as opposed to the prices themselves.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.