r2mcp:

Usage Arguments Examples

Usage

1
r2mcp(J, K, x, grp = NA, alpha = 0.05, bhop = FALSE)

Arguments

J
K
x
grp
alpha
bhop

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
123
124
##---- 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 (J, K, x, grp = NA, alpha = 0.05, bhop = FALSE) 
{
    JK <- J * K
    if (is.matrix(x)) 
        x <- listm(x)
    if (!is.na(grp[1])) {
        yy <- x
        x <- list()
        for (j in 1:length(grp)) x[[j]] <- yy[[grp[j]]]
    }
    if (!is.list(x)) 
        stop("Data must be stored in list mode or a matrix.")
    for (j in 1:JK) {
        xx <- x[[j]]
        x[[j]] <- xx[!is.na(xx)]
    }
    if (JK != length(x)) {
        print("Warning: The number of groups does not match")
        print("the number of contrast coefficients.")
    }
    for (j in 1:JK) {
        temp <- x[[j]]
        temp <- temp[!is.na(temp)]
        x[[j]] <- temp
    }
    CC <- (J^2 - J)/2
    ncon <- CC * (K^2 - K)/2
    if (!bhop) {
        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 (bhop) 
        dvec <- (ncon - c(1:ncon) + 1) * alpha/ncon
    Fac.A <- matrix(0, CC, 5)
    dimnames(Fac.A) <- list(NULL, c("Level", "Level", "test.stat", 
        "p.value", "p.crit"))
    mat <- matrix(c(1:JK), ncol = K, byrow = T)
    ic <- 0
    for (j in 1:J) {
        for (jj in 1:J) {
            if (j < jj) {
                ic <- ic + 1
                Fac.A[ic, 1] <- j
                Fac.A[ic, 2] <- jj
                temp <- bdm2way(2, K, x[c(mat[j, ], mat[jj, ])])
                Fac.A[ic, 3] <- temp$outputA$F
                Fac.A[ic, 4] <- temp$outputA$sig
            }
        }
    }
    temp2 <- order(0 - Fac.A[, 4])
    Fac.A[temp2, 5] <- dvec[1:length(temp2)]
    CCB <- (K^2 - K)/2
    ic <- 0
    Fac.B <- matrix(0, CCB, 5)
    dimnames(Fac.B) <- list(NULL, c("Level", "Level", "test.stat", 
        "p.value", "p.crit"))
    for (k in 1:K) {
        for (kk in 1:K) {
            if (k < kk) {
                ic <- ic + 1
                Fac.B[ic, 1] <- k
                Fac.B[ic, 2] <- kk
                mat1 <- cbind(mat[, k], mat[, kk])
                temp <- bdm2way(J, 2, x[c(mat1[, 1], mat1[, 2])])
                Fac.B[ic, 3] <- temp$outputB$F
                Fac.B[ic, 4] <- temp$outputB$sig
            }
        }
    }
    temp2 <- order(0 - Fac.B[, 4])
    Fac.B[temp2, 5] <- dvec[1:length(temp2)]
    CCI <- CC * CCB
    Fac.AB <- matrix(0, CCI, 7)
    dimnames(Fac.AB) <- list(NULL, c("Lev.A", "Lev.A", "Lev.B", 
        "Lev.B", "test.stat", "p.value", "p.crit"))
    ic <- 0
    for (j in 1:J) {
        for (jj in 1:J) {
            if (j < jj) {
                for (k in 1:K) {
                  for (kk in 1:K) {
                    if (k < kk) {
                      ic <- ic + 1
                      Fac.AB[ic, 1] <- j
                      Fac.AB[ic, 2] <- jj
                      Fac.AB[ic, 3] <- k
                      Fac.AB[ic, 4] <- kk
                      val <- c(mat[j, k], mat[j, kk], mat[jj, 
                        k], mat[jj, kk])
                      temp <- bdm2way(2, 2, x[val])
                      Fac.AB[ic, 5] <- temp$outputAB$F
                      Fac.AB[ic, 6] <- temp$outputAB$sig
                    }
                  }
                }
            }
        }
    }
    temp2 <- order(0 - Fac.AB[, 6])
    Fac.AB[temp2, 7] <- dvec[1:length(temp2)]
    list(Factor.A = Fac.A, Factor.B = Fac.B, Factor.AB = Fac.AB)
  }

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