set_covariates: Set Covariates of a Survival Model

View source: R/set_covariates.r

set_covariatesR Documentation

Set Covariates of a Survival Model

Description

Generate a survival distribution representing model predictions for a specified cohort. The cohort can be defined by providing a data frame of covariate values (for multiple subjects) or by providing covariate values as named arguments (for a single subject).

Usage

set_covariates(dist, data, ...)

Arguments

dist

a survfit or flexsurvreg object

data

a data.frame representing subjets for which predictions will be generated

...

optional argument representing covariate values to generate predictions for, can be used instead of data argument

Value

a surv_model object

Examples

library(flexsurv)
fs1 <- flexsurvreg(
  Surv(rectime, censrec)~group,
  data=flexsurv::bc,
  dist = "llogis"
)
good_model <- set_covariates(fs1, group = "Good")
cohort <- data.frame(group=c("Good", "Good", "Medium", "Poor"))
mixed_model <- set_covariates(fs1, data = cohort)


PolicyAnalysisInc/herosurv documentation built on May 21, 2023, 10:12 a.m.