tsplitbt:

Usage Arguments Examples

Usage

1
tsplitbt(J, K, x, tr = 0.2, alpha = 0.05, JK = J * K, grp = c(1:JK), nboot = 599, SEED = TRUE, monitor = FALSE)

Arguments

J
K
x
tr
alpha
JK
grp
nboot
SEED
monitor

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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
##---- 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, alpha = 0.05, JK = J * K, grp = c(1:JK), 
    nboot = 599, SEED = TRUE, monitor = FALSE) 
{
    if (SEED) 
        set.seed(2)
    if (is.data.frame(x)) 
        x = as.matrix(x)
    if (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]])
    }
    if (min(nvec) < 10) {
        print("Warning: with small sample sizes, a bootstrap-t method can")
        print("result in estimated variances equal to zero, resulting in")
        print("this function terminating and giving no results and peculiar error messages.")
    }
    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]
            }
        }
        if (monitor) 
            print(paste("Bootstrap iteration", iboot, "is complete"))
        btest <- tsplit(J, K, blist, tr)
        testmat[iboot, 1] <- btest$Qa
        testmat[iboot, 2] <- btest$Qb
        testmat[iboot, 3] <- btest$Qab
    }
    lcrit <- round((1 - alpha) * nboot)
    temp3 <- sort(testmat[, 1])
    crit.Qa <- temp3[lcrit]
    temp3 <- sort(testmat[, 2])
    crit.Qb <- temp3[lcrit]
    temp3 <- sort(testmat[, 3])
    crit.Qab <- temp3[lcrit]
    temp4 <- tsplit(J, K, x, tr = tr)
    list(Qa = temp4$Qa, Qb = temp4$Qb, Qab = temp4$Qab, crit.Qa = crit.Qa, 
        crit.Qb = crit.Qb, crit.Qab = crit.Qab)
  }

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