1 |
x |
|
y |
|
nboot |
|
alpha |
|
pr |
|
SEED |
|
plotit |
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 | ##---- 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 = NA, nboot = 500, alpha = 0.05, pr = FALSE, SEED = TRUE,
plotit = TRUE)
{
if (SEED)
set.seed(2)
if (is.na(y[1])) {
y <- x[, 2]
x <- x[, 1]
}
xy = elimna(cbind(x, y))
x = xy[, 1]
y = xy[, 2]
if (sum(duplicated(x)) > 0)
stop("Tied values detected, use Dqcomhd")
if (sum(duplicated(y)) > 0)
stop("Tied values detected, use Dqcomhd")
bvec <- matrix(NA, nrow = nboot, ncol = 9)
if (pr)
print("Taking bootstrap samples. Please Wait.")
data <- matrix(sample(n, size = n * nboot, replace = TRUE),
nrow = nboot)
for (i in 1:nboot) bvec[i, ] <- qdec(x[data[i, ]]) - qdec(y[data[i,
]])
pval <- NA
m <- matrix(0, 9, 5)
dimnames(m) <- list(NULL, c("lower", "upper", "Delta.hat",
"p.values", "p.crit"))
crit <- alpha/2
icl <- round(crit * nboot) + 1
icu <- nboot - icl
for (i in 1:9) {
pval[i] <- (sum(bvec[, i] < 0) + 0.5 * sum(bvec[, i] ==
0))/nboot
pval[i] <- 2 * min(pval[i], 1 - pval[i])
temp <- sort(bvec[, i])
m[i, 1] <- temp[icl]
m[i, 2] <- temp[icu]
}
m[, 3] <- qdec(x) - qdec(y)
m[, 4] <- pval
temp = order(pval, decreasing = TRUE)
zvec = alpha/c(1:9)
m[temp, 5] = zvec
if (plotit) {
xaxis <- c(qdec(x), qdec(x))
par(pch = "+")
yaxis <- c(m[, 1], m[, 2])
plot(xaxis, yaxis, ylab = "delta", xlab = "x (first group)")
par(pch = "*")
points(qdec(x), m[, 3])
}
m
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.