1 |
J |
|
K |
|
x |
|
tr |
|
JK |
|
grp |
|
alpha |
|
op |
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 | ##---- 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, tr = 0.2, JK = J * K, grp = c(1:JK), alpha = 0.05,
op = T)
{
if (is.matrix(x)) {
y <- list()
for (j in 1:ncol(x)) y[[j]] <- x[, j]
x <- y
}
JK <- J * K
if (!op) {
data <- list()
for (j in 1:length(x)) {
data[[j]] <- x[[grp[j]]]
}
x <- data
data <- list()
jp <- 1 - K
kv <- 0
for (j in 1:J) {
jp <- jp + K
for (k in 1:K) {
kv <- kv + 1
if (k == 1)
temp <- x[[jp]]
if (k > 1)
temp <- c(temp, x[[kv]])
}
data[[j]] <- temp
}
print("Group numbers refer to levels of Factor A")
temp <- lincon(data, tr = tr, alpha = alpha)
}
if (op) {
MJK <- K * (J^2 - J)/2
JK <- J * K
MJ <- (J^2 - J)/2
cont <- matrix(0, nrow = J, ncol = MJ)
ic <- 0
for (j in 1:J) {
for (jj in 1:J) {
if (j < jj) {
ic <- ic + 1
cont[j, ic] <- 1
cont[jj, ic] <- 0 - 1
}
}
}
tempv <- matrix(0, nrow = K - 1, ncol = MJ)
con1 <- rbind(cont[1, ], tempv)
for (j in 2:J) {
con2 <- rbind(cont[j, ], tempv)
con1 <- rbind(con1, con2)
}
con <- con1
if (K > 1) {
for (k in 2:K) {
con1 <- push(con1)
con <- cbind(con, con1)
}
}
print("Contrast Matrix Used:")
print(con)
temp <- lincon(x, con = con, tr = tr, alpha = alpha)
}
temp
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.