glm_first_order: a first-order solution for the GLM maximum likelihood problem...

Description Usage Arguments Examples

View source: R/glm-first-order.r

Description

This function solves GLM with a first order solution, which avoids the Hessian matrix. Here we could use either a constant step size or a an adaptive step size.

Usage

1
glm_first_order(X, Y, mu_fun, steps, maxit = 10000, tol = 1e-20)

Arguments

X

data matrix

Y

Response vector

mu_fun

The inverse of link function

steps

the step size.

maxit

Default is 10000. The maximum number of iterations.

tol

Default is 1e-20. The minimum difference between the old beta and the update beta.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(100)
maxit=10000
steps1=rep(0.001,maxit)
n=100 
p=2
X=matrix(rnorm(n*p),n,p)
X=cbind(1,X)
beta=matrix(c(2,4,6),1,3)
prob=exp(beta%*%t(X))/(1+exp(beta%*%t(X)))
y=rbinom(n,size = 1, prob = prob)
glm_first_order(X,y, binomial(link="logit")$linkinv,steps1,maxit=maxit)

cz354/bis557 documentation built on Dec. 20, 2020, 3:05 a.m.