1 |
x |
|
ci |
|
plotit |
|
nboot |
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 | ##---- 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, ci = FALSE, plotit = TRUE, nboot = 800)
{
x <- x[!is.na(x)]
lp <- NA
se <- trimse(x)
gval <- NA
dv <- seq(0, 3.5 * se, length = 15)
for (i in 1:length(dv)) {
gval[i] <- powest(x, rep(0, 5), dv[i], se)
}
if (!ci) {
if (plotit) {
plot(dv, gval, type = "n", xlab = "delta", ylab = "power")
lines(dv, gval)
}
}
if (ci) {
set.seed(2)
print("Taking bootstrap samples. Please wait.")
datax <- matrix(sample(x, size = length(x) * nboot, replace = TRUE),
nrow = nboot)
pboot <- matrix(NA, nrow = nboot, ncol = length(dv))
for (i in 1:nboot) {
se <- trimse(datax[i, ])
for (j in 1:length(dv)) {
pboot[i, j] <- powest(x, rep(0, 5), dv[j], se)
}
}
ll <- floor(0.05 * nboot + 0.5)
for (i in 1:15) {
temp <- sort(pboot[, i])
lp[i] <- temp[ll]
}
plot(c(dv, dv), c(gval, lp), type = "n", xlab = "delta",
ylab = "power")
lines(dv, gval)
lines(dv, lp, lty = 2)
}
list(delta = dv, power = gval, lowp = lp)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.