1 | YYmanova(x1, x2, tr = 0.2)
|
x1 |
|
x2 |
|
tr |
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 | ##---- 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 (x1, x2, tr = 0.2)
{
x1 = elimna(x1)
x2 = elimna(x2)
s1 = winall(x1, tr = tr)$cov
s2 = winall(x2, tr = tr)$cov
n1 = nrow(x1)
n2 = nrow(x2)
n = n1 + n2
g1 = floor(n1 * tr)
g2 = floor(n2 * tr)
h1 = n1 - 2 * g1
h2 = n2 - 2 * g2
h = h1 + h2
sbar = n2 * s1/n + n1 * s2/n
sbarinv = solve(sbar)
psi1 = n2^2 * (n - 2) * (sum(diag(s1 %*% sbarinv)))^2/(n^2 *
(n1 - 1)) + n1^2 * (n - 2) * (sum(diag(s2 %*% sbarinv)))^2/(n^2 *
(n2 - 1))
psi2 = n2^2 * (n - 2) * (sum(diag(s1 %*% sbarinv %*% s1 %*%
sbarinv)))/(n^2 * (n1 - 1)) + n1^2 * (n - 2) * (sum(diag(s2 %*%
sbarinv %*% s2 %*% sbarinv)))/(n^2 * (n2 - 1))
p = ncol(x1)
theta1 = (p * psi1 + (p - 2) * psi2)/(p * (p + 2))
theta2 = (psi1 + 2 * psi2)/(p * (p + 2))
nuhat = (h - 2 - theta1)^2/((h - 2) * theta2 - theta1)
xb1 = apply(x1, 2, mean, tr = tr)
xb2 = apply(x2, 2, mean, tr = tr)
dif = xb1 - xb2
dif = as.matrix(dif)
Ttest = t(dif) %*% solve((n1 - 1) * s1/(h1 * (h1 - 1)) +
(n2 - 1) * s2/(h2 * (h2 - 1))) %*% dif
TF = (n - 2 - theta1) * Ttest/((n - 2) * p)
pv = 1 - pf(TF, p, nuhat)
list(test.stat = TF, p.value = pv)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.