This function is a modification of the part of the function `cor.test()`

, which
evaluates Spearman's rank correlation test. Besides the two approximations
used in `cor.test(,method="spearman")`

, which are AS89 and the t-distribution,
this function allows to use precomputed null distribution for `n <= 22`

.

1 2 3 | ```
spearman.test(x, y,
alternative = c("two.sided", "less", "greater"),
approximation = c("exact", "AS89", "t-distribution"))
``` |

`x, y, alternative` |
have the same meaning as in |

`approximation` |
selection of the method to approximate the null distribution |

Calculation of the exact null distribution of Spearman's rank correlation statistics
is exponentially hard in `n`

. This package uses precomputed exact distribution
for `n <= 22`

obtained using Ryser's formula applied to an appropriate monomial
permanent as described in
M.A. van de Wiel and A. Di Bucchianico,
Fast computation of the exact null distribution of Spearman's rho and Page's L statistic
for samples with and without ties, J. Stat. Plann. Inf. 92 (2001), pp. 133-145.
using code written by the author of the package. The resulting distributions are
identical to those computed by an independent program kindly provided by M.A. van de Wiel.

A list with class `"htest"`

with the same structure as the value
of the function `cor.test(method="spearman")`

. Except of the
p-value, also the contents is identical.

1 2 3 4 5 6 7 8 | ```
x <- 1:10
y <- c(5:1, 6, 10:7)
out1 <- spearman.test(x, y)
out2 <- spearman.test(x, y, approximation="AS89")
out3 <- cor.test(x, y, method="spearman")
out1$p.value # [1] 0.05443067 this is the exact value
out2$p.value # [1] 0.05444507 approximation obtained from AS89
out3$p.value # [1] 0.05444507 ditto
``` |

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.