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 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, alpha = 0.05, ks = 3.5)
{
n <- length(x)
up <- 1 - alpha/2
med <- median(x)
madd <- mad(x, constant = 1)
d <- sort(x)
lo <- sum(x < (med - ks * madd))
hi <- sum(x > (med + ks * madd))
tp <- max(hi, lo)/n
if (tp == 0)
tp <- 0
if (tp > 0 && tp <= 0.01)
tp <- 0.01
if (tp > 0.01 && tp <= 0.1)
tp <- 0.1
if (tp > 0.1 && tp <= 0.25)
tp <- 0.25
if (tp > 0.25 && tp <= 0.4)
tp <- 0.4
if (tp > 0.4)
tp <- 0.49
tstmn <- mean(x, trim = tp)
ln <- floor(n * tp)
un <- n - ln
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.