1 | mee(x, y, alpha = 0.05)
|
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 31 32 33 34 35 36 37 38 39 40 41 | ##---- 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, alpha = 0.05)
{
x <- x[!is.na(x)]
y <- y[!is.na(y)]
xy <- c(x, y)
tiexy <- sum(abs(c(1:length(xy)) - sort(rank(xy))))
if (tiexy > 0) {
print("Warning: Tied values detected")
print("so even if distributions are identical,")
print("P(X<Y) is not necessarily equal to .5")
}
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))
p1 <- p1/(length(x) * length(y) * (length(x) - 1))
p2 <- p2/(length(x) * length(y) * (length(y) - 1))
b1 <- (p1 - p^2)/(p - p^2)
b2 <- (p2 - p^2)/(p - p^2)
A <- ((length(x) - 1) * b1 + 1)/(1 - 1/length(y)) + ((length(y) -
1) * b2 + 1)/(1 - 1/length(x))
nhat <- length(x) * length(y)/A
crit <- (qnorm(1 - alpha/2))^2/nhat
D <- sqrt(crit * (p * (1 - p) + 0.25 * crit))
low <- (p + 0.5 * crit - D)/(1 + crit)
hi <- (p + 0.5 * crit + D)/(1 + crit)
list(phat = p, ci = c(low, hi))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.