1 | gyreg(x, y, rinit = lmsreg, K = 2.5)
|
x |
|
y |
|
rinit |
|
K |
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 | ##---- 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, rinit = lmsreg, K = 2.5)
{
xy = elimna(cbind(x, y))
p = ncol(as.matrix(x))
p1 = p + 1
x = xy[, 1:p]
y = xy[, p1]
library(MASS)
res <- rinit(y ~ x)$res
res.scale <- abs(res)/mad(res)
flag <- (res.scale >= K)
i0 <- sum(flag)
il <- length(y) - i0 + 1
res.sort <- sort(res.scale)
if (i0 > 0) {
dval <- pnorm(res.sort[il:length(y)]) - c(il:length(y))/length(y)
}
if (i0 <= 0)
dval <- 0
dval <- max(dval)
ndval <- floor(length(y) * dval)
if (ndval < 0)
ndval <- 0
iup <- length(y) - ndval
rord <- order(res.scale)
flag <- rord[1:iup]
x = as.matrix(x)
temp <- lsfit(x[flag, ], y[flag])
list(coef = temp$coef, res = temp$residual)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.