future_mids | R Documentation |
'mice::mice.mids()'
Using {future}
future_mids()
is analogous to mice::mice.mids()
, but parallelizes chains
using the {furrr}
package and stops early if convergence is detected using
the R-hat statistic
(see the future_mice()
documentation
for details).
future_mids(
obj,
newdata = NULL,
maxit = 100L,
minit = min(5L, maxit),
quiet = FALSE,
chunk_size = 1L,
rhat_max = 1.05,
progressor = NULL,
update_call = TRUE,
...
)
obj |
A |
newdata |
An optional |
maxit |
The number of additional Gibbs sampling iterations. |
minit |
The minimum number of iterations to run. This is also the number
of iterations used to assess convergence. Convergence is defined as
|
quiet |
Should convergence messages and warning be suppressed? |
chunk_size |
The average number of chains per future. Differs from the
usual |
rhat_max |
The R-hat threshold used to assess convergence.
Convergence is defined as |
progressor |
An optional |
update_call |
Should |
... |
Named arguments that are passed down to the univariate imputation functions. |
Returns an S3 object of class mids
(multiply imputed data set)
# Run in parallel (just two cores to avoid hogging resources)
# Picking a number of workers that divides `m` evenly can help performance
future::plan("multisession", workers = pmin(2L, future::availableCores()))
# Run `mice::mice()`
# `m` and `maxit` are small here to keep runtime short
mids <- mice::mice(mice::nhanes, m = 2L, maxit = 1L)
# Run for additional iteration
mids <- future_mids(mids, maxit = 1L)
## Not run:
# Run until convergence
mids <- future_mids(mids, maxit = 100L)
mids
## End(Not run)
# Reset future plan
future::plan("sequential")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.