1 |
x |
|
y |
|
q |
|
xlab |
|
ylab |
|
plotit |
|
SEED |
|
alpha |
|
nboot |
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 | ##---- 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, q = seq(5, 40, 5)/100, xlab = "Quantile",
ylab = "Group 1 minus Group 2", plotit = TRUE, SEED = TRUE,
alpha = 0.05, nboot = 1000)
{
x = as.matrix(x)
if (is.null(y))
dif = x
if (ncol(x) > 2)
stop("Should be at most two groups")
if (ncol(x) == 2)
dif = x[, 1] - x[, 2]
if (!is.null(y))
dif = x - y
dif = elimna(dif)
dif = as.matrix(dif)
nv = length(dif)
output = matrix(NA, ncol = 8, nrow = length(q))
dimnames(output) = list(NULL, c("quantile", "Est_q", "Est_1.minus.q",
"SUM", "ci.low", "ci.up", "p_crit", "p-value"))
for (i in 1:length(q)) {
test = DqdifMC(dif, q = q[i], plotit = FALSE, nboot = nboot,
SEED = SEED)
output[i, 1] = q[i]
output[i, 2] = test$est.q
output[i, 3] = test$est.1.minus.q
output[i, 8] = test$p.value
output[i, 5] = test$conf.interval[1]
output[i, 6] = test$conf.interval[2]
}
temp = order(output[, 8], decreasing = TRUE)
zvec = alpha/c(1:length(q))
output[temp, 7] = zvec
output <- data.frame(output)
output$signif = rep("YES", nrow(output))
for (i in 1:nrow(output)) {
if (output[temp[i], 8] > output[temp[i], 7])
output$signif[temp[i]] = "NO"
if (output[temp[i], 8] <= output[temp[i], 7])
break
}
output[, 4] = output[, 2] + output[, 3]
if (plotit) {
plot(rep(q, 3), c(output[, 4], output[, 5], output[,
6]), type = "n", xlab = xlab, ylab = ylab)
points(q, output[, 6], pch = "+")
points(q, output[, 5], pch = "+")
points(q, output[, 4], pch = "*")
}
list(n = nv, output = output)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.