# NOT RUN {
surv_reg()
# Parameters can be represented by a placeholder:
surv_reg(dist = varying())
# Examples of using recipes with the `fit` function
library(dplyr)
library(recipes)
library(survival)
data(lung)
surv_rec <- recipe(time ~ ., data = lung) %>%
add_role(status, new_role = "censoring var") %>%
# exclude some vars from being in the model
add_role(inst, sex, ph.karno, pat.karno, meal.cal, wt.loss,
new_role = "other variables")
log_normal_mod <- surv_reg(dist = "lnorm")
fit(log_normal_mod, recipe = surv_rec, data = lung, engine = "flexsurv")
# make the normal variance be a function of gender:
strata_model <- surv_rec %>%
add_role(sex, new_role = "sdlog")
fit(log_normal_mod, recipe = strata_model, data = lung, engine = "flexsurv")
model <- surv_reg(dist = "weibull")
model
update(model, dist = "lnorm")
# }
Run the code above in your browser using DataLab