Learn R Programming

lme4 (version 1.1-21)

allFit: Refit a fitted model with all available optimizers

Description

Attempt to re-fit a [g]lmer model with a range of optimizers. The default is to use all known optimizers for R that satisfy the requirements (do not require explicit gradients, allow box constraints), in three categories; (i) built-in (minqa::bobyqa, lme4::Nelder_Mead, nlminbwrap), (ii) wrapped via optimx (most of optimx's optimizers that allow box constraints require an explicit gradient function to be specified; the two provided here are really base R functions that can be accessed via optimx, (iii) wrapped via nloptr; (iv)

Usage

allFit(m, meth.tab = NULL, data=NULL,
        verbose = TRUE,
        show.meth.tab = FALSE,
        maxfun = 1e5,
	parallel = c("no", "multicore", "snow"),
	ncpus = getOption("allFit.ncpus", 1L), cl = NULL)

Arguments

m

a fitted model

meth.tab

a matrix (or data.frame) with columns

method

the name of a specific optimization method to pass to the optimizer (leave blank for built-in optimizers)

optimizer

the optimizer function to use

data

data to be included with result (for later debugging etc.)

verbose

logical: report progress in detail?

show.meth.tab

logical: return table of methods?

maxfun

passed as part of optCtrl (see lmeControl)

parallel

The type of parallel operation to be used (if any). If missing, the default is taken from the option "boot.parallel" (and if that is not set, "no").

ncpus

integer: number of processes to be used in parallel operation: typically one would choose this to be the number of available CPUs.

cl

An optional parallel or snow cluster for use if parallel = "snow". If not supplied, a cluster on the local machine is created for the duration of the boot call.

Value

a list of fitted merMod objects (unless show.meth.tab is specified, in which case a data frame of methods is returned)

See Also

slice,slice2D from the bbmle package

Examples

Run this code
# NOT RUN {
library(lme4)
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
             data = cbpp, family = binomial)
## show available methods
allFit(show.meth.tab=TRUE) 
gm_all <- allFit(gm1)
ss <- summary(gm_all)
ss$fixef               ## extract fixed effects
ss$llik                ## log-likelihoods
ss$sdcor               ## SDs and correlations
ss$theta               ## Cholesky factors
ss$which.OK            ## which fits worked
# }

Run the code above in your browser using DataLab