linconb:

Usage Arguments Examples

Usage

1
linconb(x, con = 0, tr = 0.2, alpha = 0.05, nboot = 599, pr = TRUE, SEED = TRUE)

Arguments

x
con
tr
alpha
nboot
pr
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##---- 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, con = 0, tr = 0.2, alpha = 0.05, nboot = 599, pr = TRUE, 
    SEED = TRUE) 
{
    if (is.data.frame(x)) 
        x = as.matrix(x)
    if (pr) {
        print("Note: confidence intervals are adjusted to control FWE")
        print("But p-values are not adjusted to control FWE")
    }
    con <- as.matrix(con)
    if (is.matrix(x)) 
        x <- listm(x)
    if (!is.list(x)) 
        stop("Data must be stored in a matrix or in list mode.")
    J <- length(x)
    for (j in 1:J) {
        xx <- x[[j]]
        x[[j]] <- xx[!is.na(xx)]
    }
    Jm <- J - 1
    d <- (J^2 - J)/2
    if (sum(con^2) == 0) {
        con <- matrix(0, J, d)
        id <- 0
        for (j in 1:Jm) {
            jp <- j + 1
            for (k in jp:J) {
                id <- id + 1
                con[j, id] <- 1
                con[k, id] <- 0 - 1
            }
        }
    }
    if (nrow(con) != length(x)) 
        stop("The number of groups does not match the number of contrast coefficients.")
    bvec <- array(0, c(J, 2, nboot))
    if (SEED) 
        set.seed(2)
    if (pr) 
        print("Taking bootstrap samples. Please wait.")
    nsam = matl(lapply(x, length))
    for (j in 1:J) {
        paste("Working on group ", j)
        xcen <- x[[j]] - mean(x[[j]], tr)
        data <- matrix(sample(xcen, size = length(x[[j]]) * nboot, 
            replace = TRUE), nrow = nboot)
        bvec[j, , ] <- apply(data, 1, trimparts, tr)
    }
    m1 <- bvec[, 1, ]
    m2 <- bvec[, 2, ]
    boot <- matrix(0, ncol(con), nboot)
    for (d in 1:ncol(con)) {
        top <- apply(m1, 2, trimpartt, con[, d])
        consq <- con[, d]^2
        bot <- apply(m2, 2, trimpartt, consq)
        boot[d, ] <- abs(top)/sqrt(bot)
    }
    testb <- apply(boot, 2, max)
    ic <- floor((1 - alpha) * nboot)
    testb <- sort(testb)
    psihat <- matrix(0, ncol(con), 4)
    test <- matrix(0, ncol(con), 4)
    dimnames(psihat) <- list(NULL, c("con.num", "psihat", "ci.lower", 
        "ci.upper"))
    dimnames(test) <- list(NULL, c("con.num", "test", "se", "p.value"))
    for (d in 1:ncol(con)) {
        test[d, 1] <- d
        psihat[d, 1] <- d
        testit <- lincon(x, con[, d], tr, pr = FALSE)
        test[d, 2] <- testit$test[1, 2]
        pval <- mean((abs(testit$test[1, 2]) < boot[d, ]))
        test[d, 4] <- pval
        psihat[d, 3] <- testit$psihat[1, 2] - testb[ic] * testit$test[1, 
            4]
        psihat[d, 4] <- testit$psihat[1, 2] + testb[ic] * testit$test[1, 
            4]
        psihat[d, 2] <- testit$psihat[1, 2]
        test[d, 3] <- testit$test[1, 4]
    }
    list(n = nsam, psihat = psihat, test = test, crit = testb[ic], 
        con = con)
  }

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