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.

infer_runs_test(data, x, drop = FALSE, split = FALSE, mean = FALSE, threshold = NA)

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. |

`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:

number of observations

within group sum of squares

number below the threshold

number above the threshold

expected number of runs

variance of the number of runs

number of runs

z statistic

p-value of `z`

`runs_test()`

has been deprecated. Instead use `infer_runs_test()`

.

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.

infer_runs_test(hsb, read)#> Runs Test #> Total Cases: 200 #> Test Value : 50 #> Cases < Test Value: 101 #> Cases > Test Value: 99 #> Number of Runs: 95 #> Expected Runs: 100.99 #> Variance (Runs): 49.73874 #> z Statistic: -0.8493358 #> p-value: 0.3956945infer_runs_test(hsb, read, drop = TRUE)#> Runs Test #> Total Cases: 200 #> Test Value : 50 #> Cases < Test Value: 83 #> Cases > Test Value: 99 #> Number of Runs: 89 #> Expected Runs: 91.2967 #> Variance (Runs): 44.54805 #> z Statistic: -0.3441046 #> p-value: 0.7307676infer_runs_test(hsb, read, split = TRUE)#> Runs Test #> Total Cases: 200 #> Test Value : 50 #> Cases < Test Value: 101 #> Cases > Test Value: 99 #> Number of Runs: 95 #> Expected Runs: 100.99 #> Variance (Runs): 49.73874 #> z Statistic: -0.8493358 #> p-value: 0.3956945infer_runs_test(hsb, read, mean = TRUE)#> Runs Test #> Total Cases: 200 #> Test Value : 52.23 #> Cases < Test Value: 115 #> Cases > Test Value: 85 #> Number of Runs: 93 #> Expected Runs: 98.75 #> Variance (Runs): 47.52418 #> z Statistic: -0.8340854 #> p-value: 0.4042329infer_runs_test(hsb, read, threshold = 0)#> Runs Test #> Total Cases: 200 #> Test Value : 0 #> Cases < Test Value: 0 #> Cases > Test Value: 200 #> Number of Runs: 1 #> Expected Runs: 1 #> Variance (Runs): 0 #> z Statistic: NaN #> p-value: NaN