Welcome to the World of GLMs!

In your CS1 journey, you’ve likely already met Linear Regression. It’s a fantastic tool, but it has one big limitation: it assumes that the data follows a Normal Distribution. In the real world (and in actuarial exams!), data isn't always that well-behaved. Claims might be counts (Poisson) or "yes/no" events (Binomial).

This is where Generalised Linear Models (GLMs) come to the rescue! They are the "Super-Powered" version of linear regression that allow us to model almost any type of data. Don't worry if this seems a bit abstract at first; we're going to break it down piece by piece.

1. The Exponential Family of Distributions

Before we can build a GLM, we need to make sure our data comes from a specific "family" of distributions called the Exponential Family. This includes the Normal, Poisson, Binomial, Gamma, and Exponential distributions.

A distribution belongs to this family if its probability density (or mass) function can be written in this specific format:
\( f(y; \theta, \phi) = \exp \left[ \frac{y\theta - b(\theta)}{a(\phi)} + c(y, \phi) \right] \)

Breaking Down the Formula:

  • \( y \): The actual data point (the observation).
  • \( \theta \) (Theta): The natural parameter. It’s related to the mean.
  • \( \phi \) (Phi): The dispersion parameter. It’s related to the variance (how spread out the data is).
  • \( a, b, c \): These are just functions that change depending on which distribution you are using.

Why do we care about this format?

Because if a distribution fits this "template," we can find the Mean and Variance using these simple shortcuts:
1. Mean: \( E[Y] = \mu = b'(\theta) \) (The first derivative of \( b \))
2. Variance: \( Var(Y) = a(\phi)b''(\theta) \) (The second derivative of \( b \), scaled by \( a \))

Quick Tip: In the exam, you are often asked to show that a distribution belongs to the exponential family. Just take the log of the PDF/PMF and try to rearrange it to look like the formula above!

Key Takeaway: The Exponential Family provides a unified framework so we can treat different types of data (like counts and costs) using the same mathematical logic.

2. The Three Components of a GLM

Every GLM consists of three essential ingredients. Think of it like a recipe for a model:

Component 1: The Random Component

This is the probability distribution of our response variable \( Y \). We assume the observations are independent and come from a distribution in the Exponential Family (like Poisson for the number of car accidents).

Component 2: The Systematic Component

This is our Linear Predictor, denoted by the Greek letter eta (\( \eta \)). It’s the combination of our explanatory variables (like age, car type, or location):
\( \eta = \beta_1 x_1 + \beta_2 x_2 + ... + \beta_k x_k \)

Component 3: The Link Function

This is the "bridge" between the Mean (\( \mu \)) and the Linear Predictor (\( \eta \)).
\( g(\mu) = \eta \)

Analogy Time!
Imagine you are trying to predict how many people attend a party based on the amount of music played.
- The Random Component is the actual number of guests (a count).
- The Systematic Component is the music volume.
- The Link Function is the "vibe" that converts the volume into a number of people. It ensures that even if you turn the music up to "100," your model doesn't predict a negative number of people (which would be impossible!).

Key Takeaway: A GLM = Distribution + Linear Predictor + Link Function.

The link function \( g(\mu) \) is crucial because it ensures the model stays within realistic bounds. For example, a probability must be between 0 and 1.

  • Identity Link: \( \eta = \mu \). (Used for standard Normal regression).
  • Log Link: \( \eta = \ln(\mu) \). (Often used for Poisson data because it ensures \( \mu > 0 \)).
  • Logit Link: \( \eta = \ln \left( \frac{\mu}{1-\mu} \right) \). (The standard choice for Binomial data/probabilities).

Did you know? Every distribution has a Canonical Link. This is the special link function where \( \eta = \theta \). Using the canonical link makes the math much simpler for computers to solve!

4. Estimating Parameters and the "Deviance"

How do we find the best values for our \( \beta \) coefficients? In GLMs, we use Maximum Likelihood Estimation (MLE). Instead of drawing a line that minimizes the "squares" (like in OLS), we find the values that make our observed data most likely to have happened.

What is Deviance?

In standard regression, we talk about "Residual Sum of Squares." In GLMs, we talk about Deviance.
Deviance is a measure of how much our model deviates from a "perfect" model (called the Saturated Model).
- Low Deviance = Good fit.
- High Deviance = Poor fit.

Common Mistake: Don't confuse Deviance with Scaled Deviance. Scaled deviance adjusts for the dispersion parameter \( \phi \). In the Poisson and Binomial cases, where \( \phi = 1 \), they are the same!

Quick Review Box:
- Saturated Model: A perfect model with one parameter for every data point.
- Null Model: A simple model that assumes all data points have the same mean (no predictors).
- Your Model: Somewhere in between.

5. Checking if the Model Works (Residuals)

Once you’ve built your model, you need to check the "leftovers"—the Residuals. If the model is good, the residuals should look like random noise.

  1. Pearson Residuals: These are like "standardised" errors. We take the difference between the actual value and the predicted value, and divide by the standard deviation.
  2. Deviance Residuals: These are more complex but often preferred in GLMs. They represent the contribution of each individual observation to the total deviance.

Key Takeaway: If you plot your residuals and see a pattern (like a "U" shape), your model is missing something important!

6. Model Selection: Which one is better?

Often, you’ll have to choose between two models. For example: "Does adding the 'Driver's Age' actually make my insurance model better?"

  • Likelihood Ratio Test (LRT): Used to compare nested models (where one is a simpler version of the other). The test statistic is \( 2 \times (\ln L_{big} - \ln L_{small}) \), which follows a Chi-square distribution.
  • AIC (Akaike Information Criterion): A "fairness" score. It rewards a good fit but penalizes you for adding too many unnecessary variables. Lower AIC is better!

Summary & Final Encouragement

GLMs are the bread and butter of modern actuarial work. By moving beyond simple straight lines and normal distributions, you can model real-world risks like insurance claim frequencies and severities accurately.

Remember the core steps:
1. Check if the distribution is in the Exponential Family.
2. Pick your Link Function.
3. Use MLE to find your coefficients.
4. Check the Deviance and AIC to see if the model is any good.

Don't worry if the algebra for the exponential family feels heavy at first. Once you practice rewriting the Poisson and Binomial PDFs a few times, it will become second nature! You've got this!