1 |
x1 |
|
y1 |
|
x2 |
|
y2 |
|
q |
|
qval |
|
LP |
|
fr |
|
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | ##---- 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 (x1, y1, x2, y2, q = 0.5, qval = NULL, LP = TRUE, fr = 0.8,
xlab = "X", ylab = "Y", xout = FALSE, outfun = outpro, ...)
{
if (!is.null(qval))
q = qval
m1 <- elimna(cbind(x1, y1))
if (ncol(m1) > 3)
stop("One covariate only is allowed")
m2 <- elimna(cbind(x2, y2))
x1 <- m1[, 1]
y1 <- m1[, 2]
x2 <- m2[, 1]
y2 <- m2[, 2]
if (xout) {
flag <- outfun(m1[, 1], plotit = FALSE, ...)$keep
m1 <- m1[flag, ]
x1 <- m1[, 1]
y1 <- m1[, 2]
flag <- outfun(m2[, 1], plotit = FALSE, ...)$keep
m2 <- m2[flag, ]
x2 <- m2[, 1]
y2 <- m2[, 2]
}
flag = order(x1)
x1 = x1[flag]
y1 = y1[flag]
flag = order(x2)
x2 = x2[flag]
y2 = y2[flag]
rmd1 = NA
rmd2 = NA
for (i in 1:length(x1)) rmd1[i] <- hd(y1[near(x1, x1[i],
fr)], q = q)
for (i in 1:length(x2)) rmd2[i] <- hd(y2[near(x2, x2[i],
fr)], q = q)
if (LP) {
rmd1 = lplot(x1, rmd1, plotit = FALSE, pyhat = TRUE,
pr = FALSE)$yhat
rmd2 = lplot(x2, rmd2, plotit = FALSE, pyhat = TRUE,
pr = FALSE)$yhat
}
plot(c(x1, x2), c(y1, y2), type = "n", xlab = xlab, ylab = ylab)
points(x1, y1)
points(x2, y2, pch = "+")
lines(x1, rmd1)
lines(x2, rmd2, lty = 2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.