1 |
x |
|
tr |
|
alpha |
|
nboot |
|
side |
|
plotit |
|
op |
|
nullval |
|
SEED |
|
prCRIT |
|
pr |
|
xlab |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ##---- 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, alpha = 0.05, nboot = 599, side = TRUE,
plotit = FALSE, op = 1, nullval = 0, SEED = TRUE, prCRIT = FALSE,
pr = TRUE, xlab = "")
{
x = elimna(x)
side <- as.logical(side)
p.value <- NA
if (SEED)
set.seed(2)
test <- (mean(x, tr) - nullval)/trimse(x, tr)
data <- matrix(sample(x, size = length(x) * nboot, replace = TRUE),
nrow = nboot)
data <- data - mean(x, tr)
top <- apply(data, 1, mean, tr)
bot <- apply(data, 1, trimse, tr)
tval <- top/bot
if (plotit) {
if (op == 1)
akerd(tval, xlab = xlab)
if (op == 2)
rdplot(tval, xlab = xlab)
}
if (side)
tval <- abs(tval)
tval <- sort(tval)
icrit <- floor((1 - alpha) * nboot + 0.5)
ibot <- round(alpha * nboot/2) + 1
itop <- nboot - ibot - 1
if (!side) {
if (prCRIT)
print(paste("Lower crit=", tval[ibot], "Upper crit=",
tval[itop]))
if (prCRIT)
print(paste(".025 Lower Type I=", mean(tval <= 0 -
1.96)))
if (prCRIT)
print(paste(".05 Lower Type I=", mean(tval <= 0 -
1.645)))
if (prCRIT)
print(paste(".025 Upper Type I=", mean(tval >= 1.96)))
if (prCRIT)
print(paste(".05 Upper Type I=", mean(tval >= 1.645)))
trimcibt <- mean(x, tr) - tval[itop] * trimse(x, tr)
trimcibt[2] <- mean(x, tr) - tval[ibot] * trimse(x, tr)
if (pr)
print("NOTE: p.value is computed only when side=T")
}
if (side) {
if (prCRIT)
print(paste("Symmetric Crit.val=", tval[icrit]))
trimcibt <- mean(x, tr) - tval[icrit] * trimse(x, tr)
trimcibt[2] <- mean(x, tr) + tval[icrit] * trimse(x,
tr)
p.value <- (sum(abs(test) <= abs(tval)))/nboot
}
list(estimate = mean(x, tr), ci = trimcibt, test.stat = test,
p.value = p.value, n = length(x))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.