Generalized Linear Models › Maximum Likelihood Estimation

Michael BrenndoerferApril 1, 20252 min read
Machine Learning from ScratchAll chapters
Part 4 of 9Regression Models
Chapter 40Generalized Linear Models › Maximum Likelihood Estimation
Reading section 5 of 12 · Maximum Likelihood Estimation · 2 minSection 5 of 12 · 2 min

Book contents

Section 5 of 12 · 2 min read

Generalized Linear Models › Maximum Likelihood EstimationOne section · Sections in this chapter5 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Unlike linear regression, GLMs typically don't have closed-form solutions and require iterative optimization to find the maximum likelihood estimates of the parameters. The likelihood function for a GLM is:

L(β)=∏i=1nf(yi∣β,xi)L(\boldsymbol{\beta}) = \prod_{i=1}^n f(y_i | \boldsymbol{\beta}, \mathbf{x}_i)

where:

  • L(β)L(\boldsymbol{\beta}) is the likelihood function (the probability of observing the data given the parameters)
  • β\boldsymbol{\beta} is the vector of regression coefficients (β=[β0,β1,…,βp]T\boldsymbol{\beta} = [\beta_0, \beta_1, \ldots, \beta_p]^T)
  • nn is the number of observations in the dataset
  • f(yi∣β,xi)f(y_i | \boldsymbol{\beta}, \mathbf{x}_i) is the probability density function (for continuous responses) or probability mass function (for discrete responses) of the chosen distribution for observation ii
  • yiy_i is the observed response value for observation ii
  • xi\mathbf{x}_i is the vector of predictor values for observation ii (i.e., xi=[1,xi1,xi2,…,xip]T\mathbf{x}_i = [1, x_{i1}, x_{i2}, \ldots, x_{ip}]^T where the first element is 1 for the intercept)
  • ∏i=1n\prod_{i=1}^n denotes the product over all nn observations (reflecting the assumption of independent observations)

The log-likelihood is:

ℓ(β)=∑i=1nlog⁡f(yi∣β,xi)\ell(\boldsymbol{\beta}) = \sum_{i=1}^n \log f(y_i | \boldsymbol{\beta}, \mathbf{x}_i)

where:

  • ℓ(β)\ell(\boldsymbol{\beta}) is the log-likelihood function (the logarithm of the likelihood)
  • log⁡\log denotes the natural logarithm
  • ∑i=1n\sum_{i=1}^n denotes the sum over all nn observations
  • Taking the logarithm converts the product to a sum, which is computationally more stable and prevents numerical underflow when dealing with many small probabilities

The maximum likelihood estimates are found by solving:

β^=arg⁡max⁡βℓ(β)\hat{\boldsymbol{\beta}} = \arg\max_{\boldsymbol{\beta}} \ell(\boldsymbol{\beta})

where:

  • β^\hat{\boldsymbol{\beta}} is the maximum likelihood estimate of the coefficient vector (the value that makes the observed data most probable)
  • arg⁡max⁡β\arg\max_{\boldsymbol{\beta}} finds the value of β\boldsymbol{\beta} that maximizes the log-likelihood function ℓ(β)\ell(\boldsymbol{\beta})

This is typically done using Iteratively Reweighted Least Squares (IRLS), which is an iterative algorithm that solves a sequence of weighted least squares problems.