infer_runs_test {inferr} | R Documentation |
Test for Random Order
Description
runtest tests whether the observations of x
are serially
independent i.e. whether they occur in a random order, by counting
how many runs there are above and below a threshold. By default, the median
is used as the threshold. A small number of runs indicates positive serial
correlation; a large number indicates negative serial correlation.
Usage
infer_runs_test(
data,
x,
drop = FALSE,
split = FALSE,
mean = FALSE,
threshold = NA
)
Arguments
data |
a |
x |
numeric; column in |
drop |
logical; if TRUE, values equal to the threshold will be dropped
from |
split |
logical; if TRUE, data will be recoded in binary format |
mean |
logical; if TRUE, mean will be used as threshold |
threshold |
threshold to be used for counting runs, specify 0 if data is coded as a binary. |
Value
infer_runs_test
returns an object of class "infer_runs_test"
.
An object of class "infer_runs_test"
is a list containing the
following components:
n |
number of observations |
threshold |
within group sum of squares |
n_below |
number below the threshold |
n_above |
number above the threshold |
mean |
expected number of runs |
var |
variance of the number of runs |
n_runs |
number of runs |
z |
z statistic |
p |
p-value of |
Deprecated Function
runs_test()
has been deprecated. Instead use infer_runs_test()
.
References
Sheskin, D. J. 2007. Handbook of Parametric and Nonparametric Statistical Procedures, 4th edition. : Chapman & Hall/CRC.
Edgington, E. S. 1961. Probability table for number of runs of signs of first differences in ordered series. Journal of the American Statistical Association 56: 156–159.
Madansky, A. 1988. Prescriptions for Working Statisticians. New York: Springer.
Swed, F. S., and C. Eisenhart. 1943. Tables for testing randomness of grouping in a sequence of alternatives. Annals of Mathematical Statistics 14: 66–87.
Examples
infer_runs_test(hsb, read)
infer_runs_test(hsb, read, drop = TRUE)
infer_runs_test(hsb, read, split = TRUE)
infer_runs_test(hsb, read, mean = TRUE)
infer_runs_test(hsb, read, threshold = 0)