glm_gradient: GLM based on gradient.

Description Usage Arguments Value Examples

View source: R/glm_gradient.R

Description

A first-order solution for the GLM maximum likelihood problem using gradient information,including both a constant step size along with an adaptive one.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
glm_gradient(
  X,
  y,
  family,
  step = c("constant", "momentum"),
  lambda = 1e-05,
  gamma = 0.8,
  maxiter = 1000,
  tol = 1e-12
)

Arguments

X

The input design matrix.

y

The input response vector.

family

The error distribution and link function.

step

An option to choose whether use a constant step size or an adaptive one,momentum.

lambda

A number indicating the learning rate.

gamma

A fraction indicating the momentum step size.

maxiter

A number indicating the maximum number iterations.

tol

A number indicating the covergence of the algorithm.

Value

A list of estimated coefficients.

Examples

1
2
3
4
5
6
7
set.seed(999)
n <- 1000; p <- 5;
X <- cbind(1, matrix(rnorm(n * (p-1)), ncol = p-1))
beta <- c(-1, 0.3, 2, 0.1, 0.5)
Y <- rpois(n, lambda = exp(X %*% beta))
glm_gradient(X,Y,family=poisson(link = "log"),step = "constant")
glm_gradient(X,Y,family=poisson(link = "log"),step = "momentum")

lyran92/bis557 documentation built on Dec. 21, 2020, 10:03 p.m.