rmdzeroG:

Usage Arguments Examples

Usage

1
rmdzeroG(x, est = skipSPR, grp = NA, nboot = 500, SEED = TRUE, ...)

Arguments

x
est
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
57
58
59
60
61
62
63
64
65
66
##---- 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, est = skipSPR, grp = NA, nboot = 500, SEED = TRUE, 
    ...) 
{
    if (!is.list(x) && !is.matrix(x)) 
        stop("Data must be stored in a matrix or in list mode.")
    if (is.list(x)) {
        mat <- matrix(0, length(x[[1]]), length(x))
        for (j in 1:length(x)) mat[, j] <- x[[j]]
    }
    if (is.matrix(x)) 
        mat <- x
    if (!is.na(grp[1])) {
        mat <- mat[, grp]
    }
    FLAG = FALSE
    if (ncol(mat) < 3) 
        FLAG = TRUE
    mat <- elimna(mat)
    J <- ncol(mat)
    jp <- 0
    Jall <- (J^2 - J)/2
    dif <- matrix(NA, nrow = nrow(mat), ncol = Jall)
    ic <- 0
    for (j in 1:J) {
        for (k in 1:J) {
            if (j < k) {
                ic <- ic + 1
                dif[, ic] <- mat[, j] - mat[, k]
            }
        }
    }
    dif <- as.matrix(dif)
    if (SEED) 
        set.seed(2)
    data <- matrix(sample(nrow(mat), size = nrow(mat) * nboot, 
        replace = T), nrow = nboot)
    if (!FLAG) {
        bvec <- matrix(NA, ncol = ncol(dif), nrow = nboot)
        for (i in 1:nboot) {
            bvec[i, ] <- est(dif[data[i, ], ], ...)$center
        }
        center <- est(dif, ...)$center
        bcen <- apply(bvec, 2, mean)
        cmat <- var(bvec - bcen + center)
        zvec <- rep(0, Jall)
        m1 <- rbind(bvec, zvec)
        bplus <- nboot + 1
        discen <- mahalanobis(m1, center, cmat)
        sig.level <- sum(discen[bplus] <= discen)/bplus
    }
    if (FLAG) {
        bvec = matrix(NA, ncol = ncol(mat), nrow = nboot)
        for (i in 1:nboot) bvec[i, ] = est(mat[data[i, ], ], 
            ...)$center
        pv = mean(bvec[, 1] < bvec[, 2]) + 0.5 * mean(bvec[, 
            1] == bvec[, 2])
        sig.level = 2 * min(c(pv, 1 - pv))
        center = est(mat, ...)$center
    }
    list(p.value = sig.level, center = center)
  }

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