Skip to contents

Calculate log-rank test as well as hazard ratio estimates for survival data, optionally adjusted for covariates and a stratification factor.

Usage

robin_surv(
  formula,
  data,
  treatment,
  comparisons,
  contrast = "hazardratio",
  test = "logrank",
  ...
)

Arguments

formula

(formula) A formula of analysis, of the form Surv(time, status) ~ treatment * strata + covariates.

data

(data.frame) Input data frame.

treatment

(formula) A formula of treatment assignment or assignment by stratification.

comparisons

(list) An optional list of comparisons between treatment levels to be performed, see details. By default, all pairwise comparisons are performed automatically.

contrast

(character(1)) The contrast statistic to be used, currently only "hazardratio" is supported.

test

(character(1)) The test to be used, currently only "logrank" is supported.

...

Additional arguments passed to the survival analysis functions, in particular se_method (please see the vignette for details).

Value

A surv_effect object containing the results of the survival analysis.

Details

The user can optionally specify a list of comparisons between treatment levels to be performed. The list must have two elements:

  • Treatment level indices of the treatment group.

  • Treatment level indices of the control group.

So for example if you would like to compare level 3 with level 1, and also level 3 with level 2 (but not level 2 with level 1) then you can specify: comparisons = list(c(3, 3), c(1, 2))

See also

surv_effect_methods for S3 methods.

Examples

robin_surv(
  formula = Surv(time, status) ~ sex * strata + meal.cal + age,
  data = surv_data,
  treatment = sex ~ strata
)
#> Model        :  Surv(time, status) ~ sex * strata + meal.cal + age 
#> Randomization:  sex ~ strata  ( Simple )
#> 
#> Contrast     :  Hazard ratio
#> 
#>                  Estimate Std.Err Z Value Pr(>|z|)   
#> Male v.s. Female  0.55219 0.19133  2.8861   0.0039 **
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Test         :  Log-Rank
#> 
#>                  Test Stat. Pr(>|z|)   
#> Male v.s. Female     2.9496 0.003181 **
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1