1 | ols.pred.ci(x, y, xlab = "X", ylab = "Y", alpha = 0.05, xout = FALSE, RETURN = FALSE, newx = NULL)
|
x |
|
y |
|
xlab |
|
ylab |
|
alpha |
|
xout |
|
RETURN |
|
newx |
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, xlab = "X", ylab = "Y", alpha = 0.05, xout = FALSE,
RETURN = FALSE, newx = NULL)
{
if (ncol(as.matrix(x)) != 1)
stop("One predictor is allowed")
xy = elimna(cbind(x, y))
x = xy[, 1]
y = xy[, 2]
if (xout) {
flag = out(x)$keep
x = x[flag]
y = y[flag]
}
tmp.lm = lm(y ~ x)
if (is.null(newx))
newx = seq(min(x), max(x), 0.1)
a = predict(tmp.lm, interval = "confidence", level = 1 -
alpha, newdata = data.frame(x = newx))
plot(x, y, xlab = xlab, ylab = ylab)
abline(ols(x, y, plotit = FALSE)$coef)
lines(newx, a[, 2], lty = 2)
lines(newx, a[, 3], lty = 2)
res = NULL
if (RETURN)
res = a
res
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.