r descr_models("proportional_hazards", "glmnet")

Tuning Parameters

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:

Translation from parsnip to the original package

r uses_extension("proportional_hazards", "glmnet", "censored regression")

library(censored)

proportional_hazards(penalty = double(1), mixture = double(1)) %>% 
  set_engine("glmnet") %>% 
  translate()

Preprocessing requirements



By default, [glmnet::glmnet()] uses the argument standardize = TRUE to center and scale the data.

Other details

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. 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).


Linear predictor values


Case weights


Saving fitted model objects


References



Try the parsnip package in your browser

Any scripts or data that you put into this service are public.

parsnip documentation built on Aug. 18, 2023, 1:07 a.m.