randomizeBE (version 0.3-5)

pruns.exact: Exact cumulative distribution function of runs test

Description

This function calculates the exact cumulative conditional distribution of the Wald-Wolfowitz runs.

Usage

pruns.exact(r, n1, n2, tail = c("2-sided", "lower", "upper"))

Value

Numeric value of the cumulative distribution function according to the chosen tail.

Arguments

r

Number of runs observed.

n1

Number of +1 items in the sequence.

n2

Number of -1 items in the sequence.

tail

Tail of the cumulative distribution function.
Default is the 2-tailed value.

Author

D. Labes

Examples

Run this code
# SPSS "Exact Tests": small sample example, exact p:  0.071
# x <- c(1, 1, 1, 1, 0, 0, 0, 0, 1, 1)  
pruns.exact(r=3, n1=4, n2=6)
# 0.07142857
# left tail P(R<=3)=0.04761905
pruns.exact(r=3, n1=4, n2=6, tail="lower")
# right tail P(R>=3)=0.9904762
pruns.exact(r=3, n1=4, n2=6, tail="upper")
# or via runs.pvalue (2-sided)
x <- c(1, 1, 1, 1, 0, 0, 0, 0, 1, 1)  
runs.pvalue(x, pmethod="ex")

Run the code above in your browser using DataLab