Penalized generalized linear models {penalized} | R Documentation |
Fitting generalized linear models with L1 (lasso) and/or L2 (ridge) penalties, or a combination of the two.
penalized (response, penalized, unpenalized, lambda1 = 0, lambda2 = 0, data, model = c("cox", "logistic", "linear"), startbeta, startgamma, steps = 1, epsilon = 1e-10, maxiter, standardize = FALSE, trace = TRUE)
response |
The response variable (vector). This should be a numeric vector for
linear regression, a Surv object for Cox regression and
a vector of 0/1 values for logistic regression. |
penalized |
The penalized covariates. These may be specified
either as a matrix or as a (one-sided) formula object.
See also under data . |
unpenalized |
Additional unpenalized covariates.
Specified as under penalized .
Note that an unpenalized intercept is included in the model by default (except in the cox model).
This can be suppressed by specifying unpenalized = ~0 . |
lambda1, lambda2 |
The tuning parameters for L1 and L2 penalization. May be vectors if different cavariates are to be penalized differently. |
data |
A data.frame used to evaluate response , and the terms of
penalized or unpenalized when these have been specified as a
formula object. |
model |
The model to be used. If missing, the model will be guessed from the response input. |
startbeta |
Starting values for the regression coefficients of the penalized covariates. |
startgamma |
Starting values for the regression coefficients of the unpenalized covariates. |
steps |
If greater than 1, the algorithm will fit the model for a range of steps
lambda1 -values, starting from the maximal value down to the value of lambda1 specified.
This is useful for making plots as in plotpath . |
epsilon |
The convergence criterion. As in glm .
Convergence is judged separately on the likelihood and on the penalty. |
maxiter |
The maximum number of iterations allowed. Set by default at 25 when lambda1 = 0, infinite otherwise. |
standardize |
If TRUE , standardizes all penalized covariates to
unit central L2-norm before applying penalization. |
trace |
If TRUE , prints progress information. Note that setting
trace=TRUE may slow down the algorithm up to 30 percent (but it often feels quicker) |
The penalized
function fits regression models for a given
combination of L1 and L2 penalty parameters.
penalized
returns a link{penfit}
object when steps = 1
or a list of such objects if steps > 1
.
The response
argument of the function also accepts formula input as in lm
and related functions. In that case, the right hand side of the response
formula is used as the penalized
argument or, if that is already given, as the unpenalized
argument. For example, the input penalized(y~x)
is equivalent to penalized(y, ~x)
and penalized(y~x, ~z)
to penalized(y, ~z, ~x)
.
In case of tied survival times, the function uses Breslow's version of the partial likelihood.
Jelle Goeman: j.j.goeman@lumc.nl
penfit
for the penfit
object returned, plotpath
for plotting the solution path, and cvl
for cross-validation and
optimizing the tunung parameters.
data(nki70) # A single lasso fit predicting survival pen <- penalized(Surv(time, event), penalized = nki70[,8:77], unpenalized = ~ER+Age+Diam+N+Grade, data = nki70, lambda1 = 10) show(pen) coefficients(pen) coefficients(pen, "penalized") basehaz(pen) # A single lasso fit using using the clinical risk factors pen <- penalized(Surv(time, event), penalized = ~ER+Age+Diam+N+Grade, data = nki70, lambda1=10, standardize=TRUE) # using steps pen <- penalized(Surv(time, event), penalized = nki70[,8:77], data = nki70, lambda1 = 1, steps = 20) plotpath(pen)