Wald–Wolfowitz runs test

From testwiki
Revision as of 01:44, 6 April 2024 by imported>Knotnic (Copyedit (minor) for clarity)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Wald–Wolfowitz runs test (or simply runs test), named after statisticians Abraham Wald and Jacob Wolfowitz is a non-parametric statistical test that checks a randomness hypothesis for a two-valued data sequence. More precisely, it can be used to test the hypothesis that the elements of the sequence are mutually independent.

Definition

A run of a sequence is a maximal non-empty segment of the sequence consisting of adjacent equal elements. For example, the 22-element-long sequence

+ + + + − − − + + + − − + + + + + + − − − −

consists of 6 runs, with lengths 4, 3, 3, 2, 6, and 4. The run test is based on the null hypothesis that each element in the sequence is independently drawn from the same distribution.

Under the null hypothesis, the number of runs in a sequence of N elements[note 1] is a random variable whose conditional distribution given the observation of N+ positive values[note 2] and N negative values (Template:Nowrap) is approximately normal, with:[1][2]

mean: μ=2 N+ NN+1,variance: σ2=2 N+ N (2 N+ NN)N2 (N1)=(μ1)(μ2)N1.

Equivalently, the number of runs is R=12(N++N+1i=1N1xixi+1).

These parameters do not assume that the positive and negative elements have equal probabilities of occurring, but only assume that the elements are independent and identically distributed. If the number of runs is significantly higher or lower than expected, the hypothesis of statistical independence of the elements may be rejected.

Proofs

Moments

The number of runs is R=12(N++N+1i=1N1xixi+1). By independence, the expectation isE[R]=12(N+1(N1)E[x1x2])Writing out all possibilities, we findx1x2={+1 with probability N+(N+1)+N(N1)N(N1)1 with probability 2N+NN(N1)Thus, E[x1x2]=(N+N)2NN(N1). Now simplify the expression to get E[R]=2 N+ NN+1.

Similarly, the variance of the number of runs isVar[R]=14Var[i=1N1xixi+1]=14((N1)E[x1x2x1x2]+2(N2)E[x1x2x2x3]+(N2)(N3)E[x1x2x3x4](N1)2E[x1x2]2)and simplifying, we obtain the variance.

Similarly we can calculate all moments of R, but the algebra becomes uglier and uglier.

Asymptotic normality

Theorem. If we sample longer and longer sequences, with limN+/N=p for some fixed p(0,1), then RμσN(R/μ1) converges in distribution to the normal distribution with mean 0 and variance 1.

Proof sketch. It suffices to prove the asymptotic normality of the sequence i=1N1xixi+1, which can be proven by a martingale central limit theorem.

Applications

Runs tests can be used to test:

  1. the randomness of a distribution, by taking the data in the given order and marking with + the data greater than the median, and with – the data less than the median (numbers equalling the median are omitted.)
  2. whether a function fits well to a data set, by marking the data exceeding the function value with + and the other data with −. For this use, the runs test, which takes into account the signs but not the distances, is complementary to the chi square test, which takes into account the distances but not the signs.

The Kolmogorov–Smirnov test has been shown to be more powerful than the Wald–Wolfowitz test for detecting differences between distributions that differ solely in their location. However, the reverse is true if the distributions differ in variance and have at the most only a small difference in location.Template:Citation needed

The Wald–Wolfowitz runs test has been extended for use with several samples.[3][4][5][6]

Notes

Template:Reflist

References

Template:Reflist


Cite error: <ref> tags exist for a group named "note", but no corresponding <references group="note"/> tag was found

  1. Template:Cite web
  2. Sample 33092: Wald–Wolfowitz (or runs) test for randomness
  3. Template:Cite journal
  4. Template:Cite journal
  5. Sprent P, Smeeton NC (2007) Applied Nonparametric Statistical Methods, pp. 217–219. Boca Raton: Chapman & Hall/ CRC.
  6. Template:Cite journal