1 |
xy |
|
x1 |
|
y1 |
|
x2 |
|
y2 |
|
fr1 |
|
fr2 |
|
est |
|
alpha |
|
plotit |
|
pts |
|
qvals |
|
sm |
|
xout |
|
outfun |
|
DIF |
|
LP |
|
nboot |
|
SEED |
|
nmin |
|
MC |
|
... |
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 70 71 72 73 74 75 76 77 78 79 80 81 82 | ##---- 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 (xy = NULL, x1 = NULL, y1 = NULL, x2 = NULL, y2 = NULL,
fr1 = 1, fr2 = 1, est = tmean, alpha = 0.05, plotit = TRUE,
pts = NULL, qvals = c(0.25, 0.5, 0.75), sm = FALSE, xout = FALSE,
outfun = out, DIF = FALSE, LP = TRUE, nboot = 500, SEED = TRUE,
nmin = 12, MC = FALSE, ...)
{
if (!is.null(x1[1])) {
if (ncol(as.matrix(x1)) > 1)
stop("One covariate only is allowed with this function")
if (length(x1) != length(y1))
stop("x1 and y1 have different lengths")
if (length(x1) != length(x2))
stop("x1 and y2 have different lengths")
if (length(x2) != length(y2))
stop("x2 and y2 have different lengths")
if (length(y1) != length(y2))
stop("y1 and y2 have different lengths")
xy = elimna(cbind(x1, y1, x2, y2))
}
if (is.null(pts)) {
for (i in 1:length(qvals)) pts = c(pts, qest(xy[, 1],
qvals[i]))
}
if (SEED)
set.seed(2)
n = nrow(xy)
est1 = NA
est2 = NA
J = length(pts)
est1 = matrix(NA, nrow = nboot, ncol = J)
est2 = matrix(NA, nrow = nboot, ncol = J)
data = matrix(sample(n, size = n * nboot, replace = TRUE),
ncol = nboot, nrow = n)
if (!MC) {
est1 = apply(data, 2, DancGLOB_sub, xy = xy[, 1:2], pts = pts,
est = est, fr = fr1, nmin = nmin, ...)
est2 = apply(data, 2, DancGLOB_sub, xy = xy[, 3:4], pts = pts,
est = est, fr = fr2, nmin = nmin, ...)
est1 = t(as.matrix(est1))
est2 = t(as.matrix(est2))
}
if (MC) {
library(parallel)
data = listm(data)
est1 = mclapply(data, DancGLOB_sub, xy = xy[, 1:2], pts = pts,
est = est, fr = fr1, nmin = nmin, ...)
est2 = mclapply(data, DancGLOB_sub, xy = xy[, 3:4], pts = pts,
est = est, fr = fr2, nmin = nmin, ...)
est1 = t(matl(est1))
est2 = t(matl(est2))
}
e1 = runhat(xy[, 1], xy[, 2], pts = pts, est = est, fr = fr1,
...)
e2 = runhat(xy[, 3], xy[, 4], pts = pts, est = est, fr = fr2,
...)
dif = e1 - e2
pv = NA
for (j in 1:J) {
pv[j] = mean(est1[, j] < est2[, j], na.rm = TRUE) + 0.5 *
mean(est1[, j] == est2[, j], na.rm = TRUE)
pv[j] = 2 * min(c(pv[j], 1 - pv[j]))
}
if (plotit) {
if (xout) {
flag <- outfun(x1, ...)$keep
x1 <- x1[flag]
y1 <- y1[flag]
flag <- outfun(x2, ...)$keep
x2 <- x2[flag]
y2 <- y2[flag]
}
runmean2g(xy[, 1], xy[, 2], xy[, 3], xy[, 4], fr = fr1,
est = tmean, sm = sm, xout = FALSE, ...)
}
pv = min(pv)
pv
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.