# Ljung-Box test for ARMA residuals: is my ARMA model fine?

I have an ARMA($p$,$q$) model. $p=q=2$ gave me the lowest BIC value, and hence I stuck to it.

I know people do something with the Ljung-Box $Q$-test test for autocorrelations. I did this on Matlab with lags of 5,10, 15 and hence degrees of freedom of 1,6,11. More explanation of this Matlab function is here.

I get $h=(0,0,0)$ and $p=(0.1511,0.8545,0.3046)$.

1. Does this mean my ARMA model is good enough? Why so?
2. Does this mean my ARMA model is not good enough? Why so and what should I do?

Ideally, the residuals of your ARMA(2,2) models are independent of each other, which means there is no pattern of autocorrelation in the residuals. The Q-test tests for an autocorrelation pattern in the residuals. The null hypothesis is (Wikipedia):

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; they exhibit serial correlation.

"Data" can be read as "residuals" in your case. The lags you included tells your function to test for serial correlation in the residuals within 5, 10 and 15 time points from each other.

In general, it is correct to first select the best order for the ARMA model with the BIC (or AIC, or both) and then check whether for that model the residuals are serially independent.

The Q-test results you posted are fine, nothing to worry about.

Edit: Contribution by @RichardHardy in the comments: There has been debate about the validity of the Ljung-Box test in these situations. The Breusch-Godfrey test is considered the most powerful test (see Testing for autocorrelation: Ljung-Box versus Breusch-Godfrey).

From the information I have been able to read through, it is my impression that serious statisticians generally agree on the superiority on the Breusch-Godfrey test. Even though it seems to be generally accepted to use both tests, that does not mean it is the right thing to do.

• While it is a nice answer, unfortunately, Ljung-Box test does not apply to residuals of ARMA models (despite the fact that many are ignorant of that); see Testing for autocorrelation: Ljung-Box versus Breusch-Godfrey and How many lags to use in the Ljung-Box test of a time series?. – Richard Hardy May 22 '16 at 8:41
• @RichardHardy Thanks. Could you explain why Ljung-Box does not apply to ARMA? – bissi May 25 '16 at 20:35
• @bissi, Check out the links I included. The explanations there are detailed and IMO very good. – Richard Hardy May 25 '16 at 20:42
• Ken, would you mind responding to my concern? I think your answer is misleading since LB test does not apply to residuals from ARIMA models. Keeping the answer unchanged might mislead users in the future. – Richard Hardy Jul 10 '16 at 19:47
• Thanks, now it is alright. Keep in mind that a practice being "generally accepted" does not make it a good practice. Sometimes lack of understanding leads to many ignorant people using something that is entirely inappropriate. – Richard Hardy Jul 11 '16 at 8:46