1 |
J |
|
K |
|
L |
|
x |
|
est |
|
JKL |
|
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 88 | ##---- 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, L, x, est = tmean, JKL = J * K * L, con = 0,
alpha = 0.05, grp = c(1:JKL), nboot = 500, bhop = FALSE,
SEED = TRUE, ...)
{
if (is.matrix(x)) {
y <- list()
for (j in 1:ncol(x)) y[[j]] <- x[, j]
x = y
}
ncon = ncol(con)
p <- J * K * L
if (p > length(x))
stop("JKL is less than the Number of groups")
JK = J * K
KL = K * L
data <- list()
xx = list()
for (j in 1:length(x)) {
xx[[j]] = x[[grp[j]]]
}
ilow = 1 - L
iup = 0
for (j in 1:JK) {
ilow <- ilow + L
iup = iup + L
sel <- c(ilow:iup)
xx[sel] = listm(elimna(matl(xx[sel])))
}
jp <- 1 - L
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 - L
iup = 0
for (j in 1:JK) {
ilow <- ilow + L
iup = iup + L
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 - L
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.