ridgeGLM: Ridge estimation of generalized linear models.

View source: R/ridgeGLMandCo.R

ridgeGLMR Documentation

Ridge estimation of generalized linear models.

Description

Function that evaluates the targeted ridge estimator of the regression parameter of generalized linear models.

Usage

ridgeGLM(Y, X, U=matrix(ncol=0, nrow=length(Y)), lambda, 
         lambdaG=0, Dg=matrix(0, ncol=ncol(X), nrow=ncol(X)), 
         target=rep(0, ncol(X)), model="linear", 
         minSuccDiff=10^(-10), maxIter=100)

Arguments

Y

A numeric being the response vector.

X

The design matrix of the penalized covariates. The number of rows should match the number of elements of Y.

U

The design matrix of the unpenalized covariates. The number of rows should match the number of elements of Y.

lambda

A positive numeric that is the ridge penalty parameter.

lambdaG

A positive numeric that is the generalized ridge penalty parameter.

Dg

A non-negative definite matrix of the unscaled generalized ridge penalty.

target

A numeric towards which the estimate is shrunken.

model

A character, either "linear" and "logistic" (a reference to the models currently implemented), indicating which generalized linear model model instance is to be fitted.

minSuccDiff

A numeric, the minimum distance between the loglikelihoods of two successive iterations to be achieved. Used only if model="logistic".

maxIter

A numeric specifying the maximum number of iterations. Used only if model="logistic".

Details

This function finds the maximizer of the following penalized loglikelihood: \mathcal{L}( \mathbf{Y}, \mathbf{X}, \mathbf{U}; \boldsymbol{\beta}, \boldsymbol{\gamma}) - \frac{1}{2} \lambda \| \boldsymbol{\beta} - \boldsymbol{\beta}_0 \|_2^2 - \frac{1}{2} \lambda_g ( \boldsymbol{\beta} - \boldsymbol{\beta}_0 )^\top \Delta_g ( \boldsymbol{\beta} - \boldsymbol{\beta}_0 ), with loglikelihood \mathcal{L}( \mathbf{Y}, \mathbf{X}; \boldsymbol{\beta}), response \mathbf{Y}, design matrices \mathbf{X} and \mathbf{U}, regression parameters \boldsymbol{\beta} and \boldsymbol{\gamma}, penalty parameter \lambda, shrinkage target \boldsymbol{\beta}_0, and generalized ridge penalty matrix \Delta_g. For more details, see van Wieringen, Binder (2020) and Lettink et al. (2022).

Value

A numeric, the generalized ridge estimate of the regression parameter. If a nonempty \mathbf{U} is supplied, the first few elements are the unpenalized effect estimates of the covariates that comprise this design matrix.

Note

The penalized IRLS (Iterative Reweighted Least Squares) algorithm for the evaluation of the generalized ridge logistic regression estimator may fail to converge for small penalty parameter values in combination with a nonzero shrinkage target.

Author(s)

W.N. van Wieringen.

References

van Wieringen, W.N. Binder, H. (2022), "Sequential learning of regression models by penalized estimation", submitted.

Lettink, A., Chinapaw, M.J.M., van Wieringen, W.N. (2022), "Two-dimensional fused targeted ridge regression for health indicator prediction from accelerometer data", submitted.

Examples

# set the sample size
n <- 50

# set the true parameter
betas <- (c(0:100) - 50) / 20

# generate covariate data
X <- matrix(rnorm(length(betas)*n), nrow=n)

# sample the response
probs <- exp(tcrossprod(betas, X)[1,]) / (1 + exp(tcrossprod(betas, X)[1,]))
Y     <- numeric()
for (i in 1:n){
    Y <- c(Y, sample(c(0,1), 1, prob=c(1-probs[i], probs[i])))
}

# set the penalty parameter
lambda <- 3

# estimate the logistic regression parameter
bHat <- ridgeGLM(Y, X, lambda=lambda, target=betas/2, model="logistic")

porridge documentation built on May 29, 2024, 1:37 a.m.