Two Sample chi squared test This question is from Van der Vaart's book Asymptotic Statistics, pg. 253. #3:
Suppose that $\mathbf{X}_m$ and $\mathbf{Y}_n$ are independent multinomial vectors with parameters $(m,a_1,\ldots,a_k)$ and $(n,b_1,\ldots,b_k)$. Under the null hypothesis that $a_i=b_i$ show that 
$$\sum_{i=1}^k \dfrac{(X_{m,i} - m\hat{c}_i)^2}{m\hat{c}_i} + \sum_{i=1}^k \dfrac{(Y_{n,i} - n\hat{c}_i)^2}{n\hat{c}_i}$$ has $\chi^2_{k-1}$ distribution. where $\hat{c}_i = (X_{m,i} + Y_{n,i})/(m+n)$.
I need some help getting started. Whats the strategy here? I was able to combine the two summands into:
$$\sum_{i=1}^k \dfrac{(mY_{n,i} - nX_{m,i})^2}{mn(m+n)\hat{c}_i}$$
but this wont work with the CLT because its a weighted combination of $X_m$ and $Y_n$. Not sure if this is the right path. Any suggestions? 
EDIT: if $m=n$ then its quite easy because we get 
$$\begin{align*}
\dfrac{mY_{n} - nX_{m}}{\sqrt{mn(m+n)}} &= \dfrac{Y_{n} - X_{m}}{\sqrt{(m+n)}}
\end{align*}$$
where the numerator can be viewed as a sum of differences of Multinomial$(1,a_1,\ldots,a_k)$ variables so we can apply CLT and then finish it off with Theorem 17.2 from that same chapter. However, I can't figure out how to get this to work out in this situation with different sample sizes. Any help?
A link to Google Books' chapter 17 of van der Vaart
 A: First some notation. Let $\left\{X_t\right\}_{1,\ldots,m}$ and $\left\{Y_t\right\}_{1,\ldots,n}$ denote the categorical sequence associated with $\mathbf{X}_m$ and $\mathbf{Y}_n$, i.e. $\text{Pr}\left\{X_t = i\right\} = a_i, \text{Pr}\left\{Y_t = i\right\} = b_i$. Let $N=n+m$. Consider the binerizations
$$\begin{align*}
\mathbf{X}_{i}^* &= (X^*_{1,i},\ldots,X_{N,i}^*) = (\delta_{i,X_1},\ldots,\delta_{i,X_n},0,\ldots,0)\\
\mathbf{Y}_{i}^* &= (Y^*_{1,i},\ldots,Y_{N,i}^*)= (0,\ldots,0,\delta_{i,Y_1},\ldots,\delta_{i,Y_n})\\
\end{align*}$$ where $\delta_{i,j}\equiv \mathbf{1}_{i=j}$ is Kronecker's Delta. So we have $$X_{m,i} = \sum_{t=1}^{N} X_{t,i}^* = \sum_{t=1}^m \delta_{i,X_t} \qquad Y_{n,i} = \sum_{t=1}^{N} Y_{t,i}^* = \sum_{t=1}^n \delta_{i,Y_t}$$
Now we begin the proof. First we combine the two summands of the test statistic. Note that $$\begin{align*}
X_{m,i} - m\hat{c}_i &= \dfrac{(n+m)X_{m,i} - m(X_{m,i} + Y_{n,i})}{n+m}\\
&= \dfrac{nX_{m,i} - mY_{n,i}}{n+m}\\
Y_{n,i} - n\hat{c}_i &= \dfrac{(n+m)Y_{n,i} - n(X_{m,i} + Y_{n,i})}{n+m}\\
&= \dfrac{mY_{n,i} - nX_{m,i}}{n+m}
\end{align*}$$
So we can write the test statistic as $$\begin{align*}
S &= \sum_{i=1}^k \dfrac{(X_{m,i} - m\hat{c}_i)^2}{m\hat{c}_i} + \sum_{i=1}^k \dfrac{(Y_{n,i} - n\hat{c}_i)^2}{n\hat{c}_i}\\
&= \sum_{i=1}^k \dfrac{(nX_{m,i} - mY_{n,i})^2}{(n+m)^2m\hat{c}_i} + \sum_{i=1}^k \dfrac{(nX_{m,i} - mY_{n,i})^2}{(n+m)^2n\hat{c}_i}\\
&= \sum_{i=1}^k \dfrac{(nX_{m,i} - mY_{n,i})^2}{nm(n+m)\hat{c}_i}
\end{align*}$$
Next note that $$nX_{m,i} - mY_{n,i} = \sum_{t=1}^N nX_{t,i}^* - mY_{t,i}^* = Z_{i}$$
with the following properties
$$\begin{align*}
\text{E}[Z_{i}] &= n\text{E}[X_{m,i}] - m\text{E}[Y_{n,i}]\\
&= nma_i - nma_i = 0\\
\text{Var}[Z_{i}] &= \text{Var}[nX_{m,i} - mY_{n,i}]\\
&= n^2\text{Var}[X_{m,i}] - m^2\text{Var}[Y_{n,i}] \qquad\text{Note $X_{m,i}$ and $Y_{n,i}$ are independent}\\
&= n^2ma_i(1-a_i) + m^2na_i(1-a_i)\\
&= nm(n+m)a_i(1-a_i)\\
\text{Cov}[Z_{i},Z_{j}] &= \text{E}[Z_{i}Z_{j}] - \text{E}[Z_{i}]\text{E}[Z_{j}]\\
&= \text{E}[(nX_{m,i} - mY_{n,i})(nX_{m,j} - mY_{n,j})]\\
&= n^2(-ma_ia_j + m^2a_ia_j) - 2n^2m^2a_ia_j + m^2(-na_ia_j+n^2a_ia_j)\\
&= -nm(n+m)a_ia_j
\end{align*}$$
and so by multivariate CLT we have $$\dfrac{1}{\sqrt{nm(n+m)}}\mathbf{Z} = \dfrac{n\mathbf{X}_m - m \mathbf{Y}_n}{\sqrt{nm(n+m)}}\overset{D}{\to} \text{N}(\mathbf{0},\Sigma)$$ where the $(i,j)$th element of $\Sigma$, $\sigma_{ij} = a_i(\delta_{ij} - a_j)$. Since $\hat{\mathbf{c}} = (\hat{c}_1,\ldots,\hat{c}_k) \overset{p}{\to} (a_1,\ldots,a_k)=\mathbf{a}$ By Slutsky we have $$\dfrac{n\mathbf{X}_m - m \mathbf{Y}_n}{\sqrt{nm(n+m)}\hat{\mathbf{c}}}\overset{D}{\to} \text{N}(\mathbf{0},\mathbf{I}_k - \sqrt{\mathbf{a}}\sqrt{\mathbf{a}}')$$ where $\mathbf{I}_k$ is the $k\times k$ identity matrix, $\sqrt{\mathbf{a}} = (\sqrt{a_1},\ldots,\sqrt{a_k})$. Since $\mathbf{I}_k - \sqrt{\mathbf{a}}\sqrt{\mathbf{a}}'$ has eigenvalue 0 of multiplicty 1 and eigenvalue 1 of multiplicity $k-1$, by the continuous mapping theorem (or see Lemma 17.1, Theorem 17.2 of van der Vaart) we have $$\sum_{i=1}^k \dfrac{(nX_{m,i} - mY_{n,i})^2}{nm(n+m)\hat{c}_i} \overset{D}{\to} \chi^2_{k-1}$$
