Skip to contents

Tests a numeric series for randomness by dichotomizing around a threshold and counting runs, with the exact normal approximation. Reproduces randtests::runs.test.

Usage

morie_runs_test(x, threshold = stats::median(x), alternative = "two.sided")

Arguments

x

Numeric vector.

threshold

Cut point (default the median); values equal to the threshold are dropped, as in randtests.

alternative

"two.sided" (default), "left.sided" (too few runs), or "right.sided".

Value

A list with statistic (z), p.value, runs, n1, n2, method.

References

Wald, A., & Wolfowitz, J. (1940). On a test whether two samples are from the same population. Annals of Mathematical Statistics, 11(2), 147-162.

Examples

set.seed(1); morie_runs_test(rnorm(50))$p.value
#> [1] 1