weights.enetLTS {enetLTS} | R Documentation |
"enetLTS"
object
Extract binary weights that indicate outliers from the current model.
## S3 method for class 'enetLTS'
weights(object,vers=c("reweighted","raw","both"),index=FALSE,...)
object |
the model fit from which to extract outlier weights. |
vers |
a character string specifying for which estimator to extract
outlier weights. Possible values are |
index |
a logical indicating whether the indices of the weight vector should
be included or not (the default is |
... |
additional arguments from the |
A numeric vector containing the requested outlier weights.
The weights are 1
for observations with reasonably small
residuals and 0
for observations with large residuals.
Here, residuals represent standardized residuals
for linear regression and Pearson residuals for logistic residuals.
Use weights with or without index is available.
Fatma Sevinc KURNAZ, Irene HOFFMANN, Peter FILZMOSER
Maintainer: Fatma Sevinc KURNAZ <fatmasevinckurnaz@gmail.com>;<fskurnaz@yildiz.edu.tr>
## 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
fit1 <- enetLTS(xout,yout,alphas=0.5,lambdas=0.05,plot=FALSE)
weights(fit1)
weights(fit1,vers="raw",index=TRUE)
weights(fit1,vers="both",index=TRUE)
## 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
fit2 <- enetLTS(xout,yout,family="binomial",alphas=0.5,lambdas=0.05,plot=FALSE)
weights(fit2)
weights(fit2,vers="raw",index=TRUE)
weights(fit2,vers="both",index=TRUE)