# A $t$-test for ordered pairs

Suppose I have random variables $$W_i = \begin{cases} w_1 &\text{with prob. } p_1, \\ w_2 &\text{with prob. } p_2, \\ w &\text{with prob. } 1-p_1-p_2,\end{cases} \qquad i = 1, \dots, 2n+1.$$ The values $w_1, w_2$ and $w$ are distinct. I am interested whether the ordered pair $(w_1,w_2)$ occurs unusually often. Specifically, I would like to test whether $$P(W_i = w_1, W_{i+1} = w_2) = P(W_i = w_1) P(W_{i+1} = w_2) \quad \text{ for all } i = 1, \dots, 2n.$$ Edit: The null hypothesis is that the $W_i$ are independent.

My approach is to define the random variables $$X_i = \begin{cases} 1 &\text{if } W_i = w_1 \text{ and } W_{i+1} = w_2, \\ 0 &\text{otherwise,} \end{cases} \quad i = 1, \dots, 2n.$$ Let $p = p_1 p_2 = P(W_i = w_1) P(W_{i+1} = w_2).$ Then (under the null hypothesis) $E[X_i] = p$ and $\text{Var}(X_i) = p(1-p).$ With $\overline{X} = \frac1{2n} \sum_{i=1}^{2n} X_i,$ I can define my $t$-statistic $$T = \sqrt{2n} \frac{\overline{X}-p}{\sqrt{p(1-p)}}.$$ But is it indeed true that $T \xrightarrow{d} \mathcal{N}(0,1)$? Possibly not! To see this, suppose that $X_i = 1.$ Then $W_{i+1} = w_2 \neq w_1$, which implies $X_{i+1} = 0.$ Hence neighboring $X_i$ are not independent, and the (standard) central limit theorem is inapplicable.

Is it still possible to determine the approximate distribution of $T$?

I had the following idea: Define $\overline{X}_1 = \frac1n \sum_{i=1}^{2n} X_{2i-1}$ and $\overline{X}_2 = \frac1n \sum_{i=1}^{2n} X_{2i}.$ These sums do not contain neighboring random variables, hence the $t$-statistics $$T_1 = \sqrt{n} \frac{\overline{X}_1 - p}{\sqrt{p(1-p)}} \quad \text{ and } \quad T_2 = \sqrt{n} \frac{\overline{X}_2 - p}{\sqrt{p(1-p)}}$$ satisfy $T_1, T_2 \xrightarrow{d} \mathcal{N}(0,1).$ Furthermore, $T = (T_1 + T_2) / \sqrt{2}.$

By the arguments above, $P(X_i = X_{i+1} = 1) = 0,$ hence $$\text{Cov}(X_i, X_{i+1}) = E[X_i X_{i+1}] - p^2 = - p^2.$$ Similarly, $\text{Cov}(X_i, X_{i-1}) = -p^2.$ All other covariances are zero. Since every $X_i$ has two neighbors, except for $X_1$ and $X_{2n}$, $$\text{Cov}\Big(\frac{T_1}{\sqrt{2}},\frac{T_2}{\sqrt{2}}\Big) = \frac1{2np(1-p)} \sum_{i,j=1}^{2n} \text{Cov}(X_{2i-1},X_{2j}) = - \frac{(2n-2)p^2}{2np(1-p)} = - \frac{(n-1)p}{n(1-p)}.$$

I now thought of the following result: If $A,B \sim \mathcal{N}(0,1),$ then $(A+B)/\sqrt{2} \sim \mathcal{N}(0,1+\rho_{A,B}),$ where $\rho_{A,B}$ is the correlation coefficient of $A$ and $B$.

Hence my question:

Is the distribution of $T / \sqrt{1-\frac{(n-1)p}{n(1-p)}}$ approximately standard normal?

• To be able to make inferences here, you need to make assumptions on the joint distribution of the $W_i$'s. The inference may depend very strongly on such assumptions. Oct 1, 2017 at 17:24
• Thank you, I forgot to mention that: The $W_i$ are independent. Oct 1, 2017 at 18:31

The distribution of $T$ is indeed asymptotically normal, by virtue of any one of the many central theorems for stationary weakly dependent (here, even $2$-independent) random variables (r.v.'s). See e.g. Theorem 0 in Bradley (due to Ibragimov), the conditions of which are easily verified in your case.
An idea of how to get such results goes back to Bernstein and is as follows: Partition the sequence of weakly dependent r.v.'s into an alternating sequence of longer and shorter blocks, such that each long block is followed a short one, but the long blocks are still much shorter than the number (say $n$, $n\to\infty$) of the weakly dependent r.v.'s, so that the number of the long blocks is growing to infinity with $n$. Then the contribution of the short blocks will be comparatively small, whereas the long blocks will be nearly independent. In your case, you can take the short blocks just of length $1$, and then the long blocks, of length much greater than $1$ but much less than $n$, will be exactly independent.
• Thanks! In the notation of Theorem 0 in the paper, is it correct to say that $\rho_n = 0$ for all $n \ge 2$ in my case? Oct 2, 2017 at 9:45
• It will indeed be so in your case of $2$-independent $X_i$'s, where the sequences $(X_1,\dots,X_j)$ and $(X_{j+2},X_{j+3},\dots)$ are independent, for each $j$. Oct 2, 2017 at 12:59