pairdepb:

Usage Arguments Examples

Usage

1
pairdepb(x, tr = 0.2, alpha = 0.05, grp = 0, nboot = 599)

Arguments

x
tr
alpha
grp
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
##---- 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, alpha = 0.05, grp = 0, nboot = 599) 
{
    if (is.data.frame(x)) 
        x <- as.matrix(x)
    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]
    }
    if (sum(is.na(mat) >= 1)) 
        stop("Missing values are not allowed.")
    J <- ncol(mat)
    connum <- (J^2 - J)/2
    bvec <- matrix(0, connum, nboot)
    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] - mean(mat[, j], tr)
    it <- 0
    for (j in 1:J) {
        for (k in 1:J) {
            if (j < k) {
                it <- it + 1
                bvec[it, ] <- apply(data, 1, tsub, xcen[, j], 
                  xcen[, k], tr)
            }
        }
    }
    bvec <- abs(bvec)
    icrit <- round((1 - alpha) * nboot)
    critvec <- apply(bvec, 2, max)
    critvec <- sort(critvec)
    crit <- critvec[icrit]
    psihat <- matrix(0, connum, 5)
    dimnames(psihat) <- list(NULL, c("Group", "Group", "psihat", 
        "ci.lower", "ci.upper"))
    test <- matrix(NA, connum, 4)
    dimnames(test) <- list(NULL, c("Group", "Group", "test", 
        "se"))
    it <- 0
    for (j in 1:J) {
        for (k in 1:J) {
            if (j < k) {
                it <- it + 1
                estse <- yuend(mat[, j], mat[, k])$se
                dif <- mean(mat[, j], tr) - mean(mat[, k], tr)
                psihat[it, 1] <- grp[j]
                psihat[it, 2] <- grp[k]
                psihat[it, 3] <- dif
                psihat[it, 4] <- dif - crit * estse
                psihat[it, 5] <- dif + crit * estse
                test[it, 1] <- grp[j]
                test[it, 2] <- grp[k]
                test[it, 3] <- yuend(mat[, j], mat[, k])$teststat
                test[it, 4] <- estse
            }
        }
    }
    list(test = test, psihat = psihat, crit = crit)
  }

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