1 |
x |
|
nboot |
|
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 | ##---- 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, nboot = 500, SEED = TRUE)
{
if (is.matrix(x) || is.data.frame(x))
x = listm(x)
library(mc2d)
if (SEED)
set.seed(2)
vals = lapply(x, unique)
vals = sort(elimna(list2vec(vals)))
K = length(unique(vals))
n = lapply(x, length)
n = list2vec(n)
J = length(x)
step1 = discANOVA.sub(x)
test = step1$test
C1 = step1$C1
HT = NULL
for (i in 1:K) HT[i] = mean(C1[i, ])
tv = NULL
TB = NA
VP = NA
B1hat = NA
xx = list()
for (ib in 1:nboot) {
xx = list()
for (j in 1:J) {
temp = rmultinomial(n[j], 1, HT)
xx[[j]] = which(temp[1, ] == 1)
for (i in 2:n[j]) xx[[j]][i] = which(temp[i, ] ==
1)
}
TB[ib] = discANOVA.sub(xx)$test
}
pv = 1 - mean(test > TB) - 0.5 * mean(test == TB)
list(test = test, p.value = pv)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.