1 |
x |
|
y |
|
regfun |
|
npts |
|
nboot |
|
xout |
|
outfun |
|
SEED |
|
alpha |
|
crit |
|
xlab |
|
ylab |
|
SCAT |
|
ADJ |
|
pr |
|
nreps |
|
MC |
|
... |
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 | ##---- 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, npts = NULL, nboot = 100, xout = FALSE,
outfun = outpro, SEED = TRUE, alpha = 0.05, crit = NULL,
xlab = "X", ylab = "Y", SCAT = TRUE, ADJ = TRUE, pr = TRUE,
nreps = 1000, MC = FALSE, ...)
{
if (!ADJ) {
if (is.null(npts))
npts = 20
if (pr)
print("To adjust the confidence band so that the simultaneous probability coverage is .95, set ADJ=TRUE")
}
xy = elimna(cbind(x, y))
x <- as.matrix(x)
p = ncol(x)
if (p != 1)
stop("This function assumes a single predictor only")
p1 = p + 1
vals = NA
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)
if (!ADJ)
pts = seq(min(x), max(x), length.out = npts)
if (ADJ)
pts = sort(x)
res = regYci(x, y, pts = pts, regfun = regfun, xout = FALSE,
SEED = SEED, alpha = alpha, ADJ = ADJ, nreps = nreps,
MC = MC, ...)
plot(c(x, pts, pts), c(y, res[, 2], res[, 3]), xlab = xlab,
ylab = ylab, type = "n")
abline(regfun(x, y, ...)$coef)
if (SCAT)
points(x, y)
lines(pts, res[, 3], lty = 2)
lines(pts, res[, 4], lty = 2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.