svycoxme {svycoxme}R Documentation

Survey-weighted mixed-effects Cox models

Description

Fit a mixed-effect proportional hazards model to data from a complex design.

Usage

svycoxme(
  formula,
  design,
  subset = NULL,
  rescale = TRUE,
  control = coxme::coxme.control(),
  ...
)

## S3 method for class 'DBIsvydesign'
svycoxme(
  formula,
  design,
  subset = NULL,
  rescale = TRUE,
  control = coxme::coxme.control(),
  ...
)

## S3 method for class 'survey.design'
svycoxme(
  formula,
  design,
  subset = NULL,
  rescale = TRUE,
  control = coxme::coxme.control(),
  ...
)

## S3 method for class 'svyrep.design'
svycoxme(
  formula,
  design,
  subset = NULL,
  rescale = TRUE,
  control = coxme::coxme.control(),
  multicore = getOption("survey.multicore"),
  return.replicates = FALSE,
  ...
)

Arguments

formula

Model formula.

design

survey.design object. It must contain all variables in the formula.

subset

Expression to select a subpopulation.

rescale

Rescale weights to improve numerical stability.

control

Optional list of coxme control options. See coxme.control for details.

...

Other arguments passed to coxme.

multicore

For replicate weight designs. Should parallel processing be used?

return.replicates

For replicate weight designs. Should replicates be returned?

Details

Parallel processing is done with future_lapply. Future planning is left to the user, e.g. using plan before the call to svycoxme. Note that svycoxme.DBIsvydesign has not been implemented yet.

Value

An object of class svycoxme.

Examples

des <- survey::svydesign(ids = ~group_id, weights = ~weight, data = samp_srcs)
fit1 <- svycoxme(survival::Surv(stat_time, stat) ~ X1 + X2 + X3 + (1 | group_id),
                 design = des)
summary(fit1)

# with replicate weights (only 10 replicates are used to reduce CPU time)
repdes <- survey::as.svrepdesign(des, type = "bootstrap", replicates = 10)
fit2 <- svycoxme(survival::Surv(stat_time, stat) ~ X1 + X2 + X3 + (1 | group_id),
                 design = repdes)
summary(fit2)

# use multicore processing (`n_cores = 2` to comply with CRAN policy). Otherwise,
# something like, `floor(parallelly::availableCores() * 0.8)`, could be used.

n_cores = 2
future::plan("multicore", workers = n_cores)
fit3 <- svycoxme(survival::Surv(stat_time, stat) ~ X1 + X2 + X3 + (1 | group_id),
                 design = repdes, multicore = TRUE)
all.equal(coef(fit2), coef(fit3))
future::plan("sequential")


[Package svycoxme version 1.0.0 Index]