t2wayv2:

Usage Arguments Examples

Usage

1
t2wayv2(J, K, data, tr = 0.2, grp = c(1:p), p = J * K, g = NULL, dp = NULL, pr = T)

Arguments

J
K
data
tr
grp
p
g
dp
pr

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
##---- 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, data, tr = 0.2, grp = c(1:p), p = J * K, g = NULL, 
    dp = NULL, pr = T) 
{
    if (!is.null(g[1])) {
        if (length(g) != 2) 
            stop("Argument g should have two values")
        if (is.null(dp[1])) 
            stop("Specify a value for dp, the column containing the data")
        data = fac2list(data[, dp], data[, g])
    }
    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) {
        data[[grp[i]]] = elimna(data[[grp[i]]])
        tmeans[i] <- mean(data[[grp[i]]], tr)
        h[i] <- length(data[[grp[i]]]) - 2 * floor(tr * length(data[[grp[i]]]))
        if (winvar(data[[grp[i]]], tr) == 0) 
            print(paste("The Winsorized variance is zero for group", 
                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)
    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
    cmat <- kron(cj, ik)
    alval <- c(1:999)/1000
    for (i in 1:999) {
        irem <- i
        Qa <- johan(cmat, tmeans, v, h, alval[i])
        if (Qa$teststat > Qa$crit) 
            break
    }
    A.p.value = irem/1000
    cmat <- kron(ij, ck)
    for (i in 1:999) {
        irem <- i
        Qb <- johan(cmat, tmeans, v, h, alval[i])
        if (Qb$teststat > Qb$crit) 
            break
    }
    B.p.value = irem/1000
    cmat <- kron(cj, ck)
    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
    tmeans = matrix(tmeans, J, K, byrow = T)
    list(Qa = Qa$teststat, A.p.value = A.p.value, Qb = Qb$teststat, 
        B.p.value = B.p.value, Qab = Qab$teststat, AB.p.value = AB.p.value, 
        means = tmeans)
  }

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