1 |
x |
|
y |
|
pool |
|
jcen |
|
fr |
|
depfun |
|
nmin |
|
op |
|
tr |
|
SEED |
|
pr |
|
pts |
|
con |
|
nboot |
|
alpha |
|
bhop |
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | ##---- 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, pool = TRUE, jcen = 1, fr = 1, depfun = fdepth,
nmin = 8, op = 3, tr = 0.2, SEED = TRUE, pr = TRUE, pts = NA,
con = 0, nboot = NA, alpha = 0.05, bhop = FALSE)
{
if (SEED)
set.seed(2)
if (pr) {
if (op == 1)
print("Trimmed means are to be compared. For medians, use op=2")
if (op == 2)
print("Medians are to be compared. For trimmed means, use op=1")
if (op == 3)
print("20% trimmed means are compared. For medians, use op=4")
if (op == 4)
print("medians are compared. For 20% trimmed means, use op=3")
}
output <- NULL
conout = NULL
nval <- NA
if (is.matrix(y))
J <- ncol(y)
if (is.matrix(x))
pval = ncol(x)
if (is.list(y))
J <- length(y)
if (is.list(x))
pval <- ncol(as.matrix(x[[1]]))
if (pval > 1)
stop("More than one covariate. Use ancmg")
if (J == 1)
stop("Only have one group stored in y")
if (is.matrix(x)) {
if (ncol(x)%%J != 0)
stop("Number of columns of x should be a multiple of ncol(y)")
}
if (is.matrix(x)) {
xcen <- x[, jcen]
}
if (is.list(x))
xcen <- x[[jcen]]
if (is.na(pts[1])) {
if (pool) {
if (is.matrix(x))
xval <- stackit(x, 1)
if (is.list(x))
xval <- stacklist(x)
temp <- idealf(xval)
pts <- temp$ql
pts[2] <- median(xval)
pts[3] <- temp$qu
}
if (!pool) {
temp <- idealf(xcen)
pts <- temp$ql
pts[2] <- median(xval)
pts[3] <- temp$qu
}
}
nval <- matrix(NA, ncol = J, nrow = length(pts))
for (j in 1:J) {
for (i in 1:length(pts)) {
if (is.matrix(x) && is.matrix(y)) {
nval[i, j] <- length(y[near(x[, j], pts[i], fr = fr)])
}
if (is.matrix(x) && is.list(y)) {
tempy <- y[[j]]
nval[i, j] <- length(tempy[near(x[, j], pts[i],
fr = fr)])
}
if (is.list(x) && is.matrix(y)) {
xm <- as.matrix(x[[j]])
nval[i, j] <- length(y[near(xm, pts[i], fr = fr),
j])
}
if (is.list(x) && is.list(y)) {
tempy <- y[[j]]
xm <- as.matrix(x[[j]])
nval[i, j] <- length(tempy[near(xm, pts[i], fr = fr)])
}
}
}
flag <- rep(TRUE, length(pts))
for (i in 1:length(pts)) {
if (min(nval[i, ]) < nmin)
flag[i] <- F
}
nflag <- F
if (sum(flag) == 0) {
print("Warning: No design points found with large enough sample size")
nflag <- T
}
if (!nflag) {
pts <- pts[flag]
nval <- nval[flag, ]
if (!is.matrix(pts))
pts <- t(as.matrix(pts))
output <- matrix(NA, nrow = length(pts), ncol = 3)
dimnames(output) <- list(NULL, c("point", "test.stat",
"p-value"))
if (op == 3 || op == 4)
output <- list()
}
for (i in 1:length(pts)) {
if (op == 1 || op == 2)
output[i, 1] <- i
icl <- 0 - pval + 1
icu <- 0
yval <- list()
for (j in 1:J) {
if (is.matrix(x) && is.matrix(y)) {
yval[[j]] <- y[near(x[, j], pts[i], fr = fr),
j]
}
if (is.matrix(x) && is.list(y)) {
tempy <- y[[j]]
yval[[j]] <- tempy[near(x[, j], pts[i], fr = fr)]
}
if (is.list(x) && is.matrix(y)) {
yval[[j]] <- y[near3d(x[[j]], pts[i], fr = fr),
j]
}
if (is.list(x) && is.list(y)) {
tempy <- y[[j]]
yval[[j]] <- tempy[near(x[[j]], pts[i], fr = fr)]
}
}
if (op == 1)
temp <- t1way(yval, tr = tr)
if (op == 2)
temp <- med1way(yval, SEED = SEED, pr = FALSE)
if (op == 1 || op == 2) {
output[i, 2] <- temp$TEST
output[i, 3] <- temp$p.value
}
if (op == 3) {
output[[i]] <- linconpb(yval, alpha = alpha, SEED = SEED,
con = con, bhop = bhop, est = tmean, nboot = nboot)
}
if (op == 4) {
output[[i]] <- medpb(yval, alpha = alpha, SEED = SEED,
con = con, bhop = bhop, nboot = nboot)
}
}
if (op == 1 || op == 2)
tempout = output
if (nflag)
output <- NULL
if (op == 3 || op == 4) {
conout = list()
tempout = list()
for (j in 1:length(output)) tempout[[j]] = output[[j]]$output
for (j in 1:length(output)) conout[[j]] = output[[j]]$con
}
list(points.chosen = pts, sample.sizes = nval, point = tempout,
contrast.coef = conout[[1]])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.