glm.train: Donwscaling with generalized linear models (GLM).

View source: R/downsGLM.R

glm.trainR Documentation

Donwscaling with generalized linear models (GLM).

Description

Donwscaling with generalized linear models (GLM) with the base function glm.

Usage

glm.train(x, y, fitting = NULL, model.verbose = TRUE, stepwise.arg = NULL, ...)

Arguments

x

The grid data. Class: matrix.

y

The observations data. Class: matrix.

fitting

A string indicating the types of objective functions and how to fit the linear model.

model.verbose

A logic value. Indicates wether the information concerning the model infered is limited to the essential information (model.verbose = FALSE) or a more detailed information (model.verbose = TRUE, DEFAULT). This is recommended when you want to save memory. Only operates for GLM. or binomial families.

stepwise.arg

A list contatining two parameters: steps and direction. When performing a stepwise search we can limit the search by indicating a maximum number of variables to be included in the model (parameter steps). We can also indicate wheter we want to perform a forward or a backward search with the parameter direction. For more information step. Thus an example would be: stepwise.arg = list(steps = 5, direction = "backward"). Default is NULL what indicates an unlimited forward stepwise search.

...

Optional parameters. See the parameter fitting for more information.

  • fitting = NULL In this case the generalized linear model uses the glm function to fit the linear model. This is the default option. The optional parameters when fitting = NULL are:

    • family A string indicating a description of the error distribution. Options are family = c("gaussian","binomial","Gamma","inverse.gaussian","poisson","quasi","quasibinomial","quasipoisson"). The links can be also specified and can be found in family.

    • na.action A function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options, and is na.fail if that is unset. The ‘factory-fresh’ default is na.omit. Another possible value is NULL, no action. Value na.exclude can be useful.

  • fitting = "stepwise" Indicates a stepwise regression via glm and step. The optional parameters are the same than for fitting = NULL. The stepwise performs always a forward selection search stopping based on the AIC criterion.

  • fitting = c("L1","L2","L1L2","gLASSO"). These four options refer to ridge regression (L1 penalty), lasso regression (L2 penalty), elastic-net regression (L1L2 penalty) and group Lasso regression (group L2 penalty). The model is fitted via glmnet and the corresponding penalties are found via cv.glmnet. This function glmnet forces by default to standardize predictors, however we have changed it to standardize = FALSE, and standardization should be done prior to the downscaling process. The optional parameters when fitting = c("L1","L2","L1L2","gLASSO") are:

    • family A string indicating a description of the error distribution. Options are family = c("gaussian","binomial","Gamma","inverse.gaussian","poisson","quasi","quasibinomial","quasipoisson"). The links CAN NOT be specified as the glmnet has not been programmed to handle links. However, the default ones can be found in family. If fitting = "gLASSO" then family must be "mgaussian".

    • offset A vector of length nobs that is included in the linear predictor (a nobs x nc matrix for the "multinomial" family). Useful for the "poisson" family (e.g. log of exposure time), or for refining a model by starting at a current fit. Default is NULL. If supplied, then values must also be supplied to the predict function.

There are two things to consider. 1) If family = "binomial" then type = "response" when predicting values. 2) Except for fitting = "MP", for the rest of the fitting options, the parameter singlesite must be TRUE, unless we want a gLASSO which in this case singlesite must be FALSE.

Details

This function is internal and should not be used by the user. The user should use downscaleTrain or downscaleCV.

Value

The GLM model as returned from glm plus a list with information concerning the experiment.

Author(s)

J. Bano-Medina


SantanderMetGroup/downscaleR documentation built on Nov. 16, 2024, 1:35 a.m.