1 |
x |
|
alpha |
|
ks |
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 | ##---- 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, ks = 3.5)
{
n <- length(x)
up <- 1 - alpha/2
med <- median(x)
madd <- mad(x, constant = 1)
lo <- sum(x < (med - ks * madd))
hi <- sum(x > (med + ks * madd))
low <- ceiling((100 * lo)/n)
high <- ceiling((100 * hi)/n)
tp <- min(max(low, high)/100, 0.5)
tstmn <- mean(x, trim = tp)
ln <- floor(n * tp)
un <- n - ln
d <- sort(x)
if (ln > 0) {
d[1:ln] <- d[(ln + 1)]
d[(un + 1):n] <- d[un]
}
den <- ((un - ln)/n)^2
swv <- var(d)/den
rdf <- un - ln - 1
rval <- qt(up, rdf) * sqrt(swv/n)
tslo <- tstmn - rval
tshi <- tstmn + rval
list(int = c(tslo, tshi), tp = tp)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.