Skip to contents

forkflow turns a space of defensible analytic choices into a single reproducible object. This vignette runs a small multiverse on the colon cancer trial that ships with the survival package, so it needs no download.

1. Prepare the cohort

d <- colon |>
  dplyr::filter(etype == 2) |>            # death endpoint
  tidyr::drop_na()

2. Enumerate the decision space

Every subset of the candidate adjusters is one defensible adjustment set.

specs <- adjuster_sets(
  c("age", "sex", "obstruct", "perfor", "adhere", "differ", "surg")
)
nrow(specs)   # 2^7 = 128 specifications
#> [1] 128

3. Fit the whole grid

results <- fit_multiverse(specs, function(spec) {
  f <- reformulate(c("node4", spec$adjusters[[1]]), "Surv(time, status)")
  coxph(f, data = d) |>
    tidy(conf.int = TRUE) |>
    dplyr::filter(term == "node4")
})

4. Summarise the vibration of effects

voe(results)
#> <vibration of effects>
#>   models             : 128
#>   median effect      : 2.630
#>   relative ratio     : 1.07   (p99 / p01)
#>   Janus fraction     : 1.00   (0 or 1 = stable sign)
#>   prop. significant  : 1.00

5. Visualise

spec_curve(results)

voe_volcano(results, colour = n_adjusters)

The relative ratio and the Janus fraction quantify how much the association for node4 depends on which covariates enter the model.