Introduction
Welcome back! In our previous lesson, we established the foundation for parameter estimation in Generalized Linear Models (GLMs) by learning how to formulate the log-likelihood function, . This function tells us how "plausible" a given set of model coefficients is, based on our observed data.
Our ultimate goal is to find the coefficients that maximize this function. From basic calculus, you know that to find the maximum of a function, you take its derivative, set it to zero, and solve. That's exactly what we're going to do today.
This lesson will focus on deriving the score equations, which are the set of equations obtained by differentiating the log-likelihood function with respect to each model parameter and setting the result to zero. Mastering this step is crucial as it forms the basis of the numerical algorithms used to fit GLMs.
The Score Function and Score Equations
The process of finding the maximum likelihood estimates (MLEs) involves these key steps:
- Formulate the log-likelihood function, . (You learned this last lesson).
- Differentiate with respect to each parameter to get the score function.
- Set these derivatives to zero to form the score equations.
- Solve the score equations for .
Let's formalize the definition of the score function.

The score function, denoted , is the vector of these partial derivatives:
The score equations are the system of equations we need to solve, which is simply the score function set to a vector of zeros:
The solution, , is our Maximum Likelihood Estimate.
Deriving the Score Equations: The General Case
While we can differentiate the log-likelihood for each specific distribution, it's more powerful to derive a general formula that works for any GLM in the exponential family. This requires the chain rule.
Recall the log-likelihood for a single observation :
We need to find . The parameters are linked to through the linear predictor and link function. Here is the chain of dependencies:
By the chain rule, the derivative is:
Let's find each component. The following resource provides the mathematical details for this derivation.
[PDF] MATH 523 - Generalized Linear Models - Léo Belzile, PhD
These notes from Léo Belzile's course on GLMs provide a concise derivation of the general form of the score equations. We'll focus on the section that assembles the chain rule.
Please read the short section 'Iteratively reweighted least-squares' on page 28, specifically focusing on the derivation steps near the bottom of the page that start with 'By the chain rule, ∂ℓ(y; θ, φ)/∂βj = ...' and the three key identities: dµ/dθ = V(µ), ∂η/∂βj = xj, and the one relating ∂ℓ/∂θ to (y-µ).
As shown in the resource, the components of the chain rule are:
- (since )
Putting it all together for one observation:
The full score equation for parameter is the sum over all observations, set to zero:
A Major Simplification: Canonical Links
This formula simplifies beautifully when we use a canonical link function. For a canonical link, . The chain rule becomes much shorter, as is no longer an intermediate step between and . The derivative is simply:
The score equation for with a canonical link is:
Since is a constant, we can ignore it for finding the root, giving the elegantly simple form:
This means the MLE is found at the point where the model's residuals, , are orthogonal to (uncorrelated with) the predictor variables . This is a direct generalization of the principle behind ordinary least squares regression.
Worked Example: Poisson Regression
Let's apply this to the Poisson GLM, which uses a canonical log link. In the previous lesson, we found its log-likelihood:
We can derive the score equations by direct differentiation. Let's see this in action.
[PDF] MATH 523 - Generalized Linear Models - Léo Belzile, PhD
Let's read the section 'Example 2.9 (Poisson regression)' in the MATH 523 notes. It shows the step-by-step differentiation of the Poisson log-likelihood.
Read 'Example 2.9 (Poisson regression)' on page 32. Follow how the partial derivative ∂ℓn(β)/∂βj is taken, leading to the final expression \sum_{i=1}^{n} x_{ij}(y_i - \mu_i).
As the resource demonstrates, differentiating with respect to a single parameter gives:
Since for a Poisson model with a log link, , we can rewrite this as:
Setting this to zero gives the score equation for :
This exactly matches the simplified formula for canonical links, since for the Poisson distribution, .
Worked Example: Logistic Regression
Now let's do the same for logistic regression, which uses a Binomial distribution and the canonical logit link. The log-likelihood is:
Let's see the derivation for its score equations.
[PDF] MATH 523 - Generalized Linear Models - Léo Belzile, PhD
The MATH 523 notes also have a very clear derivation for the logistic regression score equations. It's nearly identical to the Poisson case.
Please read the section '4.1 Binomial Model and Logistic Regression' on page 62. Focus on the final two equations, where ∂ℓn(β)/∂β is derived.
Differentiating with respect to involves the chain rule for the second term:
The fraction is the inverse logit function, which is exactly the mean (often written as for probabilities). So the derivative is simply .
Combining terms, the derivative of the log-likelihood is:
Again, this perfectly matches our general formula for a canonical link, giving us the score equation:
Conclusion
In this lesson, you have moved from constructing the log-likelihood function to deriving the equations needed to optimize it. This is the heart of the estimation process.
Key Takeaways:
- The score function is the vector of first partial derivatives of the log-likelihood function with respect to the model parameters .
- The score equations are formed by setting the score function to zero. Solving them yields the Maximum Likelihood Estimates.
- We derived a general formula for the score equations using the chain rule, which applies to any GLM.
- For canonical links, this formula simplifies to the intuitive expression , meaning the model residuals are uncorrelated with the predictors.
- We confirmed this result by directly differentiating the log-likelihood for Poisson and logistic regression.
You now have the equations, but how do you solve them? Except for the simplest cases, these are non-linear equations with no closed-form solution. They must be solved numerically. In our next lesson, we will explore the main algorithm used for this purpose: Fisher scoring, and see how it is implemented as Iteratively Reweighted Least Squares (IRWLS).