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

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

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

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

The 2-sided exact p-value is defined as P(abs(R-E(R)>=abs(r-E(R)).

The lower (left) tail p-value is defined as P(R<=r).

The upper (right) tail p-value is defined as P(R>=r).

r is the observed value of the random variable R.

D. Labes

1 2 3 4 5 6 7 8 9 10 11 | ```
# 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")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.