Learn R Programming

sdwd (version 1.0.5)

predict.sdwd: make predictions for the sparse DWD

Description

This function predicts the binary class labels or the fitted values of an sdwd object.

Usage

# S3 method for sdwd
predict(object, newx, s=NULL, type=c("class", "link"), ...)

Arguments

object

A fitted sdwd object.

newx

A matrix of new values for x at which predictions are to be made. We note that newx must be a matrix, predict function does not accept a vector or other formats of newx.

s

Value(s) of the L1 tuning parameter lambda for computing coefficients. Default is the entire lambda sequence obtained by sdwd.

type

"class" or "link"? "class" produces the predicted binary class labels."link" returns the fitted values. Default is "class".

Not used. Other arguments to predict.

Value

Returns either the predicted class labels or the fitted values, depending on the choice of type.

Details

s stands for the new lambda values for making predictions. If s is not in the original lambda sequence generated by sdwd, the predict.sdwd function will use linear interpolation by using a fraction of predicted values from the lambda values in the original sequence adjacent to the s to make predictions. The predict.sdwd function is modified based on the predict 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

coef.sdwd

Examples

Run this code
# NOT RUN {
data(colon)
fit = sdwd(colon$x, colon$y, lambda2=1)
print(predict(fit ,type="class",newx=colon$x[2:5,]))
# }

Run the code above in your browser using DataLab