r descr_models("proportional_hazards", "glmnet")
defaults <- tibble::tibble(parsnip = c("penalty", "mixture"), default = c("see below", "1.0")) param <- proportional_hazards() %>% set_engine("glmnet") %>% make_parameter_list(defaults)
This model has r nrow(param)
tuning parameters:
param$item
The penalty
parameter has no default and requires a single numeric value. For more details about this, and the glmnet
model in general, see [parsnip::glmnet-details]. As for mixture
:
mixture = 1
specifies a pure lasso model,mixture = 0
specifies a ridge regression model, and0 < mixture < 1
specifies an elastic net model, interpolating lasso and ridge.r uses_extension("proportional_hazards", "glmnet", "censored regression")
library(censored) proportional_hazards(penalty = double(1), mixture = double(1)) %>% set_engine("glmnet") %>% translate()
By default, [glmnet::glmnet()] uses the argument standardize = TRUE
to center and scale the data.
The model does not fit an intercept.
The model formula (which is required) can include special terms, such as [survival::strata()]. This allows the baseline hazard to differ between groups contained in the function. (To learn more about using special terms in formulas with tidymodels, see [?model_formula
][parsnip::model_formula].) The column used inside strata()
is treated as qualitative no matter its type. This is different than the syntax offered by the [glmnet::glmnet()] package (i.e., [glmnet::stratifySurv()]) which is not recommended here.
For example, in this model, the numeric column rx
is used to estimate two different baseline hazards for each value of the column:
library(survival) library(censored) library(dplyr) library(tidyr)
library(survival) library(censored) library(dplyr) library(tidyr) mod <- proportional_hazards(penalty = 0.01) %>% set_engine("glmnet", nlambda = 5) %>% fit(Surv(futime, fustat) ~ age + ecog.ps + strata(rx), data = ovarian) pred_data <- data.frame(age = c(50, 50), ecog.ps = c(1, 1), rx = c(1, 2)) # Different survival probabilities for different values of 'rx' predict(mod, pred_data, type = "survival", time = 500) %>% bind_cols(pred_data) %>% unnest(.pred)
Note that columns used in the strata()
function will also be estimated in the regular portion of the model (i.e., within the linear predictor).
Simon N, Friedman J, Hastie T, Tibshirani R. 2011. "Regularization Paths for Cox’s Proportional Hazards Model via Coordinate Descent." Journal of Statistical Software, Articles 39 (5): 1–13. \doi{10.18637/jss.v039.i05}.
Hastie T, Tibshirani R, Wainwright M. 2015. Statistical Learning with Sparsity. CRC Press.
Kuhn M, Johnson K. 2013. Applied Predictive Modeling. Springer.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.