I have a time series I am trying to forecast, for which I have used the seasonal ARIMA(0,0,0)(0,1,0)[12] model (=fit2). It is different from what R suggested with auto.arima (R calculated ARIMA(0,1,1)(0,1,0)[12] would be a better fit, I named it fit1). However, in the last 12 months of my time series my model (fit2) seems to be a better fit when adjusted (it was chronically biased, I have added the residual mean and the new fit seems to sit more snugly around the original time series. Here is the example of the last 12 months and MAPE for 12 most recent months for both fits:

fit1, fit2 and original data

The time series looks like this:

original time series

So far so good. I have performed residual analysis for both models, and here is the confusion.

The acf(resid(fit1)) looks great, very white-noisey:

acf of fit1

However, Ljung-Box test doesn't look good for , for instance, 20 lags:


I get the following results:

    X-squared = 26.8511, df = 19, p-value = 0.1082

To my understanding, this is the confirmation that the residuals are not independent ( p-value is too big to stay with the Independence Hypothesis).

However, for lag 1 everything is great:


gives me the result:

    X-squared = 0.3512, df = 0, p-value < 2.2e-16

Either I am not understanding the test, or it is slightly contradicting to what I see on the acf plot. The autocorrelation is laughably low.

Then I checked fit2. The autocorrelation function looks like this:

acf fit2

Despite such obvious autocorrelation at several first lags, the Ljung-Box test gave me much better results at 20 lags, than fit1:


results in :

    X-squared = 147.4062, df = 20, p-value < 2.2e-16

whereas just checking autocorrelation at lag1, also gives me the confirmation of the null-hypothesis!

    X-squared = 30.8958, df = 1, p-value = 2.723e-08 

Am I understanding the test correctly? The p-value should be preferrably smaller than 0.05 in order to confirm the null hypothesis of residuals independence. Which fit is better to use for forecasting, fit1 or fit2?

Additional info: residuals of fit1 display normal distribution, those of fit2 do not.

  • 4
    $\begingroup$ You don't understand p-values, & are interpreting them the wrong way round. $\endgroup$ Jul 18, 2013 at 14:36
  • $\begingroup$ Yes, it could be the question of understanding. Could you please expand? For example, what exactly means if p-value is bigger than 0.5? I have read the definition of p-value (probability of obtaining statistics at least as extreme as the test statistic given that null hypotheses holds). How does it apply to Ljung-Box test? Does "at least as extreme" mean "larger than X squared"? I would be grateful for the example with my data, since significance testing has been challenging for me to understand. $\endgroup$
    – zima
    Jul 18, 2013 at 14:42
  • 7
    $\begingroup$ The Ljung-Box test statistic (X-squared) gets larger as the sample auto-correlations of the residuals get larger (see its definition), & its p-value is the probability of getting a value as large as or larger than that observed under the null hypothesis that the true innovations are independent. Therefore a small p-value is evidence against independence. $\endgroup$ Jul 18, 2013 at 14:58
  • $\begingroup$ @Scortchi, I think I got it. But that also makes my test at lag=1 for fit1 fail. How could this be explained? I do not see any autocorrelation at lag=1. Is there an some sort of extremality of this test with small number of lags (very small sample)? $\endgroup$
    – zima
    Jul 18, 2013 at 15:07
  • 3
    $\begingroup$ The Box-Ljung is an omnibus test of independence at all lags up to the one you specify. The degrees of freedom used is the no. lags minus the no. AR & MA parameters (fitdf) so you were testing against a chi-squared distribution with zero degrees of freedom. $\endgroup$ Jul 18, 2013 at 15:28

5 Answers 5


You've interpreted the test wrong. If the p value is greater than 0.05 then the residuals are independent which we want for the model to be correct. If you simulate a white noise time series using the code below and use the same test for it then the p value will be greater than 0.05.

m = c(ar, ma)
w = arima.sim(m, 120)
w = ts(w)
Box.test(w, type="Ljung-Box")
  • 5
    $\begingroup$ A short and neat explanation. +1 for the code example. $\endgroup$
    – Dawny33
    Aug 7, 2015 at 8:10
  • 1
    $\begingroup$ Your interpretation is not correct as well. A p-value of 0.05 means that you have 5% chance to make an error if you reject the null hypothesis of no auto-correlation until order 1 in your case. $\endgroup$
    – DJJ
    Nov 19, 2015 at 14:10
  • $\begingroup$ Mr. Ferrelly, what would be the advice if your ets model fails the Ljung-Box test? Should we for example try another model like Arima? Thank you very much in advance. $\endgroup$ Nov 27, 2021 at 11:58

Many statistical tests are used to try to reject some null hypothesis. In this particular case the Ljung-Box test tries to reject the independence of some values. What does it mean?

  • If p-value < 0.051: You can reject the null hypothesis assuming a 5% chance of making a mistake. So you can assume that your values are showing dependence on each other.

  • If p-value > 0.051: You don't have enough statistical evidence to reject the null hypothesis. So you can not assume that your values are dependent. This could mean that your values are dependent anyway or it can mean that your values are independent. But you are not proving any specific possibility, what your test actually said is that you can not assert the dependence of the values, neither can you assert the independence of the values.

In general, what is important here is to keep in mind that p-value < 0.05 lets you reject of the null-hypothesis, but a p-value > 0.05 does not let you confirm the null-hypothesis.

In particular, you can not proof the independence of the values of Time Series using the Ljung-Box test. You can only prove the dependence.

1: I assumed $\alpha = 0.05$, which is a standard value of risk.

  • $\begingroup$ Sorry I'm confused about your second point (p>0.05). When p>0.05 (assuming $\alpha=0.05$) we cannot reject the null hypothesis of independence. But you write "But you are not proving any possibility, you proved that both possibilit[i]es are still a chance". Can you explain it better? $\endgroup$
    – utobi
    Nov 26, 2016 at 14:06

According to the ACF graphs, it is obviously that the fit 1 is better since the correlation coefficient at lag k(k>1) drops sharply, and close to 0.


If you are judging with ACF then fit 1 is more appropriate. Instead of being confused on Ljung test you can still use the correlogram of the residuals to ascertain the best fit between fit1 and fit2

  • 1
    $\begingroup$ I don't understand this answer. $\endgroup$ May 27, 2018 at 23:03
  • $\begingroup$ When we visit Ljung box statistics, we could be interested in model diagnostic check I.e, model adequacy..... If using that is confusing to you there are other ways to check model adequacy which I stated above. You can plot the correlogram I.e, ACF and PACF of the data residual and then check the bounds of the series if it is white noise...... It's not must to use Ljung box test $\endgroup$
    – Vincent
    May 27, 2018 at 23:23

The Ljung-Box test uses the following hypotheses:

H0: The residuals are independently distributed.

HA: The residuals are not independently distributed; they exhibit serial correlation.

Ideally, we would like to be unable to reject the null hypothesis. That is, we would like to see a p-value greater than 0.05 because this means the residuals for our time series model are independent, which is often an assumption we make when creating a model.


Not the answer you're looking for? Browse other questions tagged or ask your own question.