cdlasso.rfsgt.RdFit lasso for regression using coordinate descent.
Formula describing the model to be fit.
Data frame containing response and features.
Number of cross-validation folds where default is 0 corresponding to no cross-validation.
Observation weights. Default is 1 for each observation.
The number of lambda values; default is 100.
Smallest value for lambda, as a
fraction of lambda.max which equals smallest value for which
all coefficients are zero. A very small value of
lambda.min.ratio will lead to a saturated fit in if number of
observations n is less than number of features
n.xvar.
Lasso lambda sequence. Default is an internally
selected sequence based on nlambda and
lambda.min.ratio. For experts only.
Convergence threshold for coordinate descent. Each
inner coordinate-descent loop continues until the maximum change in
the objective after any coefficient update is less than
threshold times the null deviance.
Multiplication factor applied to lambda.min.ratio
used to define the smallest lambda value.
Maximum number of passes over the data for all
lambda values.
Switches the algorithm to efficiency or naive mode
depending on number of variables. Efficiency covariance
saves all inner-products and can be significantly faster in certain
settings than naive which loops through all values n
each time an inner-product is formed.
Negative integer specifying seed for the random number generator.
Number of seconds between updates to the user on approximate time to completion.
Use coordinate descent to fit lasso to a regression model.
Lasso solution path with the following values.
Matrix containing beta values for the lasso solution path.
The sequence of lambda values used.
Index for value of lambda that gives the
minimum cross-validation error. Only applies if nfolds is
greater than 1.
Index for minimum lambda value
within 1 standard error of the minimum cross-validation error. This
is more liberal. Only applies if nfolds is greater than 1.
Index for maximum lambda value
within 1 standard error of the minimum cross-validation error. This
is more conservative. Only applies if nfolds is greater than
1.
Friedman, J., Hastie, T. and Tibshirani, R. (2010) Regularization paths for generalized linear models via coordinate descent, J. of Statistical Software, 33(1):1-22.
# \donttest{
## ------------------------------------------------------------
## regression example: boston housing
## ------------------------------------------------------------
## load the data
data(BostonHousing, package = "mlbench")
## 10-fold validation
o <- cdlasso(medv ~., BostonHousing, nfolds=10)
## lasso solution
bhat <- data.frame(bhat.min=o$beta[o$lambda.min.indx,],
bhat.1se=o$beta[o$lambda.1se.max.indx[1],])
print(bhat)
## compare to results from glmnet
if (library("glmnet", logical.return = TRUE)) {
oo <- cv.glmnet(data.matrix(o$xvar), o$yvar, nfolds=10)
bhat2 <- cbind(data.matrix(coef(oo, s=oo$lambda.min)),
data.matrix(coef(oo, s=oo$lambda.1se)))
rownames(bhat2) <- rownames(bhat)
print(bhat2)
}
# }