1 |
x |
|
y |
|
regfun |
|
nboot |
|
alpha |
|
... |
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 | ##---- 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 = chreg, nboot = 599, alpha = 0.05, ...)
{
x <- as.matrix(x)
set.seed(2)
print("Taking bootstrap samples. Please wait.")
data <- matrix(sample(length(y), size = length(y) * nboot,
replace = TRUE), nrow = nboot)
bvec <- apply(data, 1, regboot, x, y, regfun, ...)
p1 <- ncol(x) + 1
regci <- matrix(0, p1, 2)
ilow <- round((alpha/2) * nboot)
ihi <- nboot - ilow
ilow <- ilow + 1
se <- NA
pvec <- NA
for (i in 1:p1) {
bsort <- sort(bvec[i, ])
pvec[i] <- sum(bvec[i, ] < 0)/nboot
if (pvec[i] > 0.5)
pvec[i] <- 1 - pvec[i]
regci[i, 1] <- bsort[ilow]
regci[i, 2] <- bsort[ihi]
se[i] <- sqrt(var(bvec[i, ]))
}
pvec <- 2 * pvec
list(regci = regci, p.value = pvec, se = se)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.