bwtrimbt:

Usage Arguments Examples

Usage

1
bwtrimbt(J, K, x, tr = 0.2, JK = J * K, grp = c(1:JK), nboot = 599, SEED = TRUE)

Arguments

J
K
x
tr
JK
grp
nboot
SEED

Examples

 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
##---- 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, tr = 0.2, JK = J * K, grp = c(1:JK), nboot = 599, 
    SEED = TRUE) 
{
    if (SEED) 
        set.seed(2)
    if (is.data.frame(x) || is.matrix(x)) {
        y <- list()
        ik = 0
        il = c(1:K) - K
        for (j in 1:J) {
            il = il + K
            zz = x[, il]
            zz = elimna(zz)
            for (k in 1:K) {
                ik = ik + 1
                y[[ik]] = zz[, k]
            }
        }
        x <- y
    }
    JK <- J * K
    data <- list()
    xcen <- list()
    for (j in 1:length(x)) {
        data[[j]] <- x[[grp[j]]]
        xcen[[j]] <- data[[j]] - mean(data[[j]], tr)
    }
    x <- data
    set.seed(2)
    nvec <- NA
    jp <- 1 - K
    for (j in 1:J) {
        jp <- jp + K
        nvec[j] <- length(x[[j]])
    }
    blist <- list()
    print("Taking bootstrap samples. Please wait.")
    testmat <- matrix(NA, ncol = 3, nrow = nboot)
    for (iboot in 1:nboot) {
        iv <- 0
        for (j in 1:J) {
            temp <- sample(nvec[j], replace = T)
            for (k in 1:K) {
                iv <- iv + 1
                tempx <- xcen[[iv]]
                blist[[iv]] <- tempx[temp]
            }
        }
        btest <- tsplit(J, K, blist, tr)
        testmat[iboot, 1] <- btest$Qa
        testmat[iboot, 2] <- btest$Qb
        testmat[iboot, 3] <- btest$Qab
    }
    test = tsplit(J, K, x, tr = tr)
    pbA = mean(test$Qa[1] < testmat[, 1])
    pbB = mean(test$Qb[1] < testmat[, 2])
    pbAB = mean(test$Qab[1] < testmat[, 3])
    list(p.value.A = pbA, p.value.B = pbB, p.value.AB = pbAB)
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.