Skip to contents

One interface over the established survival stack. method selects an estimator from the registry (sest_methods()); the appropriate backend is checked, a small-sample power gate runs (sest_power()), and the fit is returned as a single typed object (sest_fit) with consistent print, summary, coef, vcov, predict and tidy() methods.

Usage

survestimand(
  formula,
  data,
  method = "cox",
  ...,
  check_power = TRUE,
  warn_underpowered = TRUE,
  on_underpowered = c("warn", "abstain")
)

Arguments

formula

A model formula, e.g. survival::Surv(time, status) ~ x.

data

A data frame.

method

Character registry key (default "cox"); see sest_methods().

...

Passed to the backend estimator. weights, id, cluster, istate and subset are read as the backend reads them: a bare name or expression is evaluated in data, and a vector is used as given. subset is applied to data before the power gate, so the counts describe the rows fitted. fine_gray refuses the four row arguments.

check_power

Logical; run the events-per-variable gate (default TRUE).

warn_underpowered

Logical; warn when the gate flags the model under-powered (default TRUE). Ignored when on_underpowered = "abstain".

on_underpowered

One of "warn" (default) or "abstain". With "warn" the model is fitted, with a warning when warn_underpowered is TRUE. With "abstain" a model the gate flags under-powered is not fitted, and a sest_refusal() is returned instead.

Value

A sest_fit object, or a sest_refusal() when on_underpowered = "abstain" and the power gate is not satisfied.

Details

The left-hand side of formula is a survival::Surv() response. Extra arguments in ... pass to the backend estimator.

Examples

fit <- survestimand(survival::Surv(time, status) ~ age + sex, survival::lung)
fit
#> <sest_fit> method = cox (cox, via survival)
#>   n = 228   events = 165
#>   power: ok (82.5 events/predictor)
#>   coefficients:
#>     age     sex 
#>  0.0170 -0.5132 
coef(fit)
#>         age         sex 
#>  0.01704533 -0.51321852 
if (requireNamespace("flexsurv", quietly = TRUE)) {
  survestimand(survival::Surv(time, status) ~ age + sex, survival::lung,
               method = "weibull")
}
#> <sest_fit> method = weibull (parametric, via flexsurv)
#>   n = 228   events = 165
#>   power: ok (82.5 events/predictor)
#>   coefficients:
#>   shape   scale     age     sex 
#>  0.2823  6.2749 -0.0123  0.3821