1 |
x |
|
y |
|
qval |
|
q |
|
plotit |
|
xlab |
|
ylab |
|
xout |
|
outfun |
|
... |
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 | ##---- 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, qval = c(0.2, 0.8), q = NULL, plotit = TRUE,
xlab = "X", ylab = "Y", xout = FALSE, outfun = out, ...)
{
if (!is.null(q))
qval = q
xy = elimna(cbind(x, y))
if (ncol(xy) > 2)
stop("Only One Predictor Allowed")
x = xy[, 1]
y = xy[, 2]
if (xout) {
x <- as.matrix(x)
flag <- outfun(x, ...)$keep
x <- x[flag, ]
y <- y[flag]
}
n <- length(qval)
coef <- matrix(NA, ncol = 2, nrow = n)
x <- as.matrix(x)
if (ncol(x) > 1)
stop("This version allows one predictor only.")
if (plotit)
plot(x, y, xlab = xlab, ylab = ylab)
for (it in 1:n) {
coef[it, ] <- qreg(x, y, qval = qval[it], pr = FALSE)$coef
dimnames(coef) = list(NULL, c("Inter.", "Slope"))
if (plotit)
abline(coef[it, 1], coef[it, 2])
}
coef
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.