Parallelly Run Cox Analysis in Batch Mode

ezcox_parallel(
  data,
  covariates,
  controls = NULL,
  time = "time",
  status = "status",
  batch_size = 100,
  global_method = c("likelihood", "wald", "logrank"),
  keep_models = FALSE,
  return_models = FALSE,
  model_dir = file.path(tempdir(), "ezcox"),
  parallel = TRUE,
  verbose = FALSE
)

Arguments

data

a data.frame containing variables, time and os status.

covariates

column names specifying variables.

controls

column names specifying controls.

time

column name specifying time, default is 'time'.

status

column name specifying event status, default is 'status'.

batch_size

processing size in a batch.

global_method

method used to obtain global p value for cox model, should be one of "likelihood", "wald", "logrank". The likelihood-ratio test, Wald test, and score logrank statistics. These three methods are asymptotically equivalent. For large enough N, they will give similar results. For small N, they may differ somewhat. The Likelihood ratio test has better behavior for small sample sizes, so it is generally preferred.

keep_models

If TRUE, keep models as local files.

return_models

default FALSE. If TRUE, return a list contains cox models.

model_dir

a path for storing model results.

parallel

if TRUE, do parallel computation by furrr package.

verbose

if TRUE, print extra info. If parallel is TRUE, set verbose to FALSE may speed up.

Value

a ezcox object

Author

Shixiang Wang w_shixiang@163.com

Examples

library(survival)
t <- ezcox_parallel(lung, covariates = c("sex", "ph.ecog"), controls = "age")
#> Loading required namespace: furrr
t
#> # A tibble: 4 × 12
#>   Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref    beta    HR lower…⁵ upper…⁶
#>   <chr>    <lgl>     <chr>   <chr>     <int> <int>   <dbl> <dbl>   <dbl>   <dbl>
#> 1 sex      FALSE     sex     sex         228   228 -0.513  0.599   0.431   0.831
#> 2 sex      TRUE      age     age         228   228  0.017  1.02    0.999   1.04 
#> 3 ph.ecog  FALSE     ph.ecog ph.ecog     227   227  0.443  1.56    1.24    1.96 
#> 4 ph.ecog  TRUE      age     age         228   228  0.0113 1.01    0.993   1.03 
#> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
#> #   variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
#> #   ⁵​lower_95, ⁶​upper_95