Run test statistics

117 Views Asked by At

I'm currently implementing the Wald-Wolfowitz runs test on a variable $\epsilon \in \{0;1\} $. According to the original paper, the number of runs, $V_n$ converges to the normal distribution with:

$$\mu = \frac{2n_1n_2}{n}+1$$

and

$$\sigma^2 = \frac{2n_1n_2(2n_1n_2-n)}{n^2(n-1)}$$

where $n_1$ is the number of 1 and $n_2$ the number of 0 in the sample under the assumption that $\epsilon$ is randomly generated. I would like to build the corresponding test statistic and determine the p-value from there.

$$\frac{V_n-\mu}{\sigma} \sim \mathcal{N}(0,1)$$

I could then use the half normal distribution of the previous result. The p-value associated with the test would become:

$$p-value = erfc(\frac{|V_n-\mu|}{\sqrt{2}\sigma})$$

Now, I compared this result with the recommended statistic in FIPS 800-22, which is:

$$p-value=erfc(\frac{|V_n - 2n\pi(1-\pi)|}{2\sqrt{2n}\pi(1-\pi)})$$

where $\pi=\frac{n_1}{n}$. From the description, it seems like they are using the $\chi^2$ test but there is no more information on how this p value is found.

Is there anything wrong with the reasoning I had to find the p-value? Is there any particular reason to use the $\chi^2$ test instead of using the expected distribution law?

Thanks