Learn R Programming

sdwd (version 1.0.5)

predict.cv.sdwd: make predictions from a "cv.sdwd" object

Description

This function predicts the class labels of new observations by the sparse DWD at the lambda values suggested by cv.sdwd.

Usage

# S3 method for cv.sdwd
predict(object, newx, s=c("lambda.1se","lambda.min"),...)

Arguments

object

A fitted cv.sdwd object.

newx

A matrix of new values for x at which predictions are to be made. Must be a matrix. See documentation for predict.sdwd.

s

Value(s) of the L1 tuning parameter lambda for making predictions. Default is the s="lambda.1se" saved on the cv.sdwd object. An alternative choice is s="lambda.min". s can also be numeric, being taken as the value(s) to be used.

Not used. Other arguments to predict.

Value

Predicted class labels or fitted values, depending on the choice of s and the … argument passed on to the sdwd method.

Details

This function uses the cross-validation results to making predictions. This function is modified based on the predict.cv function from the glmnet and the gcdnet packages.

References

Wang, B. and Zou, H. (2016) ``Sparse Distance Weighted Discrimination", Journal of Computational and Graphical Statistics, 25(3), 826--838. https://www.tandfonline.com/doi/full/10.1080/10618600.2015.1049700

Yang, Y. and Zou, H. (2013) ``An Efficient Algorithm for Computing the HHSVM and Its Generalizations", Journal of Computational and Graphical Statistics, 22(2), 396--415. https://www.tandfonline.com/doi/full/10.1080/10618600.2012.680324

Friedman, J., Hastie, T., and Tibshirani, R. (2010), "Regularization paths for generalized linear models via coordinate descent," Journal of Statistical Software, 33(1), 1--22. https://www.jstatsoft.org/v33/i01/paper

See Also

cv.sdwd, and coef.cv.sdwd methods.

Examples

Run this code
# NOT RUN {
data(colon)
colon$x = colon$x[ , 1:100] # this example only uses the first 100 columns 
set.seed(1)
cv = cv.sdwd(colon$x, colon$y, lambda2=1, nfolds=5)
predict(cv$sdwd.fit, newx=colon$x[2:5, ], 
  s=cv$lambda.1se, type="class")
# }

Run the code above in your browser using DataLab