1 |
x |
|
y |
|
regfun |
|
nboot |
|
alpha |
|
xout |
|
outfun |
|
MC |
|
SEED |
|
... |
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 | ##---- 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, regfun = tsreg, nboot = 400, alpha = 0.05, xout = FALSE,
outfun = out, MC = FALSE, SEED = TRUE, ...)
{
if (MC)
library(parallel)
x <- as.matrix(x)
p1 <- ncol(x) + 1
p <- ncol(x)
if (p != 2)
stop("Argument x should have two columns")
xy <- cbind(x, y)
xy <- elimna(xy)
x <- xy[, 1:p]
y <- xy[, p1]
if (xout) {
m <- cbind(x, y)
flag <- outfun(x, plotit = FALSE)$keep
m <- m[flag, ]
x <- m[, 1:p]
y <- m[, p1]
}
if (SEED)
set.seed(2)
data <- matrix(sample(length(y), size = length(y) * nboot,
replace = TRUE), ncol = nboot)
data = listm(data)
if (MC) {
bvec1 <- mclapply(data, regbootMC, as.matrix(x[, 1]),
y, regfun, mc.preschedule = TRUE)
bvec2 <- mclapply(data, regbootMC, x, y, regfun, mc.preschedule = TRUE)
}
if (!MC) {
bvec1 <- lapply(data, regboot, as.matrix(x[, 1]), y,
regfun)
bvec2 <- lapply(data, regboot, x, y, regfun)
}
bvec1 = matl(bvec1)
bvec2 = matl(bvec2)
dif = bvec1[2, ] - bvec2[2, ]
ilow <- round((alpha/2) * nboot)
ihi <- nboot - ilow
ilow <- ilow + 1
sig.level <- NA
temp <- mean(dif < 0)
sig.level <- 2 * (min(temp, 1 - temp))
bsort <- sort(dif)
regci <- bsort[ilow]
regci[2] <- bsort[ihi]
list(conf.interval = regci, p.value = sig.level)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.