1 |
x1 |
|
y1 |
|
x2 |
|
y2 |
|
crit.mat |
|
nboot |
|
SEED |
|
REP.CRIT |
|
qval |
|
q |
|
xlab |
|
ylab |
|
plotit |
|
pr |
|
xout |
|
outfun |
|
... |
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 66 67 68 69 | ##---- 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 (x1, y1, x2, y2, crit.mat = NULL, nboot = 200, SEED = TRUE,
REP.CRIT = FALSE, qval = 0.5, q = NULL, xlab = "X", ylab = "Y",
plotit = TRUE, pr = TRUE, xout = FALSE, outfun = out, ...)
{
if (ncol(as.matrix(x1)) > 1)
stop("One covariate only is allowed")
if (!is.null(q))
qval = q
if (xout) {
flag1 = outfun(x1)$keep
flag2 = outfun(x2)$keep
x1 = x1[flag1]
y1 = y1[flag1]
x2 = x2[flag2]
y2 = y2[flag2]
}
if (SEED)
set.seed(2)
xy = elimna(cbind(x1, y1))
x1 = xy[, 1]
xord = order(x1)
x1 = x1[xord]
y1 = xy[xord, 2]
xy = elimna(cbind(x2, y2))
x2 = xy[, 1]
xord = order(x2)
x2 = x2[xord]
y2 = xy[xord, 2]
n1 = length(y1)
n2 = length(y2)
if (is.null(crit.mat[1])) {
if (pr)
print("Determining critical value. This might take a while")
crit.val = NA
yall = c(y1, y2)
xall = c(x1, x2)
nn = n1 + n2
il = n1 + 1
for (i in 1:nboot) {
data = sample(nn, nn, T)
yy1 = yall[data[1:n1]]
yy2 = yall[data[il:nn]]
xx1 = xall[data[1:n1]]
xx2 = xall[data[il:nn]]
crit.mat[i] = Qdepthcom(xx1, yy1, xx2, yy2, qval = qval)
}
}
dep = Qdepthcom(x1, y1, x2, y2, qval = qval)
pv = 1 - mean(crit.mat < dep)
if (!REP.CRIT)
crit.mat = NULL
if (plotit) {
plot(c(x1, x2), c(y1, y2), type = "n", xlab = xlab, ylab = ylab)
temp1 = cobs(x1, y1, print.mesg = FALSE, print.warn = FALSE,
tau = qval)
temp2 = cobs(x2, y2, print.mesg = FALSE, print.warn = FALSE,
tau = qval)
points(x1, y1)
points(x2, y2, pch = "+")
lines(x1, temp1$fitted)
lines(x2, temp2$fitted, lty = 2)
}
list(p.value = pv, crit.mat = crit.mat, test.depth = dep)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.