1 |
x |
|
y |
|
alpha |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, y = NULL, alpha = 0.05)
{
if (is.null(y))
m = elimna(x)
if (!is.null(y))
m = elimna(cbind(x, y))
x = m[, 1]
y = m[, 2]
xdif <- outer(x, x, FUN = "-")
ydif <- outer(y, y, FUN = "-")
tv <- sign(xdif) * sign(ydif)
dbar <- apply(tv, 1, mean)
n <- length(x)
tau <- sum(tv)/(n * (n - 1))
A <- sum((dbar - tau)^2)/(n - 1)
B <- (n * (n - 1) * (-1) * tau^2 + sum(tv^2))/(n^2 - n -
1)
C <- (4 * (n - 2) * A + 2 * B)/(n * (n - 1))
crit <- qnorm(alpha/2)
cilow <- tau + crit * sqrt(C)
cihi <- tau - crit * sqrt(C)
test <- tau/sqrt((2 * (2 * n + 5))/(9 * n * (n - 1)))
siglevel <- 2 * (1 - pnorm(abs(test)))
list(cor = tau, ci = c(cilow, cihi), p.value = siglevel)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.