library("gamlss2")
data("HarzTraffic", package = "gamlss2")
## specify the model formula
f <- bikes ~ s(yday, bs = "cc") + s(temp) + s(rain) | .
## estimate model using RS (default)
m1 <- gamlss2(f, data = HarzTraffic, family = NBI, optimizer = RS)
## now with CG
m2 <- gamlss2(f, data = HarzTraffic, family = NBI, optimizer = CG)
## first 2 RS iterations and afterwards switch to CG
m3 <- gamlss2(f, data = HarzTraffic, family = NBI, CG = 3)Rigby and Stasinopoulos (RS) & Cole and Green (CG) Algorithm
Description
The function RS() implements the algorithm of Rigby and Stasinopoulos, the function CG() implements the algorithm of Cole and Green for estimating a GAMLSS with gamlss2.
Usage
## rigby and stasinopoulos algorithm
RS(x, y, specials, family, offsets,
weights, start, xterms, sterms, control)
## cole and green algorithm
CG(x, y, specials, family, offsets,
weights, start, xterms, sterms, control)
Arguments
x
|
The full model matrix to be used for fitting. |
y
|
The response vector or matrix. |
specials
|
A named list of special model terms, e.g., including design and penalty matrices for fitting smooth terms using smooth.construct.
|
family
|
A family object, see gamlss2.family.
|
offsets
|
If supplied, a list or data frame of possible model offset. |
weights
|
If supplied, a numeric vector of weights. |
start
|
Starting values, either for the parameters of the response distribution or, if specified as a named list in which each element of length one is named with “(Intercept)”, the respective intercepts are initialized. If starting values are specified as a named list, data frame or matrix, where each element/column is a vector with the same length as the number of observations in the data, the respective predictors are initialized with these. See the examples for gamlss2.
|
xterms
|
A named list specifying the linear model terms. Each named list element represents one parameter as specified in the family object. |
sterms
|
A named list specifying the special model terms. Each named list element represents one parameter as specified in the family object. |
control
|
Further control arguments as specified within the call of gamlss2. See the details.
|
Details
Functions RS() and CG() are called within gamlss2. Both functions implement a backfitting algorithm for estimating GAMLSS. For algorithm details see Rigby and Stasinopoulos (2005).
The functions use the following control arguments:
-
eps: Numeric vector of length 1 to 3, the stopping criterion for the global, per-parameter, and CG correction loops. The CG tolerance defaults to the per-parameter tolerance. -
maxit: Integer vector of length 1 to 3, the maximum number of global parameter sweeps and per-parameter IRLS/backfitting iterations. Default ismaxit = c(20, 50). For the CG algorithm, an optional third element limits the internal correction sweeps and defaults to the second element. Plain RS always performs one parameter sweep before checking global convergence; a third element is therefore ignored by RS. -
step: Numeric, the step length control parameter. Default isstep = 1. After the first update and with fixed smoothing parameters, the step is applied to a complete parameter update in RS and to a complete correction sweep in CG. A smoothing-parameter change and its coefficients are instead accepted or rejected as one state. Ifstepis set smaller than 1, it might be appropriate to lower the stopping criterioneps, too. -
autostep: Logical, should an update that decreases its objective be halved automatically? Default isTRUE. The objective is the likelihood for unpenalized updates and the penalized likelihood when smoothing parameters are fixed. Smoothing-parameter changes use the specified smoothing criterion, the default local REML update, or the term-specific local ML update. -
sigma.tol: Numeric between zero and one. If a model contains a smooth forsigma, warn when its smallest fitted value divided by its median is less thansigma.tol. The default is0.001; use zero orFALSEto disable the diagnostic. This diagnostic does not constrain the fitted values. -
CG: Integer, the outer iteration in which to start the CG correction. Thus,CG = 5uses RS for the first four outer iterations and CG in the fifth.CG = 0starts with CG immediately; the default isCG = Inf. -
trace: Logical, should information be printed while the algorithm is running? -
rs.cache: Logical, reuse unchanged generated family evaluations and weighted matrix calculations within a fit? Default isTRUE. Reuse requires identical inputs and preserves the original arithmetic. User replacements of family callbacks are not memoized. Linear QR reuse is restricted to full-rank fits with strictly positive weights. SetFALSEto disable these caches, for example for comparisons. -
flush: Logical, useflush.consolefor displaying the current output in the console. -
ridge: Logical, should automatic ridge penalization be applied only to linear effects, without penalizing the intercept? For each parameter of the distribution the optimum ridge penalty is estimated using an information criterion. Possible options arecriterion = c(“aic”, “aicc”, “bic”, “gaic”, “gcv”). The default iscriterion = “gaic”and argumentK = 2, which can be set ingamlss2_control.
To facilitate the development of new algorithms for gamlss2, users can exchange them using the optimizer argument in gamlss2_control. Users developing new model fitting functions are advised to use these functions as templates and pass them to gamlss2_control. Alternatively, users can replace the optimizer function by adding a named list element, “optimizer”, to the family object. For instructions on setting up new families in gamlss2, see gamlss2.family.
Value
Functions RS() and CG() return a named list of class “gamlss2” containing the following objects:
fitted.values
|
A data frame of the fitted values of the predictors of the selected distribution. |
fitted.specials
|
A named list, one element for each parameter of the distribution, containing the fitted model object information of special model terms. |
fitted.linear
|
A named list, one element for each parameter of the distribution, containing the information on fitted linear effects. |
coefficients
|
A named list, one element for each parameter of the distribution, containing the estimated parameters of the linear effects. |
elapsed
|
The elapsed runtime of the algorithm. |
iterations
|
How many iterations the algorithm performed. |
converged
|
Logical, did the global iteration satisfy the stopping criterion? |
logLik
|
The final value of the log-likelihood of the model. |
control
|
All effective control arguments used by the optimizer. |
References
Rigby RA, Stasinopoulos DM (2005). “Generalized Additive Models for Location, Scale and Shape (with Discussion).” Journal of the Royal Statistical Society, Series C (Applied Statistics), 54, 507–554. doi:10.1111/j.1467-9876.2005.00510.x
See Also
gamlss2, gamlss2_control, gamlss2.family