1 |
x |
|
y |
|
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 46 47 | ##---- 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, y, ci = FALSE, plotit = TRUE, nboot = 800)
{
x <- x[!is.na(x)]
y <- y[!is.na(y)]
lp <- NA
se <- yuen(x, y)$se
gval <- NA
dv <- seq(0, 3.5 * se, length = 15)
for (i in 1:length(dv)) {
gval[i] <- powest(x, y, dv[i], se)
}
if (!ci) {
if (plotit) {
plot(dv, gval, type = "n", xlab = "delta", ylab = "power")
lines(dv, gval)
}
}
if (ci) {
print("Taking bootstrap samples. Please wait.")
datax <- matrix(sample(x, size = length(x) * nboot, replace = TRUE),
nrow = nboot)
datay <- matrix(sample(y, size = length(y) * nboot, replace = TRUE),
nrow = nboot)
pboot <- matrix(NA, ncol = 15, nrow = nboot)
for (i in 1:nboot) {
se <- yuen(datax[i, ], datay[i, ])$se
for (j in 1:length(dv)) {
pboot[i, j] <- powest(x, y, 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.