residuals.enetLTS

0th

Percentile

the residuals from the "enetLTS" object

A numeric vector which returns residuals from the enetLTS object.

Keywords
regression, classification
Usage
# S3 method for enetLTS
residuals(object,vers=c("reweighted","raw","both"),...)
Arguments
object

the model fit from which to extract residuals.

vers

a character string specifying for which estimator to extract outlier weights. Possible values are "reweighted" (the default) for weights indicating outliers from the reweighted fit, "raw" for weights indicating outliers from the raw fit, or "both" for the outlier weights from both estimators.

additional arguments from the enetLTS object.

Value

A numeric vector containing the requested residuals.

See Also

enetLTS, fitted.enetLTS, predict.enetLTS, coef.enetLTS

Aliases
  • residuals.enetLTS
Examples
# NOT RUN {
## for gaussian

set.seed(86)
n <- 100; p <- 25                             # number of observations and variables
beta <- rep(0,p); beta[1:6] <- 1              # 10% nonzero coefficients
sigma <- 0.5                                  # controls signal-to-noise ratio
x <- matrix(rnorm(n*p, sigma),nrow=n)
e <- rnorm(n,0,1)                             # error terms
eps <- 0.1                                    # contamination level
m <- ceiling(eps*n)                           # observations to be contaminated
eout <- e; eout[1:m] <- eout[1:m] + 10        # vertical outliers
yout <- c(x %*% beta + sigma * eout)          # response
xout <- x; xout[1:m,] <- xout[1:m,] + 10      # bad leverage points

# }
# NOT RUN {
fit1 <- enetLTS(xout,yout,alphas=0.5,lambdas=0.05,plot=FALSE)
residuals(fit1)
residuals(fit1,vers="raw")
residuals(fit1,vers="both")
# }
# NOT RUN {

## for binomial

eps <-0.05                                    # %10 contamination to only class 0
m <- ceiling(eps*n)
y <- sample(0:1,n,replace=TRUE)
xout <- x
xout[y==0,][1:m,] <- xout[1:m,] + 10;         # class 0
yout <- y                                     # wrong classification for vertical outliers

# }
# NOT RUN {
fit2 <- enetLTS(xout,yout,family="binomial",alphas=0.5,lambdas=0.05,plot=FALSE)
residuals(fit2)
residuals(fit2,vers="raw")
residuals(fit2,vers="both")
# }
Documentation reproduced from package enetLTS, version 0.1.0, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.