Skip to contents

Wraps survival::survreg(). Supported dist: "weibull", "lognormal", "loglogistic", "exponential", "gaussian".

Usage

morie_survival_aft(
  data,
  duration_col,
  event_col,
  covariate_cols,
  dist = c("weibull", "lognormal", "loglogistic", "exponential", "gaussian")
)

Arguments

data

A data.frame whose columns supply duration_col, event_col, covariate_cols, etc.

duration_col

Character; column name of the event/censoring time in data.

event_col

Character; column name of the event-indicator variable in data.

covariate_cols

Character vector of covariate column names.

dist

Distribution name for parametric/AFT fits (e.g. "weibull", "lognormal", "loglogistic").

Value

A named list with elements distribution, coefficients, scale, log_likelihood, aic, bic, n_observations, n_events, .survreg.

Examples

set.seed(1)
df <- data.frame(t = rexp(60), e = rbinom(60, 1, 0.7),
                 x1 = rnorm(60), x2 = rnorm(60))
str(morie_survival_aft(df, "t", "e", c("x1", "x2")), max.level = 1)
#> List of 9
#>  $ distribution  : chr "AFT-weibull"
#>  $ coefficients  : Named num [1:3] 0.252 0.27 0.105
#>   ..- attr(*, "names")= chr [1:3] "(Intercept)" "x1" "x2"
#>  $ scale         : num 0.832
#>  $ log_likelihood: num -55.3
#>  $ aic           : num 119
#>  $ bic           : num 127
#>  $ n_observations: int 60
#>  $ n_events      : int 47
#>  $ .survreg      :List of 15
#>   ..- attr(*, "class")= chr "survreg"