spearman.test {pspearman} | R Documentation |
Spearman's rank correlation test with precomputed null distribution
Description
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
.
Usage
spearman.test(x, y,
alternative = c("two.sided", "less", "greater"),
approximation = c("exact", "AS89", "t-distribution"))
Arguments
x , y , alternative |
have the same meaning as in |
approximation |
selection of the method to approximate the null distribution |
Details
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.
Value
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.
Examples
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