Skip to contents

savvy_glm2 extends the classical glm2 function from the glm2 package by embedding a set of shrinkage-based methods within the iteratively reweighted least squares (IRLS) algorithm. These shrinkage methods (implemented via savvy_glm.fit2) are designed to improve convergence and estimation accuracy. The user can specify one or more methods through the model_class argument. When multiple methods are provided (default is c("St", "DSh", "SR", "GSR", "Sh")), the function can evaluate them in parallel (controlled by the use_parallel argument) and selects the final model based on criterion.

Usage

savvy_glm2(formula, family = gaussian, data, weights,
               model_class = c("St", "DSh", "SR", "GSR", "Sh"), subset,
               na.action, start = NULL, etastart, mustart, offset,
               control = list(...), model = TRUE,
               method = "savvy_glm.fit2", x = FALSE, y = TRUE,
               contrasts = NULL, use_parallel = TRUE, ...)

Arguments

formula

An object of class "formula": a symbolic description of the model to be fitted. As for glm2.

family

A description of the error distribution and link function to be used in the model. As for glm2.

data

An optional data frame, list or environment containing the variables in the model. As for glm2.

weights

An optional vector of weights to be used in the fitting process. As for glm2.

model_class

A character vector specifying the shrinkage method(s) to be used in the underlying fitter savvy_glm.fit2. Allowed values are "St", "DSh", "SR", "GSR", and "Sh". If a single value is provided, only that method is executed. If multiple values are provided, the specified methods are evaluated (in parallel if use_parallel = TRUE) and the one with the lowest AIC is returned. By default, the value is c("St", "DSh", "SR", "GSR"); note that the "Sh" method is considered only if explicitly included.

subset

An optional vector specifying a subset of observations to be used in the fitting process. As for glm2.

na.action

A function which indicates what should happen when the data contain NAs. As for glm2.

start

Starting values for the parameters in the linear predictor. As for glm2.

etastart

Starting values for the linear predictor. As for glm2.

mustart

Starting values for the vector of means. As for glm2.

offset

An optional vector specifying a priori known component to be included in the linear predictor during fitting. As for glm2.

control

A list of control parameters to pass to the iterative fitting process. As for glm2.

model

A logical value indicating whether the model frame should be included as a component of the returned value. As for glm2.

method

The method to be used in fitting the model. The default is savvy_glm.fit2. This method uses IRLS with custom optimization methods to ensure better convergence by evaluating different fitting methods and selecting the best one based on AIC. As in glm2, the alternative method "model.frame" returns the model frame and does no fitting.

x

A logical value indicating whether the model matrix used in the fitting process should be returned as a component of the returned value. As for glm2.

y

A logical value indicating whether the response vector used in the fitting process should be returned as a component of the returned value. As for glm2.

contrasts

An optional list. See the contrasts.arg of model.matrix.default. As for glm2.

use_parallel

A logical value specifying whether to evaluate multiple shrinkage methods in parallel. Defaults to TRUE. Setting this to FALSE forces sequential evaluation.

...

Additional arguments to be passed to the low level regression fitting functions. As for glm2.

Value

The value returned by savvy_glm2 has exactly the same structure as that returned by glm2, except for:

method

the name of the fitter function used, which by default is savvy_glm.fit2.

chosen_fit

the name of the chosen fitting method based on AIC.

Details

savvy_glm2 improves upon the standard Generalized Linear Model (GLM) fitting process by incorporating shrinkage estimator functions (St_ost, DSh_ost, SR_ost, GSR_ost, and optionally Sh_ost) within the IRLS algorithm. The function begins with initial parameter estimates and iteratively updates the coefficients using the specified shrinkage methods. When multiple methods are specified in model_class, they may be evaluated in parallel (if use_parallel = TRUE), and the final model is selected based on the lowest AIC. In cases where any candidate model returns an NA or non-finite AIC (such as when using quasi-likelihood families), the deviance is used uniformly as the selection criterion. This approach ensures that the chosen model represents the best trade-off between fit and complexity given the data and the specified family.

References

Marschner, I. C. (2011). glm2: Fitting Generalized Linear Models with Convergence Problems. The R Journal, 3(2), 12–15. doi:10.32614/RJ-2011-012. Available at: https://doi.org/10.32614/RJ-2011-012.

Asimit, V., Cidota, M. A., Chen, Z., & Asimit, J. (2025). Slab and Shrinkage Linear Regression Estimation. Retrieved from https://openaccess.city.ac.uk/id/eprint/35005/.

SavvyGLM article. https://ziwei-chenchen.github.io/savvyGLM.

See also

Author

Ziwei Chen and Vali Asimit
Maintainer: Ziwei Chen <ziwei.chen.3@citystgeorges.ac.uk>