Computes the coefficients or returns the indices of nonzero coefficients at chosen values of lambda
from a fitted sdwd
object.
# S3 method for sdwd
coef(object, s=NULL, type=c("coefficients","nonzero"), ...)
A fitted sdwd
object.
Value(s) of the L1 tuning parameter lambda
for computing coefficients. Default is the entire lambda
sequence obtained by sdwd
.
"coefficients"
or "nonzero"
? "coefficients"
computes the coefficients at given values for s
; "nonzero"
returns a list of the indices of the nonzero coefficients for each value of s
. Default is "coefficients"
.
Not used. Other arguments to predict
.
Either the coefficients at the requested values of lambda
, or a list of the indices of the nonzero coefficients for each lambda
.
s
is the new vector at which predictions are requested. If s
is not in the lambda sequence used for fitting the model, the coef
function will use linear interpolation to make predictions. The new values are interpolated using a fraction of coefficients from both left and right lambda
indices. This function is modified based on the coef
function from the gcdnet
and the glmnet
packages.
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
# NOT RUN {
data(colon)
fit = sdwd(colon$x, colon$y, lambda2=1)
c1 = coef(fit, type="coef",s=c(0.1, 0.005))
c2 = coef(fit, type="nonzero")
# }
Run the code above in your browser using DataLab