1 |
x |
|
y |
|
fr |
|
plotit |
|
pyhat |
|
xlab |
|
ylab |
|
STAND |
|
xout |
|
outfun |
|
LP |
|
... |
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 | ##---- 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, fr = 1, plotit = TRUE, pyhat = FALSE, xlab = "X",
ylab = "Y", STAND = TRUE, xout = FALSE, outfun = outpro,
LP = TRUE, ...)
{
x <- as.matrix(x)
if (ncol(x) > 1)
stop("With more than one predictor, use logSM")
xy = elimna(cbind(x, y))
x = xy[, 1:ncol(x)]
y = xy[, ncol(xy)]
x <- as.vector(x)
if (xout) {
flag <- outfun(x, ...)$keep
x <- x[flag]
y <- y[flag]
}
if (STAND)
x <- (x - median(x))/mad(x)
m1 <- outer(x, x, "-")^2
m2 <- exp(-1 * m1) * (sqrt(m1) <= fr)
m3 <- matrix(y, length(y), length(y)) * m2
yhat <- apply(m3, 2, sum)/apply(m2, 2, sum)
if (plotit) {
xor <- order(x)
plot(x, y, xlab = xlab, ylab = ylab)
if (!LP)
lines(x[xor], yhat[xor])
if (LP) {
Yhat = lplot(x[xor], yhat[xor], pyhat = TRUE, plotit = FALSE)$yhat.values
lines(x[xor], Yhat)
}
}
output <- "Done"
if (pyhat)
output <- yhat
list(output = output)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.