# x has to be dichotomous for the test being
x <- c("S","S", "T", "S", "T","T","T", "S", "T")
RunsTest( x < median(x) )
x <- c(13, 3, 14, 14, 1, 14, 3, 8, 14, 17, 9, 14, 13, 2, 16, 1, 3, 12, 13, 14)
RunsTest( x < median(x) )
plot( (x < median(x)) - 0.5, type="s", ylim=c(-1,1) )
abline(h=0)
set.seed(123)
x <- sample(0:1, size=100, replace=TRUE)
RunsTest(x)
# As you would expect of values from a random number generator, the test fails to reject
# the null hypothesis that the data are random.
Run the code above in your browser using DataLab