lindepbt:

Usage Arguments Examples

Usage

1
lindepbt(x, con = NULL, tr = 0.2, alpha = 0.05, nboot = 599, dif = TRUE, SEED = TRUE)

Arguments

x
con
tr
alpha
nboot
dif
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
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
##---- 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 = NULL, tr = 0.2, alpha = 0.05, nboot = 599, 
    dif = TRUE, SEED = TRUE) 
{
    if (SEED) 
        set.seed(2)
    if (is.data.frame(x)) 
        x = as.matrix(x)
    if (is.list(x)) 
        x = matl(x)
    if (is.null(con)) 
        con = con2way(1, ncol(x))$conB
    x = elimna(x)
    n = nrow(x)
    flagcon = F
    if (!is.matrix(x)) 
        x <- matl(x)
    if (!is.matrix(x)) 
        stop("Data must be stored in a matrix or in list mode.")
    con <- as.matrix(con)
    J <- ncol(x)
    xbar <- vector("numeric", J)
    nval <- nrow(x)
    h1 <- nrow(x) - 2 * floor(tr * nrow(x))
    df <- h1 - 1
    xbar = apply(x, 2, mean, tr = tr)
    if (sum(con^2 != 0)) 
        CC <- ncol(con)
    ncon <- CC
    if (alpha == 0.05) {
        dvec <- c(0.05, 0.025, 0.0169, 0.0127, 0.0102, 0.00851, 
            0.0073, 0.00639, 0.00568, 0.00511)
        if (ncon > 10) {
            avec <- 0.05/c(11:ncon)
            dvec <- c(dvec, avec)
        }
    }
    if (alpha == 0.01) {
        dvec <- c(0.01, 0.005, 0.00334, 0.00251, 0.00201, 0.00167, 
            0.00143, 0.00126, 0.00112, 0.00101)
        if (ncon > 10) {
            avec <- 0.01/c(11:ncon)
            dvec <- c(dvec, avec)
        }
    }
    if (alpha != 0.05 && alpha != 0.01) 
        dvec <- alpha/c(1:ncon)
    if (nrow(con) != ncol(x)) 
        warning("The number of groups does not match the number\n of contrast coefficients.")
    ncon <- ncol(con)
    psihat <- matrix(0, ncol(con), 4)
    dimnames(psihat) <- list(NULL, c("con.num", "psihat", "ci.lower", 
        "ci.upper"))
    test <- matrix(0, ncol(con), 5)
    dimnames(test) <- list(NULL, c("con.num", "test", "p.value", 
        "p.crit", "se"))
    temp1 <- NA
    for (d in 1:ncol(con)) {
        psihat[d, 1] <- d
        if (!dif) {
            psihat[d, 2] <- sum(con[, d] * xbar)
            sejk <- 0
            for (j in 1:J) {
                for (k in 1:J) {
                  djk <- (nval - 1) * wincor(x[, j], x[, k], 
                    tr)$cov/(h1 * (h1 - 1))
                  sejk <- sejk + con[j, d] * con[k, d] * djk
                }
            }
            sejk <- sqrt(sejk)
            test[d, 1] <- d
            test[d, 2] <- sum(con[, d] * xbar)/sejk
            test[d, 5] <- sejk
            data <- matrix(sample(n, size = n * nboot, replace = TRUE), 
                nrow = nboot)
            xcen = x
            for (j in 1:ncol(x)) xcen[, j] = xcen[, j] - tmean(x[, 
                j], tr = tr)
            bvec = apply(data, 1, lindep.sub, xcen, con[, d], 
                tr)
            bsort <- sort(abs(bvec))
            ic <- round((1 - alpha) * nboot)
            ci <- 0
            psihat[d, 3] <- psihat[d, 2] - bsort[ic] * test[d, 
                5]
            psihat[d, 4] <- psihat[d, 2] + bsort[ic] * test[d, 
                5]
            p.value <- mean(abs(test[d, 2]) <= abs(bvec))
            temp1[d] = p.value
        }
        if (dif) {
            for (j in 1:J) {
                if (j == 1) 
                  dval <- con[j, d] * x[, j]
                if (j > 1) 
                  dval <- dval + con[j, d] * x[, j]
            }
            temp = trimcibt(dval, tr = tr, alpha = alpha, nboot = nboot, 
                pr = FALSE)
            temp1[d] <- temp$p.value
            test[d, 1] <- d
            test[d, 5] <- trimse(dval, tr = tr)
            psihat[d, 2] <- mean(dval, tr = tr)
            psihat[d, 3] <- temp$ci[1]
            psihat[d, 4] <- temp$ci[2]
        }
    }
    test[, 3] <- temp1
    temp2 <- order(0 - temp1)
    zvec <- dvec[1:ncon]
    sigvec <- (test[temp2, 3] >= zvec)
    test[temp2, 4] <- zvec
    if (flagcon) 
        num.sig <- sum(test[, 4] <= test[, 5])
    if (!flagcon) 
        num.sig <- sum(test[, 3] <= test[, 4])
    list(test = test, psihat = psihat, con = con, num.sig = num.sig)
  }

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