runs.test.RdComputes the runs test for randomness of the dichotomous (binary) data
series x.
runs.test(x, alternative = c("two.sided", "less", "greater"))This test searches for randomness in the observed data series
x by examining the frequency of runs. A "run" is defined as a
series of similar responses.
Note, that by using the alternative "less" the null of
randomness is tested against some kind of "under-mixing"
("trend"). By using the alternative "greater" the null of
randomness is tested against some kind of "over-mixing"
("mean-reversion").
Missing values are not allowed.
A list with class "htest" containing the following components:
the value of the test statistic.
the p-value of the test.
a character string indicating what type of test was performed.
a character string giving the name of the data.
a character string describing the alternative hypothesis.
S. Siegel (1956): Nonparametric Statistics for the Behavioural Sciences, McGraw-Hill, New York.
S. Siegel and N. J. Castellan (1988): Nonparametric Statistics for the Behavioural Sciences, 2nd edn, McGraw-Hill, New York.
x <- factor(sign(rnorm(100))) # randomness
runs.test(x)
#>
#> Runs Test
#>
#> data: x
#> Standard Normal = 0.036315, p-value = 0.971
#> alternative hypothesis: two.sided
#>
x <- factor(rep(c(-1,1),50)) # over-mixing
runs.test(x)
#>
#> Runs Test
#>
#> data: x
#> Standard Normal = 9.8499, p-value < 2.2e-16
#> alternative hypothesis: two.sided
#>