1 |
x |
|
nboot |
|
alpha |
|
MC |
|
SEED |
|
g |
|
dp |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ##---- 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, nboot = 1000, alpha = 0.05, MC = FALSE, SEED = TRUE,
g = NULL, dp = NULL)
{
if (!is.null(g)) {
if (is.null(dp))
stop("Specify a value for dp, the column containing the data")
x = fac2list(x[, dp], x[, g])
}
if (SEED)
set.seed(2)
if (MC)
library(parallel)
if (is.data.frame(x))
x = as.matrix(x)
if (is.matrix(x))
x = listm(x)
chk = tlist(x)
if (chk != 0)
print("Warning: tied values detected. Suggest using cidmulv2")
J = length(x)
L = (J^2 - J)/2
CC = L
pvec = NA
boot = list()
MAT = matrix(NA, nrow = nboot, ncol = L)
for (i in 1:nboot) {
jcom = 0
for (j in 1:J) {
boot[[j]] = sample(x[[j]], size = length(x[[j]]),
replace = TRUE)
}
MAT[i, ] = wmwloc2(boot)
}
pvec = NA
test <- matrix(NA, CC, 8)
dimnames(test) <- list(NULL, c("Group", "Group", "p-value",
"p.crit", "P(X<Y)", "P(X=Y)", "P(X>Y)", "p.hat"))
dvec <- alpha/c(1:CC)
for (j in 1:J) {
for (k in 1:J) {
if (j < k) {
jcom = jcom + 1
p.value = mean(MAT[, jcom] > 0) + 0.5 * mean(MAT[,
jcom] == 0)
pvec[jcom] = 2 * min(c(p.value, 1 - p.value))
if (is.na(pvec[jcom]))
pvec = 1
test[jcom, 1] <- j
test[jcom, 2] <- k
test[jcom, 3] <- pvec[jcom]
test[jcom, 5:7] <- cid(x[[j]], x[[k]])$summary.dvals
test[jcom, 8] <- test[jcom, 5] + 0.5 * test[jcom,
6]
}
}
}
temp2 <- order(0 - test[, 3])
test[temp2, 4] = dvec
list(test = test)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.