first_order_GLM: first-order solution for the GLM maximum likelihood problem

View source: R/first_order_glm.R

first_order_GLMR Documentation

first-order solution for the GLM maximum likelihood problem

Description

This is a function taking X, y and required parameters, and using gradient descent to fit a GLM

Usage

first_order_GLM(
  X,
  y,
  family,
  lr = "constant",
  gamma = 1e-04,
  iter = 1e+05,
  tol = 1e-15,
  decay = 0
)

Arguments

X

numeric data matrix

y

response vector

family

the family of GLM

lr

adaptive or constant learning rate, input "step" or "constant", default is constant

gamma

gamma_k, the starting learning rate, default is 0.0001

iter

max number of iterations, default is 1e5

tol

tolerance, default is 1e-15

decay

step decay rate if chosen step for lr, default is 0.00

Examples

n <- 5000; p <- 3
beta <- c(-1, 0.2, 0.1)
X <- cbind(1, matrix(rnorm(n * (p- 1)), ncol = p - 1))
eta <- X %*% beta
lambda <- exp(eta)
y <- rpois(n, lambda = lambda)
first_order_GLM(X,y,family = poisson(link = "log"), lr = "constant")


carolineying/bis557 documentation built on April 17, 2023, 4 a.m.