Numerical controls for mmes
mmes_control.RdCreates the validated object passed to the control argument of
mmes. It collects every numerical choice of a fit:
the equation formulation, the linear solvers, covariance updates,
convergence, output, memory/threads and diagnostics. Statistical choices
(REML vs ML, exact vs Laplace vs PQL integration, fit vs solve) do not belong
here; they are declared in mmes_method. Starting values for
nonlinear parameters are given in mmes(start=) and family nuisance
parameters in mmes(familyParameters=).
Each argument is a module and is given as a named list; only the fields you
supply are changed and all others keep their defaults. For example,
mmes_control(solve=list(method="pcg", tol=1e-6), execution=list(seed=1)).
Unknown modules or fields, invalid values, and combinations that are not
mathematically admissible (for example PCG fields without
solve$method="pcg") stop with an informative error that names the
offending fields. A request can also be valid on its own but ineligible for
the model being fitted; mmes then stops rather than silently changing
the algorithm. The defaults reproduce the established sommer algorithm, so
mmes_control() is the right choice for most analyses.
Usage
mmes_control(formulation = "henderson", optimizer = list(), mode = list(),
working = list(), likelihood = list(), population = list(),
inference = list(), representation = list(), solve = list(),
logdet = list(), score = list(), curvature = list(), update = list(),
proposal = list(), convergence = list(), output = list(),
execution = list(), diagnostics = list())Arguments
- formulation
A single string selecting the equation domain.
"henderson"(default): coefficient-space mixed model equations (fixed and random effects together). Sparse and fast when the number of coefficients is moderate or the design is sparse. Required by most advanced options (PCG, Schur/banded elimination, compression, factor scores, selected inverse, PQL and Laplace GLMMs)."direct": observation-space direct inversion of the marginal covariance. Can be preferable when there are many more random coefficients than observations. Only models that support it accept it.
The factorization backend is chosen separately in
solve$method.- optimizer
Outer optimizer for nonlinear-parameter and native Laplace likelihood fits (Gaussian covariance engines use the AI/update modules below instead). Fields:
maxit:NULL(default, engine default) or a positive integer limiting outer iterations. Do not also set a differentconvergence$maxIters; the limit must be specified once.gradient:"auto"(default) uses native analytic gradients where available and reported numerical derivatives for reference expressions;"analytic"requires analytic scores and errors if unavailable;"central"uses central differences.algorithm: only"nlminb"is currently available.scoreTol:NULL(default, 0.001) or a positive number, the outer-score certificate for nonlinear specification fits. Not allowed for non-nonlinear models.
- mode
Conditional random-effect mode search used by Laplace and nonlinear fits (not by Gaussian or PQL working fits). Fields:
maxit: maximum Newton iterations per mode (default100).tol: score tolerance for mode convergence (default1e-8).stepTol: step tolerance that detects stalled refinement (default1e-8); a non-default value is supported only by nonlinear modes, native GLMM modes usetol.warmStart:"auto"(default; reuse successful modes for native GLMMs, deterministic cold starts for nonlinear models),"off"or"on"(errors for nonlinear models).starts:"deterministic"(only choice).
- working
Outer iterations of the penalized quasi-likelihood (PQL) working fit used for non-Gaussian mixed models by default. Fields:
maxit(default20),tol(default1e-5),estimateTheta(defaultFALSE;TRUEestimates the negative binomial theta conditionally on the random effects and requiresMASS::negative.binomial), andwarmStart(defaultTRUE, start each outer iteration from the previous solution). The inner Gaussian fits are controlled byconvergence.- likelihood
Algebra used by the native Laplace likelihood (see
mmes_method(integration="laplace")); it does not choose the Gaussian solver. Fields:backend:"auto"(default),"random"(algebra in random-effect space) or"observation"(in observation space). All compute the same approximation; only"auto"is accepted for non-Laplace fits.trace:"panels"(default; bounded dense solve panels sized byexecution$denseMemoryMB) or"selected".blocks:"off"(default) or"on"to use block-structured post-fit operations.
- population
Gauss quadrature for response-scale population predictions of nonlinear models. Fields:
order(initial order, default20),maxOrder(maximum order, default160, at most 512 and at least twiceorder) andtol(accuracy, default1e-7). If the accuracy is not met atmaxOrderor the workspace limit is hit, an error is raised.- inference
Post-fit numerical uncertainty for nonlinear models. Fields:
step(relative central-difference step, default1e-4, must be below 0.1),derivativeTol(derivative acceptance tolerance, default5e-3, below 1),curvatureTol(curvature tolerance, default1e-8, below 1) andmaxCondition(largest condition number accepted for the Hessian, default1e10, above 1). Standard errors are reported asNAwhen these safeguards fail.- representation
How equations and covariance operators are represented. Fields:
compression:"off"(default),"groups"(collapse exactly identical observation groups) or"classes"(also cache cross-products and derivative operands). Exact reductions for Gaussian Henderson fits with independent residuals and fixed diagonal weights.factorScores:"none"(default),"fixed-shape"or"profile"for equivalent latent representations of eligible low-rank-plus-diagonal (factor analytic/reduced rank) models; shape standard errors are unavailable with"profile".fixedRank:"error"(default; stop if the fixed design is rank deficient) or"drop"(fit a full-rank subset using sparse QR; omitted coefficients are returned as zeros, flagged insummary(fit)$betas, and are identification constraints, not estimates).equations:"normal"(default),"saddle-point"(augmented system; avoids forming the compatibility coefficient matrix whenoutput$coefficientMatrix=FALSE) or the experimental"conditional"(reusable sparse latent equations).sparseFactors:"auto","off"or"force"(TRUE/FALSEaccepted). Uses exact sparse precision operands for autoregressive, antedependence, SAR and CAR factors. Auto also keeps complete-grid separable residuals banded.gridAugment:"auto","off"or"force". Adds one zero-response row and dummy fixed effect per missing cell of a separable gridded residual so blocks are complete banded Kronecker precisions. Likelihood, variances and BLUEs/BLUPs are unchanged; outputs are mapped back to the observed design.matrixFree:"auto"(default),"off"or"force"; avoids assembling full Kronecker priors during PCG.
- solve
Linear solves and exact eliminations. Fields:
method:"auto"(default; the model decides),"ldlt"(sparse LDLT),"cholmod"(supernodal sparse Cholesky) or"pcg"(preconditioned conjugate gradients with stochastic traces; for very large sparse systems).PCG fields (only valid with
method="pcg"or known-covariance solving where noted):tol(relative tolerance, default1e-8);maxIters(CG limit,0= automatic);preconditioner("diagonal"default,"nystrom","block-jacobi"; solving permits diagonal and block-jacobi only);nystromRank(default32);warmStart(reuse accepted solutions, defaultFALSE);recycleRank(accepted points reused,0disables, default0);recycleMethod("coarse"default or"krylov", which needs positiverecycleRank);recycleStateandexportRecycle(import or export a serializable Krylov basis across compatible fits; defaultNULL/FALSE);rhsMethod("independent"default or"block");blockSize(block width, default16);residualRefresh(periodic residual replacement,0disables).Exact elimination switches, each
"auto"(default),"off"or"force":blockSchur(dense Schur, chain, banded or latent elimination),blockBanded(block-banded elimination, bandwidth at most 4),factorSchurMultiFactor(multi-factor Woodbury/Schur for latent low-rank layouts) anddFirstML(eliminate the random block before the fixed-effect Schur complement in ML). A forced request still obeys structural and memory checks.
- logdet
Log-determinant approximation used by PCG. Fields:
scaling("none"default or"diagonal", a symmetric scaling with exact determinant correction) andlanczosSteps(stochastic Lanczos quadrature depth, integer \(\ge 2\), default20).- score
Covariance-parameter derivatives and trace estimation. Fields:
traceProbes(probe budget for stochastic traces, default8),estimator("hutchinson"default or"control-variate", which uses a low-rank correction of dimensionrank, default16); the previous three apply only to PCG. AlsocovarianceChecks("auto"default,"off","force"; skips redundant positive-definiteness checks when certified),traceBatch("off"default,"auto","force"; batch exact LDLT traces) anddenseCrossproduct("auto"default; uses an exact weighted sparse Gram product for dense designs).- curvature
Information matrix used by the optimizer.
method:"exact-ai"(default; exact average information) or"hybrid-ai"(damped BFGS between exact refreshes).assembly:"sensitivity"(default) or"augmented-working"(exact coefficient-space working-variate absorption for Gaussian Henderson fits).reduced:"off"(default),"auto"or"force"; exact independent-direction AI assembly whenvccreduces the parameters.- update
How covariance parameters are updated.
method:"ai"(default average-information Newton steps),"em"(conditional EM for eligible factor analytic models) or"conditional-fa"(legacy EM selector).recovery:"em"(default) or"pxem", the EM-type direction used for recovery.blendWeight:NULL(default), a non-negative scalar or vector weighting the recovery direction (an integer larger than 1 requests a decaying schedule).commonScale:"off"(default),"auto"or"force"; analytic common variance scale plus profiled-shape AI for Gaussian fits where all product scales are free.- proposal
Scaling of proposed steps.
stepWeight:NULL(default) or positive scalar/vector multiplying the step; likelihood safeguards stay active.extrapolation:"none"(default) or"aitken"(safeguarded Aitken extrapolation).- convergence
Inner iterations and stopping rules. Fields:
maxIters(maximum covariance iterations, default30; reaching it is not proof of convergence),likelihoodTolandparameterTol(default1e-4; relative change in log-likelihood and in parameters), and, for PCG:accuracy("fixed"default or"adaptive", which grows probe budgets up tomaxTraceProbesandmaxLanczosSteps, defaulting toscore$traceProbesandlogdet$lanczosStepsand never smaller than them),logDetTolandscoreTol(empirical accuracy targets, default0.001).- output
What is computed after the fit. Fields:
inverse:0(default; no coefficient inverse or PEVs),1(random-effect PEVs from the selected inverse, without fullCi) or2(fullCiand PEVs; only advisable for small systems). Defer this work with0and callpostPEVlater. Native Laplace fits require0.covariance:"full"(default; standard errors of covariance parameters) or"none"(skip final covariance uncertainty; point estimates remain available).coefficientMatrix:TRUE(default) orFALSE(skip assembling the compatibility matrixC; needs saddle-point equations andinverse=0;C-based methods then need a refit).setup:FALSE(default) orTRUEto return the prepared design, covariance descriptors andvcParamstable without fitting (useful for buildingvccconstraints).selectedInverse:"auto"(default),"off"or"force"; exact selected inverse from CHOLMOD withinverse=1.panelSize: width of inverse-solve batches (default64), also used bypostPEVand Laplace predictions.
- execution
Resources and reproducibility. Fields:
denseMemoryMB(admission budget for dense workspaces, default1000; not a process memory cap),memoryPolicy("speed"default or"limit"to enforce the budget),gpu(FALSEdefault;TRUEuses eligible dense kernels on CUDA builds with usable NVIDIA libraries),gpuMinSize(minimum kernel size for the GPU, default256),blasThreads(NULLdefault, a positive integer or"auto"; BLAS only, OpenMP is configured separately),inverseTol(numerical stabilization and variance floor, default1e-6; not the PCG tolerance) andseed(non-negative integer identifying the stochastic probe stream, default0).- diagnostics
Messages and profiling. Fields:
verbose(TRUEdefault; print the iteration table and fit messages),dateWarning(TRUEdefault; package-age warning) andprofile("off"default,"auto"or"force"; phase timings stored inengineDiagnostics$profile, and seeprofile_nonlinearfor nonlinear fits).
Details
Switch-like fields. Fields documented as "auto", "off",
"force" also accept TRUE (force) and FALSE (off).
"auto" lets sommer use the option when the model is eligible, while
"force" requests it and errors if it is not admissible. A forced
request never bypasses mathematical, structural or memory checks.
Global options. Experimental-mode defaults, the memory budget and
GPU settings can be set through R options, e.g.
options(sommer.mme.denseMemoryMB=2000). Values given explicitly in
mmes_control() always override option-derived defaults, so use them
for reproducible analyses.
Common recipes.
Quiet fit:
mmes_control(diagnostics=list(verbose=FALSE)).More iterations:
mmes_control(convergence=list(maxIters=100)).Random-effect PEVs at fit time:
mmes_control(output=list(inverse=1)); or leaveinverse=0and callpostPEV.Skip standard errors of variance components for speed:
mmes_control(output=list(covariance="none")).Very large sparse system:
mmes_control(solve=list(method="pcg"), execution=list(seed=1)).Rank-deficient fixed design:
mmes_control(representation=list(fixedRank="drop")).Inspect the model without fitting:
mmes_control(output=list(setup=TRUE)).Limit threads and memory:
mmes_control(execution=list(blasThreads=2, denseMemoryMB=500)).
Migration. Numerical arguments removed from mmes() are now
fields of the modules above, e.g. henderson is
formulation, solver is solve$method, nIters is
convergence$maxIters, tolParConvLL and tolParConvNorm
are convergence$likelihoodTol and convergence$parameterTol,
tolParInv is execution$inverseTol, computeCi is
output$inverse, returnParam is output$setup,
pqlControl is working, and verbose/dateWarning
are diagnostics fields. REML and solveOnly moved to
mmes_method. The complete table is in the
sommer.mmes.options vignette.
Value
A list of class sommer_mmes_control with one element per module.
It is validated again by mmes() and stored in the fitted object as
fit$control. mmes() accepts only objects created by this
function.
References
Covarrubias-Pazaran G. Genome assisted prediction of quantitative traits using the R package sommer. PLoS ONE 2016, 11(6): doi:10.1371/journal.pone.0156744
Gilmour et al. 1995. Average Information REML: An efficient algorithm for variance parameter estimation in linear mixed models. Biometrics 51(4):1440-1450.
See also
mmes, mmes_method, postPEV,
vcc, profile_nonlinear; the vignette
vignette("sommer.mmes.options") for the full field reference, defaults,
eligibility rules and decision graph, and vignette("sommer.machinery")
for the engine.
Examples
dat <- data.frame(x=seq_len(12), y=1+seq_len(12)/2+sin(seq_len(12))/10)
## defaults, silenced
ctl <- mmes_control(diagnostics=list(verbose=FALSE, dateWarning=FALSE))
fit <- mmes(y~x, data=dat, control=ctl)
coef(fit)
## modules only override the fields supplied
ctl2 <- mmes_control(convergence=list(maxIters=50),
output=list(covariance="none"),
diagnostics=list(verbose=FALSE, dateWarning=FALSE))
ctl2$convergence$maxIters
ctl2$convergence$likelihoodTol
## invalid choices are rejected
try(mmes_control(solve=list(method="gauss")))