# Why do we need adjustment when applying Ljung-Box test over residuals?

Why do we need adjustment when applying Ljung-Box test over residuals? The following is from the Multivariate Time Series Analysis by R. Tsay.

m1 = VAR(data.ts,p=2)
resi=m1$residuals ### Obtain the residuals of VAR(2) fit. mq(resi,adj=18) ## adj is used to adjust the degrees of freedom.  Regarding the above comment, why and how do we decide a value for adj? • Are you asking why the adjustment is a specific number (for this model or for any VAR model), or why there needs to be an adjustment at all (roughly, because the residuals aren't observations, they are estimates)? – Chris Haug May 4 '17 at 12:00 • Mark, see this answer for an explanation why the adjustment is needed in the first place. It is not very intuitive, but it gives some details. – Richard Hardy May 4 '17 at 14:13 ## 1 Answer The code you cite appears on page 72 of the book. Right before it, on page 71 you read: Compared with the Portmanteau test of Chapter 1, the degrees of freedom of the chi-square distribution in Theorem 2.6 is adjusted by$pk^2$, which is the number of AR parameters in a VAR(p) model. In practice, some of the AR parameters in a VAR(p) model are ﬁxed to 0. In this case, the adjustment in the degrees of freedom of the chi-square distribution is set to the number of estimated AR parameters. The adj is the degrees-of-freedom adjustment (as you can read in the help file for the mq function). In the example, adj=18 because$18=2\times 3^2$since the model has a trivariate response ($k=3$) and two autoregressive lags ($p=2\$).

• Thanks Richard. I cannot upvote the answer as I have fewer than 15 reputations. Moreover, I used AIC to fit VAR(2) model but Ljung-Box test gives better results with VAR(3) model. Can we use Ljung-Box statistic to select the order of the model? – Mark May 5 '17 at 4:14
• @Mark, it depends on what you want to use the model for. E.g. if you want to do forecasting, then AIC is a sounder basis for model selection than the Lung-Box test (which can lead to overfitting). – Richard Hardy May 5 '17 at 5:21