1 |
x |
|
alpha |
|
power |
|
delta |
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 | ##---- 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, alpha = 0.05, power = 0.9, delta = NA)
{
if (is.na(delta))
stop("A value for delta was not specified")
if (!is.list(x)) {
if (!is.matrix(x))
stop("Data must be stored in matrix or in list mode")
}
y <- x
if (is.list(y))
y = matl(y)
x <- list()
for (j in 1:ncol(y)) x[[j]] <- elimna(y[, j])
nvec <- NA
svec <- NA
J <- length(x)
for (j in 1:length(x)) {
nvec[j] <- length(x[[j]])
svec[j] <- var(x[[j]])
}
nu <- nvec - 1
nu1 <- sum(1/(nu - 2))
nu1 <- J/nu1 + 2
A <- (J - 1) * nu1/(nu1 - 2)
B <- (nu1^2/J) * (J - 1)/(nu1 - 2)
C <- 3 * (J - 1)/(nu1 - 4)
D <- (J^2 - 2 * J + 3)/(nu1 - 2)
E <- B * (C + D)
M <- (4 * E - 2 * A^2)/(E - A^2 - 2 * A)
L <- A * (M - 2)/M
f <- qf(1 - alpha, L, M)
crit <- L * f
b <- (nu1 - 2) * crit/nu1
zz <- qnorm(power)
A <- 0.5 * (sqrt(2) * zz + sqrt(2 * zz^2 + 4 * (2 * b - J +
2)))
B <- A^2 - b
d <- ((nu1 - 2)/nu1) * delta/B
N <- NA
for (j in 1:length(x)) {
N[j] <- max(c(nvec[j] + 1, floor(svec[j]/d) + 1))
}
list(N = N, d = d, crit = crit)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.