Penalized generalized linear models | R Documentation |

Fitting generalized linear models with L1 (lasso and fused lasso) and/or L2 (ridge) penalties, or a combination of the two.

penalized (response, penalized, unpenalized, lambda1=0, lambda2=0, positive = FALSE, data, fusedl=FALSE, model = c("cox", "logistic", "linear", "poisson"), 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 |

`penalized` |
The penalized covariates. These may be specified either as a matrix or as a (one-sided) |

`unpenalized` |
Additional unpenalized covariates. Specified as under |

`lambda1, lambda2` |
The tuning parameters for L1 and L2 penalization. Each must be either a single positive numbers or a vector with length equal to the number of covariates in |

`positive` |
If |

`data` |
A |

`fusedl` |
If |

`model` |
The model to be used. If missing, the model will be guessed from the |

`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 |

`epsilon` |
The convergence criterion. As in |

`maxiter` |
The maximum number of iterations allowed. Set by default at 25 when only an L2 penalty is present, infinite otherwise. |

`standardize` |
If |

`trace` |
If |

The `penalized`

function fits regression models for a given combination of L1 and L2 penalty parameters.

`penalized`

returns a `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

Goeman J.J. (2010). L-1 Penalized Estimation in the Cox Proportional Hazards Model. Biometrical Journal 52 (1) 70-84.

`penfit`

for the `penfit`

object returned, `plotpath`

for plotting the solution path, and `cvl`

for cross-validation and
optimizing the tuning parameters.

# More examples in the package vignette: # type vignette("penalized") 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 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) # A fused lasso fit predicting survival pen <- penalized(Surv(time, event), penalized = nki70[,8:77], data = nki70, lambda1 = 1, lambda2 = 2, fusedl = TRUE) plot(coefficients(pen, "all"),type="l",xlab = "probes",ylab = "coefficient value") plot(predict(pen,penalized=nki70[,8:77]))

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.