Learn R Programming

smcfcs (version 1.7.1)

smcfcs.parallel: Parallel substantive model compatible imputation

Description

Runs substantive model compatible imputation using parallel cores

Usage

smcfcs.parallel(
  smcfcs_func = "smcfcs",
  seed = NULL,
  m = 5,
  n_cores = parallel::detectCores() - 1,
  cl_type = "PSOCK",
  outfile = "",
  ...
)

Value

An object of type "smcfcs", as would usually be returned from smcfcs.

Arguments

smcfcs_func

Specifies which base smcfcs function to call. Possible values are `smcfcs`, `smcfcs.casecohort`, `smcfcs.dtasam`, `smcfcs.nestedcc`. Defaults to `smcfcs`.

seed

Optional seed, set as `set.seed` when `n_cores = 1`, or as `parallel::clusterSetRNGStream` when `n_cores > 1`.

m

Number of imputed datasets to generate.

n_cores

Number of cores over which to split the `m` imputations. If `n_cores` is not divisible exactly by `m`, one of the cores will perform more/less imputations that the rest such that the final result still contains `m` imputed datasets.

cl_type

Either "PSOCK" or "FORK". If running on a Windows system "PSOCK" is recommended, otherwise for Linux/Mac machines "FORK" tends to offer faster computation - see parlmice.

outfile

Optional character path to location for output from the workers. Useful to diagnose rejection sampling warnings. File path must be formulated as "path/to/filename.txt".

...

Additional arguments to pass on to smcfcs, smcfcs.casecohort, smcfcs.dtsam, or smcfcs.nestedcc.

Author

Edouard F. Bonneville e.f.bonneville@lumc.nl

Jonathan Bartlett jonathan.bartlett1@lshtm.ac.uk

Details

This function can be used to call one of the substantive model compatible imputation methods using parallel cores, to reduce computation time. You must specify the arguments required for the standard smcfcs call, and then specify your the arguments for how to use parallel cores.

Examples

Run this code
if (FALSE) {
# Detect number of cores
parallel::detectCores()

imps <- smcfcs.parallel(
smcfcs_func="smcfcs",
seed = 2021,
n_cores = 2,
originaldata = smcfcs::ex_compet,
m = 10,
smtype = "compet",
smformula = list(
"Surv(t, d == 1) ~ x1 + x2",
"Surv(t, d == 2) ~ x1 + x2"
),
method = c("", "", "norm", "norm")
)
}

Run the code above in your browser using DataLab