# Exact cumulative distribution function of runs test

### Description

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

### Usage

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

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

### Value

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

### Note

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.

### Author(s)

D. Labes

### Examples

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")
``` |