1 |
x |
|
y |
|
q |
|
nboot |
|
plotit |
|
xlab |
|
SEED |
|
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 = NULL, q = 0.25, nboot = 1000, plotit = TRUE,
xlab = "Group 1 - Group 2", SEED = TRUE, alpha = 0.05)
{
library(parallel)
if (SEED)
set.seed(2)
if (q >= 0.5)
stop("q should be less than .5")
if (!is.null(y)) {
xy = elimna(cbind(x, y))
dif = xy[, 1] - xy[, 2]
}
if (is.null(y))
dif = elimna(x)
x = as.matrix(x)
n = length(dif)
if (plotit)
akerd(dif, xlab = xlab)
bvec = NA
data <- matrix(sample(n, size = n * nboot, replace = TRUE),
nrow = nboot)
data = listm(t(data))
bvec <- mclapply(data, difQMC_sub, dif, q, mc.preschedule = TRUE)
bvec = matl(bvec)
est1 = hd(dif, q = q)
est2 = hd(dif, q = 1 - q)
pv = mean(bvec < 0) + 0.5 * mean(bvec == 0)
p = 2 * min(c(pv, 1 - pv))
low <- round((alpha/2) * nboot) + 1
up <- nboot - low
sbvec = sort(bvec)
ci = sbvec[low]
ci[2] = sbvec[up]
list(est.q = est1, est.1.minus.q = est2, conf.interval = ci,
p.value = p)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.