1 | rankisub(x, y)
|
x |
|
y |
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 31 32 33 34 | ##---- 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)
{
x <- x[!is.na(x)]
y <- y[!is.na(y)]
u <- outer(x, y, FUN = "<")
p1 <- 0
p2 <- 0
for (j in 1:length(y)) {
temp <- outer(u[, j], u[, j])
p1 <- p1 + sum(temp) - sum(u[, j] * u[, j])
}
for (i in 1:length(x)) {
temp <- outer(u[i, ], u[i, ])
p2 <- p2 + sum(temp) - sum(u[i, ] * u[i, ])
}
p <- sum(u)/(length(x) * length(y))
pad <- p
if (p == 0)
pad <- 0.5/(length(x) * length(y))
if (p == 1)
pad <- (1 - 0.5)/(length(x) * length(y))
p1 <- p1/(length(x) * length(y) * (length(x) - 1))
p2 <- p2/(length(x) * length(y) * (length(y) - 1))
var <- pad * (1 - pad) * (((length(x) - 1) * (p1 - p^2)/(pad *
(1 - pad)) + 1)/(1 - 1/length(y)) + ((length(y) - 1) *
(p2 - p^2)/(pad * (1 - pad)) + 1)/(1 - 1/length(x)))
var <- var/(length(x) * length(y))
list(phat = p, sqse = var)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.