The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The futurize package allows you to easily turn sequential code
into parallel code by piping the sequential code to the futurize()
function. Easy!
library(futurize)
plan(multisession)
library(lme4)
gm <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial)
gm_all <- allFit(gm) |> futurize()
This vignette demonstrates how to use this approach to parallelize lme4
functions such as allFit() and bootMer().
The lme4 package fits linear and generalized linear mixed-effects
models. Its allFit() function fits models using all available
optimizers to check for convergence issues, and bootMer() performs
parametric bootstrap inference. Both are excellent candidates for
parallelization.
The allFit() function fits a model with each available optimizer,
which can be done in parallel:
library(lme4)
## Fit a generalized linear mixed model
gm <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial)
## Try all available optimizers
gm_all <- allFit(gm)
Here allFit() evaluates sequentially, but we can easily make it
evaluate in parallel by piping to futurize():
library(futurize)
library(lme4)
gm <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial)
gm_all <- allFit(gm) |> futurize()
This will distribute the optimizer fits across the available parallel workers, given that we have set up parallel workers, e.g.
plan(multisession)
The built-in multisession backend parallelizes on your local
computer and works on all operating systems. There are [other
parallel backends] to choose from, including alternatives to
parallelize locally as well as distributed across remote machines,
e.g.
plan(future.mirai::mirai_multisession)
and
plan(future.batchtools::batchtools_slurm)
The bootMer() function performs parametric bootstrap inference on
fitted models:
library(futurize)
plan(multisession)
library(lme4)
## Fit a linear mixed model
fm <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy)
## Bootstrap the fixed-effect coefficients
boot_coef <- function(model) fixef(model)
b <- bootMer(fm, boot_coef, nsim = 100) |> futurize()
The following lme4 functions are supported by futurize():
allFit()bootMer()These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.