gdMomentum_GLM: Generalized Linear Model first order MLE using momentum...

Description Usage Arguments Examples

View source: R/glm_gradient.R

Description

This function implement a first-order solution for the GLM maximum likelihood problem using only gradient information with adaptive momentum gradient descent algorithm

Usage

1
gdMomentum_GLM(X, y, mu_fun, lambda, maxit = 10000, tol = 1e-05, gamma = 0.8)

Arguments

X

The design matrix

y

The response variable

mu_fun

The function of eta, which is the matrix multiplication of design matrix with vector beta

lambda

The stepsize in gradient descent updata

maxit

Integer maximum number of iterations

tol

Numeric tolerance parameter

gamma

The momentum term which indicates how much acceleration you want

Examples

1
2
3
4
5
6
 pd <- tibble(offers=c(rep(0,50),rep(1,30),rep(2,10),rep(3,7),rep(4,3)),
division=sample(c("A","B","C"),100,replace = TRUE),
exam=c(runif(50,60,80),runif(30,65,95),runif(20,75,95)))
y<- matrix(pd$offers,ncol = 1)
X<- model.matrix(offers~division+exam,data=pd)
gdMomentum_GLM(X,y,mu_fun=function(eta) exp(eta),lambda = 1e-3)

nixgank-wang/bis557 documentation built on Dec. 26, 2020, 9:54 p.m.