predict.enetLTS

0th

Percentile

make predictions from the "enetLTS" object.

Similar to other predict methods, this function predicts fitted values, logits, coefficients and nonzero coefficients from a fitted "enetLTS" object.

Keywords
regression, classification
Usage
# S3 method for enetLTS
predict(object,newX,vers=c("reweighted","raw","both"),
    type=c("response","coefficients","nonzero","class"),...)
Arguments
object

the model fit from which to make predictions.

newX

new values for the predictor matrix X. Must be a matrix; can be sparse as in Matrix package. This argument is not used for type=c("coefficients","nonzero").

vers

a character string denoting which fit to use for the predictions. Possible values are "reweighted" (the default) for predicting values from the reweighted fit, "raw" for predicting values from the raw fit, or "both" for predicting values from both fits.

type

type of prediction required. type="response" gives the fitted probabilities for "binomial" and gives the fitted values for "gaussian". type="coefficients" computes the coefficients from the fitted model. type="nonzero" returns a list of the indices of the nonzero coefficients. type="class" is available only for "binomial" model, and produces the class label corresponding to the maximum probability.

additional arguments from the enetLTS object if needed.

Details

The newdata argument defaults to the matrix of predictors used to fit the model such that the fitted values are computed.

coef.enetLTS(...) is equivalent to predict.enetLTS(object,newX,type="coefficients",...), where newX argument is the matrix as in enetLTS.

Value

The requested predicted values are returned.

See Also

enetLTS, coef.enetLTS, nonzeroCoef.enetLTS

Aliases
  • predict.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)
predict(fit1,newX=xout)
predict(fit1,newX=xout,type="coefficients",vers="both")
predict(fit1,newX=xout,type="nonzero",vers="raw")
# provide new X matrix
newX <- matrix(rnorm(n*p, sigma),nrow=n)
predict(fit1,newX=newX,type="response",vers="both")
predict(fit1,newX=newX,type="coefficients")
predict(fit1,newX=newX,type="nonzero",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)
predict(fit2,newX=xout)
predict(fit2,newX=xout,type="coefficients",vers="both")
predict(fit2,newX=xout,type="nonzero",vers="raw")
predict(fit2,newX=newX,type="class",vers="both")
predict(fit2,newX=newX,type="coefficients",vers="raw")
predict(fit2,newX=newX,type="nonzero",vers="both")
# }
# NOT RUN {
# }
Documentation reproduced from package enetLTS, version 0.1.0, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.