t3way:

Usage Arguments Examples

Usage

1
t3way(J, K, L, x, tr = 0.2, grp = c(1:p), alpha = 0.05, p = J * K * L, MAT = FALSE, lev.col = c(1:3), var.col = 4, pr = TRUE, IV1 = NULL, IV2 = NULL, IV3 = NULL)

Arguments

J
K
L
x
tr
grp
alpha
p
MAT
lev.col
var.col
pr
IV1
IV2
IV3

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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
##---- 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, L, x, tr = 0.2, grp = c(1:p), alpha = 0.05, p = J * 
    K * L, MAT = FALSE, lev.col = c(1:3), var.col = 4, pr = TRUE, 
    IV1 = NULL, IV2 = NULL, IV3 = NULL) 
{
    if (is.data.frame(x)) 
        x = as.matrix(x)
    if (!is.null(IV1[1])) {
        if (is.null(IV2[1])) 
            stop("IV2 is NULL")
        if (is.null(IV3[1])) 
            stop("IV3 is NULL")
        if (pr) 
            print("Assuming x is a vector containing all of the data; the dependent variable")
        xi = elimna(cbind(x, IV1, IV2, IV3))
        x = fac2list(xi[, 1], xi[, 2:4])
        J = length(unique(IV1))
        K = length(unique(IV2))
        L = length(unique(IV3))
        p = J * K * L
    }
    data = x
    if (MAT) {
        if (!is.matrix(data)) 
            stop("With MAT=T, data must be a matrix")
        if (length(lev.col) != 3) 
            stop("Argument lev.col should have 3 values")
        temp = selby2(data, lev.col, var.col)
        lev1 = length(unique(temp$grpn[, 1]))
        lev2 = length(unique(temp$grpn[, 2]))
        lev3 = length(unique(temp$grpn[, 3]))
        gv = apply(temp$grpn, 2, rank)
        gvad = 100 * gv[, 1] + 10 * gv[, 2] + gv[, 3]
        grp = rank(gvad)
        if (pr) {
            print(paste("Factor 1 has", lev1, "levels"))
            print(paste("Factor 2 has", lev2, "levels"))
            print(paste("Factor 3 has", lev3, "levels"))
        }
        if (J != lev1) 
            warning("J is being reset to the number of levels found")
        if (K != lev2) 
            warning("K is being reset to the number of levels found")
        if (L != lev3) 
            warning("K is being reset to the number of levels found")
        J = lev1
        K = lev2
        L = lev3
        data = temp$x
    }
    if (is.matrix(data)) 
        data = listm(data)
    if (!is.list(data)) 
        stop("Data are not stored in list mode")
    if (p != length(data)) {
        print("The total number of groups, based on the specified levels, is")
        print(p)
        print("The number of groups in data is")
        print(length(data))
        print("Warning: These two values are not equal")
    }
    tmeans <- 0
    h <- 0
    v <- 0
    for (i in 1:p) {
        tmeans[i] <- mean(data[[grp[i]]], tr)
        h[i] <- length(data[[grp[i]]]) - 2 * floor(tr * length(data[[grp[i]]]))
        v[i] <- (length(data[[grp[i]]]) - 1) * winvar(data[[grp[i]]], 
            tr)/(h[i] * (h[i] - 1))
    }
    v <- diag(v, p, p)
    ij <- matrix(c(rep(1, J)), 1, J)
    ik <- matrix(c(rep(1, K)), 1, K)
    il <- matrix(c(rep(1, L)), 1, L)
    jm1 <- J - 1
    cj <- diag(1, jm1, J)
    for (i in 1:jm1) cj[i, i + 1] <- 0 - 1
    km1 <- K - 1
    ck <- diag(1, km1, K)
    for (i in 1:km1) ck[i, i + 1] <- 0 - 1
    lm1 <- L - 1
    cl <- diag(1, lm1, L)
    for (i in 1:lm1) cl[i, i + 1] <- 0 - 1
    alval <- c(1:999)/1000
    cmat <- kron(cj, kron(ik, il))
    Qa <- johan(cmat, tmeans, v, h, alpha)
    A.p.value = t3pval(cmat, tmeans, v, h)
    cmat <- kron(ij, kron(ck, il))
    Qb <- johan(cmat, tmeans, v, h, alpha)
    B.p.value = t3pval(cmat, tmeans, v, h)
    cmat <- kron(ij, kron(ik, cl))
    for (i in 1:999) {
        irem <- i
        Qc <- johan(cmat, tmeans, v, h, alval[i])
        if (Qc$teststat > Qc$crit) 
            break
    }
    C.p.value = irem/1000
    cmat <- kron(cj, kron(ck, il))
    for (i in 1:999) {
        irem <- i
        Qab <- johan(cmat, tmeans, v, h, alval[i])
        if (Qab$teststat > Qab$crit) 
            break
    }
    AB.p.value = irem/1000
    cmat <- kron(cj, kron(ik, cl))
    for (i in 1:999) {
        irem <- i
        Qac <- johan(cmat, tmeans, v, h, alval[i])
        if (Qac$teststat > Qac$crit) 
            break
    }
    AC.p.value = irem/1000
    cmat <- kron(ij, kron(ck, cl))
    for (i in 1:999) {
        irem <- i
        Qbc <- johan(cmat, tmeans, v, h, alval[i])
        if (Qbc$teststat > Qbc$crit) 
            break
    }
    BC.p.value = irem/1000
    cmat <- kron(cj, kron(ck, cl))
    for (i in 1:999) {
        irem <- i
        Qabc <- johan(cmat, tmeans, v, h, alval[i])
        if (Qabc$teststat > Qabc$crit) 
            break
    }
    ABC.p.value = irem/1000
    list(Qa = Qa$teststat, Qa.crit = Qa$crit, A.p.value = A.p.value, 
        Qb = Qb$teststat, Qb.crit = Qb$crit, B.p.value = B.p.value, 
        Qc = Qc$teststat, Qc.crit = Qc$crit, C.p.value = C.p.value, 
        Qab = Qab$teststat, Qab.crit = Qab$crit, AB.p.value = AB.p.value, 
        Qac = Qac$teststat, Qac.crit = Qac$crit, AC.p.value = AC.p.value, 
        Qbc = Qbc$teststat, Qbc.crit = Qbc$crit, BC.p.value = BC.p.value, 
        Qabc = Qabc$teststat, Qabc.crit = Qabc$crit, ABC.p.value = ABC.p.value)
  }

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