1 |
x |
|
y |
|
q |
|
xlab |
|
ylab |
|
plotit |
|
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 | ##---- 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, q = seq(5, 40, 5)/100, xlab = "Quantile", ylab = "Sum of q and 1-q Quantiles",
plotit = TRUE, alpha = 0.05, nboot = 1000)
{
x = elimna(x)
y = elimna(y)
n1 = length(x)
n2 = length(y)
output = matrix(NA, ncol = 8, nrow = length(q))
dimnames(output) = list(NULL, c("quantile", "Est.1", "Est.2",
"SUM", "ci.low", "ci.up", "p_crit", "p-value"))
for (i in 1:length(q)) {
test = cbmhd(x, y, q = q[i], plotit = FALSE, nboot = nboot)
output[i, 1] = q[i]
output[i, 2] = test$Est1
output[i, 3] = test$Est2
output[i, 4] = test$sum
output[i, 8] = test$p.value
output[i, 5] = test$ci[1]
output[i, 6] = test$ci[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
}
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 = c(n1, n2), output = output)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.