Learn R Programming

glmmTMB (version 1.0.2.1)

glmmTMBControl: Control parameters for glmmTMB optimization

Description

Control parameters for glmmTMB optimization

Usage

glmmTMBControl(
  optCtrl = NULL,
  optArgs = list(),
  optimizer = nlminb,
  profile = FALSE,
  collect = FALSE,
  parallel = NULL,
  eigval_check = TRUE
)

Arguments

optCtrl

Passed as argument control to optimizer. Default value (if default nlminb optimizer is used): list(iter.max=300, eval.max=400)

optArgs

additional arguments to be passed to optimizer function (e.g.: list(method="BFGS") when optimizer=optim)

optimizer

Function to use in model fitting. See Details for required properties of this function.

profile

Logical; Experimental option to improve speed and robustness when a model has many fixed effects

collect

Logical; Experimental option to improve speed by recognizing duplicated observations.

parallel

Numeric; Setting number of OpenMP threads to evaluate the negative log-likelihood in parallel

eigval_check

Check eigenvalues of variance-covariance matrix? (This test may be very slow for models with large numbers of fixed-effect parameters.)

Details

The general non-linear optimizer nlminb is used by glmmTMB for parameter estimation. It may sometimes be necessary to tweak some tolerances in order to make a model converge. For instance, the warning ‘iteration limit reached without convergence’ may be fixed by increasing the number of iterations using something like

glmmTMBControl(optCtrl=list(iter.max=1e3,eval.max=1e3)).

The argument profile allows glmmTMB to use some special properties of the optimization problem in order to speed up estimation in cases with many fixed effects. Enable this option using

glmmTMBControl(profile=TRUE).

Control parameters may depend on the model specification, because each control component is evaluated inside TMBStruc, the output of mkTMBStruc. To specify that profile should be enabled for more than 5 fixed effects one can use

glmmTMBControl(profile=quote(length(parameters$beta)>=5)).

The optimizer argument can be any optimization (minimizing) function, provided that:

  • the first three arguments, in order, are the starting values, objective function, and gradient function;

  • it also takes a control argument;

  • it returns a list with elements (at least) par, objective, convergence (0 if convergence is successful) and message (the code internally handles output from optim(), by renaming the value component to objective)

Examples

Run this code
# NOT RUN {
## fit with default (nlminb) and alternative (optim/BFGS) optimizer
m1 <- glmmTMB(count~ mined, family=poisson, data=Salamanders)
m1B <- update(m1, control=glmmTMBControl(optimizer=optim,
               optArgs=list(method="BFGS")))
## estimates are *nearly* identical:
all.equal(fixef(m1), fixef(m1B))
# }

Run the code above in your browser using DataLab