t1waybt:

Usage Arguments Examples

Usage

1
t1waybt(x, tr = 0.2, grp = NA, nboot = 599, SEED = TRUE)

Arguments

x
tr
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
##---- 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, tr = 0.2, grp = NA, nboot = 599, SEED = TRUE) 
{
    if (is.matrix(x) || is.data.frame(x)) 
        x <- listm(x)
    if (!is.list(x)) 
        stop("Data must be stored in a matrix or in list mode.")
    if (!is.na(grp[1])) 
        J = length(grp)
    if (is.na(grp[1])) {
        J <- length(x)
        grp <- c(1:J)
    }
    for (j in 1:J) {
        temp <- x[[j]]
        x[[j]] <- temp[!is.na(temp)]
    }
    bvec <- array(0, c(J, 2, nboot))
    hval <- vector("numeric", J)
    if (SEED) 
        set.seed(2)
    for (j in 1:J) {
        hval[j] <- length(x[[grp[j]]]) - 2 * floor(tr * length(x[[grp[j]]]))
        xcen <- x[[grp[j]]] - mean(x[[grp[j]]], tr)
        data <- matrix(sample(xcen, size = length(x[[grp[j]]]) * 
            nboot, replace = TRUE), nrow = nboot)
        bvec[j, , ] <- apply(data, 1, trimparts, tr)
    }
    m1 <- bvec[, 1, ]
    m2 <- bvec[, 2, ]
    wvec <- 1/m2
    uval <- apply(wvec, 2, sum)
    blob <- wvec * m1
    xtil <- apply(blob, 2, sum)/uval
    blob1 <- matrix(0, J, nboot)
    for (j in 1:J) blob1[j, ] <- wvec[j, ] * (m1[j, ] - xtil)^2
    avec <- apply(blob1, 2, sum)/(length(x) - 1)
    blob2 <- (1 - wvec/uval)^2/(hval - 1)
    cvec <- apply(blob2, 2, sum)
    cvec <- 2 * (length(x) - 2) * cvec/(length(x)^2 - 1)
    testb <- avec/(cvec + 1)
    ct <- sum(is.na(testb))
    if (ct > 0) {
        print("Some bootstrap estimates of the test statistic could not be computed")
        print("Effective number of bootstrap samples was")
        print(sum(!is.na(testb)))
    }
    test <- t1wayv2(x, tr = tr, grp = grp)
    pval <- mean(test$TEST <= testb, na.rm = TRUE)
    list(test = test$TEST, p.value = pval, Var.Explained = test$Var.Explained, 
        Effect.Size = test$Effect.Size)
  }

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