Skip to contents

Fisher scoring for the binomial and Poisson families with their canonical links. Separation is detected from the fitted probabilities rather than from a coefficient threshold: under separation the probabilities are pinned at 0/1 long before any coefficient grows large enough to trip a cut-off.

Usage

morie_esl_iwls(
  X,
  y,
  beta0 = NULL,
  family = "binomial",
  max_iter = 50L,
  tol = 1e-08,
  add_intercept = TRUE
)

Arguments

X

Design matrix, n by p, without an intercept column.

y

Response: 0/1 for binomial, non-negative counts for Poisson.

beta0

Starting coefficients; defaults to zeros.

family

"binomial" or "poisson".

max_iter

Maximum IRLS iterations.

tol

Convergence tolerance on the coefficient change.

add_intercept

Prepend a column of ones.

Value

List with beta, se, z, p_value, fitted, loglik, deviance, n_iter, converged, separated.

References

Hastie, T., et al. (2009). ESL (2nd ed.), Sec 4.4.1. Springer.

Examples

set.seed(1)
X <- matrix(rnorm(2000), ncol = 2)
y <- rbinom(1000, 1, plogis(-0.5 + 1.5 * X[, 1] - X[, 2]))
round(morie_esl_iwls(X, y)$beta, 1)
#> [1] -0.4  1.4 -0.9