1 |
x |
|
tr |
|
grp |
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 | ##---- 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, tr = 0.2, grp = NA)
{
if (is.matrix(x))
x <- listm(x)
if (is.na(grp[1]))
grp <- c(1:length(x))
if (!is.list(x))
stop("Data are not stored in a matrix or in list mode")
J <- length(grp)
h <- 1
xbar <- 1
ybar <- 1
wvar <- 1
ell <- 0
for (j in 1:J) {
ell[j] <- length(x[[grp[j]]])/(length(x[[grp[j]]]) +
1)
h[j] <- length(x[[grp[j]]]) - 2 * floor(tr * length(x[[grp[j]]]))
ybar[j] <- winmean(x[[grp[j]]], tr)
xbar[j] <- mean(x[[grp[j]]], tr)
wvar[j] <- winvar(x[[grp[j]]], tr)
}
q <- NA
bsst <- var(xbar)
for (j in 1:J) q[j] <- (length(x[[grp[j]]] - 1) - 1) * wvar[j]/(h[j] *
(h[j] - 1))
wssw <- mean(q)
D <- bsst/wssw
g <- q/J
nu1 <- ((J - 1) * sum(q))^2/((sum(q))^2 + (J - 2) * J * sum(q^2))
nu2 <- (sum(J * q))^2/sum((J * q)^2/(h - 1))
sig <- 1 - pf(D, nu1, nu2)
sighat <- mean(ell * (ybar - (sum(ell * ybar)/sum(ell)))^2)
rho <- sighat/(sighat + winmean(wvar, tr))
list(teststat = D, df = c(nu1, nu2), p.value = sig, rho = rho,
num.groups = J)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.