# Ljung Box test chi square distribution

I want to prove the following statement:

Under $H_{0}$ the test statistic $Q=n(n+2)$ $\sum \limits_{k=1}^h \frac{\hat{p}_{k}^2}{n-k}$ follows a $\chi ^2(h)$ chi-squared distribution with $h$ degrees of freedom. $H_{0}$ is the hypothesis that all data points are independently distributed.

$n$: sample size

$\hat{p}_{k}$: sample autocorrelation at lag k

$h$: number of lags being tested

I know that if $H_{0}$ is valid it follows that $Q=0$ because $\hat{p}_{k}=0$ for all k.

But how do I conclude that $Q$ is chi-squared distributed?

• You seem to have created two separate accounts which is limiting your ability to edit your own question: click here to see how to merge them. Commented Dec 27, 2015 at 14:02
• Incidentally, the statement that $Q=0$ under $H_0$ is false, because even if the true autocorrelations are zero, the sample autcorrelations are not, and small nonzero values get magnified by $n$ - so it would be better to write that $Q$ takes small values if $H_0$ is true (and small is precisely measured by its $\chi^2$ null distribution). Commented Dec 28, 2015 at 14:05

First, note that $$Q=n\sum_{k=1}^h \frac{(n+2)\hat{p}_{k}^2}{n-k}$$ and that $\frac{n+2}{n-k}\to1$ as $n\to\infty$, so that $Q$ will behave like $$\tilde Q=n\sum_{k=1}^h\hat{p}_{k}^2$$ asymptotically.

To show that $\tilde Q$ is $\chi^2(h)$ under $H_0$, consider the following intermediate result adapted from Brockwell and Davis (1991), Theorem 7.2.1: Let $\hat{p}=(\hat p_1,\ldots,\hat p_h)^\top$. For a white noise process (i.e., one for which the null is true) $$Y_t=\mu+\epsilon_t$$ with $E|\epsilon_t|^4<\infty$ it holds that $$\sqrt{n}\hat{p}\to_d N(0,I_h)$$ Thus, the first $h$ sample autocorrelations are multivariate normal with expected value 0 each (the true autocorrelation of any order for a white noise process) and asymptotic covariance matrix equal to the identity matrix. Hence, they are asymptotically independent. This also implies that each autocorrelation is asymptotically standard normal. Next, observe that $$\tilde Q=\sqrt{n}\hat{p}^\top\sqrt{n}\hat{p}$$ Now, we know that the sum of $h$ independent squared standard normal random variables is $\chi^2(h)$.

• Are you refering to this book [books.google.de/…? I am not sure how you conclude that $\sqrt{n} \hat{p} \rightarrow N(0, I_{h})$. I understand the rest. Commented Dec 27, 2015 at 20:49
• I posted a second answer on this, as I felt it would clutter the first one on Ljung Box too much. Commented Dec 28, 2015 at 10:15

This second answer provides a more detailed derivation of why the asymptotic distribution is multivariate normal with identity covariance matrix for $Y_t$ white noise. (Notation differs slightly from the question and previous answer, in that autocorrelations are denoted by $\rho$ and that we look at $p$ of them, following Brockwell and Davis, Time Series - Theory and Methods more closely.)

Brockwell and Davis, Thm. 7.2.1, states that the distribution of the correlation coefficients $\hat{\rho}=(\hat{\rho}_1,\ldots,\hat{\rho}_p)^\top$ if $Y_t$ is a general linear process $$Y_t=\mu+\sum_{j=-\infty}^{\infty}\psi_j\epsilon_{t-j}$$ with $E|\epsilon_t|^4<\infty$ and $\sum_{j=-\infty}^{\infty}|\psi_j|<\infty$ is given by $$\sqrt{n}(\hat{\rho}-\rho)=N(0,W)$$ where the elements of $W$ are given by $$w_{ij}=\sum_{k=-\infty}^{\infty}\rho_{k+i}\rho_{k+j}+\rho_{k-i}\rho_{k+j}+2\rho_{i}\rho_{j}\rho_{k}^2-2\rho_{i}\rho_{k}\rho_{k+j}-2\rho_{j}\rho_{k}\rho_{k+i}$$ This can also be written as $$w_{ij}=\sum_{k=1}^{\infty}\{\rho_{k+i}+\rho_{k-i}-2\rho_{i}\rho_{k}\}\{\rho_{k+j}+\rho_{k-j}-2\rho_{j}\rho_{k}\}\qquad(*)$$ To see this, write $w_{ij}=\sum_{k=-\infty}^{\infty}w_{ij,k}$ and decompose $w_{ij}$ as $$w_{ij}=\sum_{k=-\infty}^{-1}w_{ij,k}+w_{ij,0}+\sum_{k=1}^{\infty}w_{ij,k}$$ Using $\rho_i=\rho_{-i}$ we directly verify that $w_{ij,0}=0$. Next, write \begin{eqnarray*} \sum_{k=-\infty}^{-1}w_{ij,k}&=&\sum_{k=1}^{\infty}w_{ij,-k}\\ &=&\sum_{k=1}^{\infty}\rho_{-k+i}\rho_{-k+j}+\rho_{-k-i}\rho_{-k+j}+2\rho_{i}\rho_{j}\rho_{-k}^2 -2\rho_{i}\rho_{-k}\rho_{-k+j}-2\rho_{j}\rho_{-k}\rho_{-k+i} \end{eqnarray*} Stationarity again implies that, e.g., $\rho_{-k+j}=\rho_{-(-k+j)}=\rho_{k-j}$. Hence, \begin{eqnarray*} \sum_{k=1}^{\infty}w_{ij,-k}&=&\sum_{k=1}^{\infty}\rho_{k-i}\rho_{k-j}+\rho_{k+i}\rho_{k-j}+2\rho_{i}\rho_{j}\rho_{k}^2 -2\rho_{i}\rho_{k}\rho_{k-j}-2\rho_{j}\rho_{k}\rho_{k-i} \end{eqnarray*} Hence, \begin{eqnarray*} \sum_{k=-\infty}^{\infty}w_{ij,k}&=&\sum_{k=1}^{\infty}\rho_{k+i}\rho_{k+j}+\rho_{k-i}\rho_{k+j}+2\rho_{i}\rho_{j}\rho_{k}^2 -2\rho_{i}\rho_{k}\rho_{k+j}-2\rho_{j}\rho_{k}\rho_{k+i}\notag\\ &&\;+\sum_{k=1}^{\infty}\rho_{k-i}\rho_{k-j}+\rho_{k+i}\rho_{k-j}+2\rho_{i}\rho_{j}\rho_{k}^2 -2\rho_{i}\rho_{k}\rho_{k-j}-2\rho_{j}\rho_{k}\rho_{k-i}\notag\\ &=&\sum_{k=1}^{\infty}\rho_{k+i}\rho_{k+j}+\rho_{k-i}\rho_{k+j}+4\rho_{i}\rho_{j}\rho_{k}^2 -2\rho_{i}\rho_{k}\rho_{k+j}-2\rho_{j}\rho_{k}\rho_{k+i}\notag\\ &&\qquad+\rho_{k-i}\rho_{k-j}+\rho_{k+i}\rho_{k-j}-2\rho_{i}\rho_{k}\rho_{k-j}-2\rho_{j}\rho_{k}\rho_{k-i}\qquad(**) \end{eqnarray*} Multiplying out (*) gives \begin{eqnarray*} w_{ij}&=&\sum_{k=1}^{\infty}\rho_{k+i}\rho_{k+j}+\rho_{k+i}\rho_{k-j}-2\rho_{k+i}\rho_{j}\rho_{k}+\rho_{k-i}\rho_{k+j}\\ &&\;+\rho_{k-i}\rho_{k-j}-2\rho_{k-i}\rho_{j}\rho_{k}-2\rho_{i}\rho_{k}\rho_{k+j}-2\rho_{i}\rho_{k}\rho_{k-j}+4\rho_{i}\rho_{k}^2\rho_{j} \end{eqnarray*} which is the same as (**).

To show the desired result for $Y_t$ white noise, note that the diagonal elements are \begin{eqnarray*} w_{ii}&=&\sum_{k=-\infty}^{\infty}\rho_{k+i}\rho_{k+i}+\rho_{k-i}\rho_{k+i}+2\rho_{i}\rho_{i}\rho_{k}^2 -2\rho_{i}\rho_{k}\rho_{k+i}-2\rho_{i}\rho_{k}\rho_{k+i}\\ &=&\sum_{k=-\infty}^{\infty}\rho_{k+i}^2+\rho_{k-i}\rho_{k+i}+2\rho_{i}^2\rho_{k}^2 -4\rho_{i}\rho_{k}\rho_{k+i} \end{eqnarray*} If $Y_t$ is white noise then $\rho_i=0$ for all $i\neq0$. Hence, $$\sum_{k=-\infty}^{\infty}\rho_{k+i}^2+\rho_{k-}\rho_{k+i}+2\rho_{i}^2\rho_{k}^2 -4\rho_{i}\rho_{k}\rho_{k+i}=1+0+0-0=1,$$ where the unit entry obtains when $k=-i$. The second term is always zero because the two terms cannot simultaneously have index zero. For $i\neq j$, note from $i,j,k>0$ that $$w_{ij}=\sum_{k=1}^{\infty}0+0-2\cdot0+0+\rho_{k-i}\rho_{k-j}-2\cdot0-2\cdot0-2\cdot0+4\cdot0$$ The only remaining entry must also be zero as $i\neq j$ such that not both $\rho_m$ can have index $m=0$.

• Ok that makes sense. So now we know that $\sqrt{n}(\hat{p}-h)\rightarrow N(0, I_{h})$ but $\sqrt{n}(\hat{p}-h)^T\sqrt{n}(\hat{p}-h) \neq \tilde{Q}$ or can we ignore $h$ as it is a constant? Commented Dec 28, 2015 at 11:24
• No, we know that $\sqrt{n}(\hat p -p)\to_dN(0,I_h)$! So, the scaled difference between the first $h$ estimated and true autocorrelations. Now, the true autocorrelations in the white noise case ("under the null") are all zero, so we need not subtract the resulting zero vector when forming $\tilde Q$. Commented Dec 28, 2015 at 11:52