library("gamlss2")
f <- dist ~ s(speed) | s(speed)
## estimate models with different information criteria
m0 <- gamlss2(f, data = cars, family = GA, criterion = "reml")
m1 <- gamlss2(f, data = cars, family = GA, criterion = "aic")
m2 <- gamlss2(f, data = cars, family = GA, criterion = "bic")
m3 <- gamlss2(f, data = cars, family = GA, criterion = "gaic")
m4 <- gamlss2(f, data = cars, family = GA, criterion = "gaic", K = 4)
m5 <- gamlss2(f, data = cars, family = GA, criterion = "ncv")
m6 <- gamlss2(f, data = cars, family = GA, criterion = "ncv", ncv = 2)Control Parameters
Description
Control parameters for fitting GAMLSS models with gamlss2.
Usage
gamlss2_control(optimizer = RS, trace = TRUE,
flush = TRUE, light = FALSE, expand = TRUE,
model = TRUE, x = TRUE, y = TRUE,
fixed = FALSE, ...)
Arguments
optimizer
|
Function, the optimizer to be used for fitting. Use JR for joint REML estimation.
|
trace
|
Logical, should information be printed while the algorithm is running? |
flush
|
Logical, whether to use flush.console to display current output in the console.
|
light
|
Logical, if set to light = TRUE, no model frame, response, model matrix and other design matrices will be part of the return value.
|
expand
|
Logical, if fewer formulas are supplied than there are parameters of the distribution, should intercept-only formulas be added automatically? |
model
|
Logical, should the model frame be included as a component of the returned object. |
x
|
Logical, indicating whether the model matrix should be included as a component of the returned object. |
y
|
Logical, should the response be included as a component of the returned object. |
fixed
|
Named logical vector indicating which parameters should be fixed during estimation. See gamlss2_start for examples.
|
…
|
Further control parameters to be included in the return value, for example parameters used by the optimizer function RS.
|
Details
The set of control parameters can be extended. For example, if a different optimizer is used, newly specified control parameters are passed on to that optimizer automatically.
With optimizer = JR, a direct joint REML solver uses cached designs and penalties for families providing a density and predictor-to-parameter map. The controls jr.inner, jr.eps, jr.maxit, jr.outer.maxit, and jr.outer.maxeval are documented in JR.
For mgcv-based smooth terms, smoothing parameters are selected by local REML updates by default (criterion = “reml”). These updates use the current working response and weights. With one penalty matrix this is the usual Schall update; with multiple penalty matrices all smoothing parameters are updated together using the extended Fellner–Schall trace equations. This is a local working-model REML update. Explicit choices such as “gcv”, “aic”, “aicc”, “bic”, and “ncv” retain their respective selection methods.
For the RS and CG optimizers, argument demmler.reinsch controls the use of a weighted Demmler–Reinsch reparameterization when selecting the smoothing parameter of an eligible single-penalty smooth, including multivariate smooths. The default, “auto”, uses the native reparameterization for local REML updates, and for quadratic criteria after the initial outer iteration. Set demmler.reinsch = TRUE to force it for eligible updates, or FALSE to disable it. For quadratic criteria, the initial outer iteration continues to use the direct solver; with numerical gradients or native.wfit = FALSE, automatic reparameterization is delayed until the current search reaches the edge of its one-decade search window.
Within an RS or CG fit, the reparameterization is cached while the design matrix, weights, penalty, and binning are unchanged. A new working response only requires updating its projection into the cached basis. The declared penalty rank keeps the null space unpenalized even at large smoothing parameters.
Analytic gradients are used by default for quadratic smoothing criteria (GCV, AIC, GAIC, AICc, and BIC), including smooths with multiple penalties. Set analytic.gradient = FALSE to use numerical gradients. Criteria using logLik = TRUE continue to use numerical gradients, with native direct solves and family likelihood evaluation in R. Nearly exact fits use observation-space residuals to avoid cancellation in the quadratic RSS.
Neighbourhood cross-validation can be selected with criterion = “ncv”. If ncv is omitted, singleton neighbourhoods are used, corresponding to leave-one-observation-out cross-validation. For ordered data, a numeric ncv = k uses the observation together with up to k neighbours on either side. Larger neighbourhoods generally provide more smoothing and can account for short-range dependence, at increased computational cost. For ordered data, small values such as ncv = 1 or ncv = 2 are often preferable to the singleton default. Custom neighbourhoods can also be supplied as a list through a smooth term’s xt argument, for example s(x, xt = list(ncv = neighbourhoods)), where neighbourhoods has one integer index vector per observation and each vector contains its target observation.
Smooths with fixed smoothing parameters and multiple-penalty smooths use the direct solver. For local REML, the common range of the penalty matrices is cached and the coupled update is evaluated in native code. Single-penalty updates use the constrained penalty null space and the Demmler–Reinsch basis when available. The term-specific “ml” method used by pb() retains its existing update. All methods return coefficients and covariance at the reported smoothing parameters.
Value
A list with the arguments specified.
References
Demmler, A. and Reinsch, C. (1975). Oscillation Matrices with Spline Smoothing. Numerische Mathematik, 24(5), 375–382. doi:10.1007/BF01437406
Wood, S. N. (2026). On Neighbourhood Cross Validation. Statistical Science, in press. doi:10.48550/arXiv.2404.16490
See Also
RS, gamlss2, gamlss2_start