1 |
J |
|
K |
|
x |
|
est |
|
JK |
|
con |
|
alpha |
|
grp |
|
nboot |
|
bhop |
|
SEED |
|
... |
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 | ##---- 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 (J, K, x, est = tmean, JK = J * K, con = 0, alpha = 0.05,
grp = c(1:JK), nboot = 500, bhop = TRUE, SEED = TRUE, ...)
{
if (is.matrix(x)) {
y <- list()
for (j in 1:ncol(x)) y[[j]] <- x[, j]
x = y
}
nvec <- NA
for (j in 1:length(x)) nvec[j] = length(x[[j]])
nmax = max(nvec)
ncon = ncol(con)
p <- J * K
v <- matrix(0, p, p)
data <- list()
xx = list()
for (j in 1:length(x)) {
xx[[j]] = x[[grp[j]]]
}
ilow = 0 - K
iup = 0
for (j in 1:J) {
ilow <- ilow + K
iup = iup + K
sel <- c(ilow:iup)
xx[sel] = listm(elimna(matl(xx[sel])))
}
jp <- 1 - K
kv <- 0
if (SEED)
set.seed(2)
testA = NA
bsam = list()
bdat = list()
aboot = matrix(NA, nrow = nboot, ncol = ncol(con))
tvec = NA
tvec = linhat(x, con, est = est, ...)
for (ib in 1:nboot) {
ilow <- 1 - K
iup = 0
for (j in 1:J) {
ilow <- ilow + K
iup = iup + K
nv = length(x[[ilow]])
bdat[[j]] = sample(nv, size = nv, replace = T)
for (k in ilow:iup) {
bsam[[k]] = x[[k]][bdat[[j]]]
}
}
ilow = 0 - K
iup = 0
aboot[ib, ] = linhat(bsam, con = con, est = est, ...)
}
pbA = NA
for (j in 1:ncol(aboot)) {
pbA[j] = mean(aboot[, j] > 0)
pbA[j] = 2 * min(c(pbA[j], 1 - pbA[j]))
}
if (!bhop)
dvec = alpha/c(1:ncol(con))
if (bhop)
dvec <- (ncol(con) - c(1:ncol(con)) + 1) * alpha/ncol(con)
outputA <- matrix(0, ncol(con), 6)
dimnames(outputA) <- list(NULL, c("con.num", "psihat", "p.value",
"p.crit", "ci.lower", "ci.upper"))
test = pbA
temp2 <- order(0 - test)
zvec <- dvec[1:ncon]
sigvec <- (test[temp2] >= zvec)
outputA[temp2, 4] <- zvec
icl <- round(dvec[ncon] * nboot/2) + 1
icu <- nboot - icl - 1
outputA[, 2] <- tvec
for (ic in 1:ncol(con)) {
outputA[ic, 1] <- ic
outputA[ic, 3] <- test[ic]
temp <- sort(aboot[, ic])
outputA[ic, 5] <- temp[icl]
outputA[ic, 6] <- temp[icu]
}
outputA
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.