1 |
x |
|
y |
|
RES |
|
xout |
|
outfun |
|
STAND |
|
varfun |
|
corfun |
|
... |
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 | ##---- 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, RES = FALSE, xout = FALSE, outfun = outpro, STAND = TRUE,
varfun = pbvar, corfun = pbcor, ...)
{
x <- as.matrix(x)
xx <- cbind(x, y)
xx <- elimna(xx)
x <- xx[, 1:ncol(x)]
x <- as.matrix(x)
y <- xx[, ncol(x) + 1]
temp <- NA
x <- as.matrix(x)
if (xout) {
x <- as.matrix(x)
if (!STAND)
flag <- outfun(x, plotit = FALSE, ...)$keep
if (STAND)
flag <- outpro(x, STAND = TRUE, plotit = FALSE, ...)$keep
x <- x[flag, ]
y <- y[flag]
x <- as.matrix(x)
}
library(robustbase)
temp = lmrob(y ~ x)
coef = temp$coefficients
p1 = ncol(x) + 1
res <- y - x %*% coef[2:p1] - coef[1]
yhat <- y - res
stre = NULL
e.pow <- varfun(yhat)/varfun(y)
if (!is.na(e.pow)) {
if (e.pow >= 1)
e.pow <- corfun(yhat, y)$cor^2
e.pow = as.numeric(e.pow)
stre = sqrt(e.pow)
}
if (!RES)
res = NULL
list(coef = coef, residuals = res, Strength.Assoc = stre)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.