lindm:

Usage Arguments Examples

Usage

1
lindm(x, con = 0, est = onestep, grp = 0, alpha = 0.05, nboot = 399, ...)

Arguments

x
con
est
grp
alpha
nboot
...

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
##---- 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, est = onestep, grp = 0, alpha = 0.05, nboot = 399, 
    ...) 
{
    if (!is.list(x) && !is.matrix(x)) 
        stop("Data must be stored in a matrix or in list mode.")
    if (is.list(x)) {
        if (sum(grp) == 0) 
            grp <- c(1:length(x))
        mat <- matrix(0, length(x[[1]]), length(grp))
        for (j in 1:length(grp)) mat[, j] <- x[[grp[j]]]
    }
    if (is.matrix(x)) {
        if (sum(grp) == 0) 
            grp <- c(1:ncol(x))
        mat <- x[, grp]
    }
    mat <- elimna(mat)
    J <- ncol(mat)
    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) != ncol(mat)) 
        stop("The number of groups does not match the number of contrast coefficients.")
    m1 <- matrix(0, J, nboot)
    m2 <- 1
    mval <- 1
    set.seed(2)
    print("Taking bootstrap samples. Please wait.")
    data <- matrix(sample(nrow(mat), size = nrow(mat) * nboot, 
        replace = TRUE), nrow = nboot)
    xcen <- matrix(0, nrow(mat), ncol(mat))
    for (j in 1:J) {
        xcen[, j] <- mat[, j] - est(mat[, j], ...)
        mval[j] <- est(mat[, j], ...)
    }
    for (j in 1:J) m1[j, ] <- apply(data, 1, lindmsub, xcen[, 
        j], est, ...)
    m2 <- var(t(m1))
    boot <- matrix(0, ncol(con), nboot)
    bot <- 1
    for (d in 1:ncol(con)) {
        top <- apply(m1, 2, trimpartt, con[, d])
        consq <- con[, d]^2
        bot[d] <- trimpartt(diag(m2), consq)
        for (j1 in 1:J) {
            for (j2 in 1:J) {
                if (j1 < j2) 
                  bot[d] <- bot[d] + 2 * con[j1, d] * con[j2, 
                    d] * m2[j1, j2]
            }
        }
        boot[d, ] <- abs(top)/sqrt(bot[d])
    }
    testb <- apply(boot, 2, max)
    ic <- round((1 - alpha) * nboot)
    testb <- sort(testb)
    psihat <- matrix(0, ncol(con), 5)
    dimnames(psihat) <- list(NULL, c("con.num", "psihat", "ci.lower", 
        "ci.upper", "se"))
    for (d in 1:ncol(con)) {
        psihat[d, 1] <- d
        psihat[d, 2] <- trimpartt(mval, con[, d])
        psihat[d, 3] <- psihat[d, 2] - testb[ic] * sqrt(bot[d])
        psihat[d, 4] <- psihat[d, 2] + testb[ic] * sqrt(bot[d])
        psihat[d, 5] <- sqrt(bot[d])
    }
    list(psihat = psihat, crit = testb[ic], con = con)
  }

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