1 | hotel1(x, null.value = 0, tr = 0)
|
x |
|
null.value |
|
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 | ##---- 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, null.value = 0, tr = 0)
{
if (is.data.frame(x))
x <- as.matrix(x)
x = elimna(x)
if (!is.matrix(x))
stop("'x' must be a numeric matrix or a data frame")
n <- nrow(x)
p <- ncol(x)
mu = null.value
xbar = apply(x, 2, mean, tr = tr)
if (!is.numeric(mu) || ((lmu <- length(mu)) > 1 & lmu !=
p))
stop("'null.value' must be a numeric vector of length ",
p)
if (lmu == 1)
mu <- rep(mu, p)
xbar.mu <- xbar - mu
V <- winall(x, tr = tr)$cov
h = n - 2 * floor(n * tr)
k <- h/(n - 1) * (h - p)/p
stat <- k * crossprod(xbar.mu, solve(V, xbar.mu))[1, ]
pvalue <- 1 - pf(stat, p, h - p)
list(test.statistic = stat, degrees_of_freedom = c(p, h -
p), p.value = pvalue, estimate = xbar, null.value = mu)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.