---
title: "Chapter 07: Foundations of GLMs — families, links, and log-concave likelihoods"
author: "Kjell Nygren"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
bibliography: REFERENCES.bib
reference-section-title: References
vignette: >
  %\VignetteIndexEntry{Chapter 07: Foundations of GLMs — families, links, and log-concave likelihoods}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

# 1. Conceptual Overview

Generalized linear models (GLMs) rest on two foundational ideas:  
(1) **exponential family likelihoods**, which provide a unified mathematical structure for a wide range of data-generating processes, and  
(2) **link functions**, which connect the mean of the response to a linear predictor.  

This section reviews the core concepts behind exponential families, explains why canonical links play such an important role, and highlights the special role of **log-concavity** in both classical and Bayesian estimation.
Standard references for GLM structure include [@McCullagh1989; @NelderWedderburn1972]; the original formulation of GLMs in **S** appears in [@Hastie1992].
For Bayesian GLMs with normal priors, envelope-based iid posterior sampling in **glmbayes** builds on [@Nygren2006].

## 1.1 Exponential Families: A Unifying Framework

Many common statistical models belong to the exponential family, a class of distributions that can be written in the **weighted** form

\[
f(y \mid \theta, \phi, w)
= \exp\left\{
  \sum_{i=1}^{n}
    w_i \left[
      \frac{y_i \theta_i - b(\theta_i)}{a(\phi)}
      + c(y_i, \phi)
    \right]
\right\}.
\]

Here:

- \( \theta_i \) is the canonical (natural) parameter  
- \( b(\theta_i) \) is the cumulant function  
- \( a(\phi) \) is a dispersion or scale parameter  
- \( c(y_i, \phi) \) collects terms not involving \( \theta_i \)  
- \( w_i \) is an observation weight (typically nonnegative)

This formulation includes the Gaussian, Poisson, Binomial, Gamma, and many others.  
The exponential-family form is not merely aesthetic: it guarantees several structural properties that GLMs rely on:

- The mean is \( \mu_i = b'(\theta_i) \).  
- The variance is \( \mathrm{Var}(Y_i) = b''(\theta_i)\, a(\phi) \).  
- Sufficient statistics are low-dimensional (often just the sample mean).  
- Likelihoods are typically smooth and well-behaved.

These properties make exponential-family models computationally stable and theoretically elegant, especially when combined with linear predictors.

## 1.2 Canonical Link Functions

A GLM specifies a relationship between the mean `mu` and a linear predictor `eta = X beta` through a **link function**:

\[
g(\mu) = \eta.
\]

When the link function is chosen so that $\theta = \eta$, the link is called **canonical**.  
Canonical links have several advantages:

- The score equations become linear in the sufficient statistics.  
- Iteratively reweighted least squares (IRLS) takes a particularly simple form.  
- The Fisher scoring and Newton–Raphson updates coincide.  
- The log-likelihood is often concave in `beta` (a key point for Section 5).

Examples:

- Gaussian with identity link  
- Poisson with log link  
- Binomial with logit link  
- Gamma with inverse link

Although noncanonical links are sometimes preferred for interpretability or domain-specific reasons, canonical links typically yield the most stable estimation behavior.

## 1.3 Why Log-Concavity Matters

A function `f` is **log-concave** if `log f` is concave.  
Most exponential-family likelihoods with canonical links are log-concave in the linear predictor, and often in the coefficients `beta` as well.

Log-concavity has several important implications:

### (a) Existence of gradients and subgradients

For concave functions, the gradient exists almost everywhere, and when it does not, a **subgradient** always exists.  
This is crucial for:

- optimization algorithms  
- envelope construction  
- sampling methods based on tangencies  
- the likelihood-subgradient densities introduced in your JASA paper

Because GLM likelihoods are log-concave in many common cases, subgradient-based methods are guaranteed to work.

### (b) Any local maximum is a global maximum

Concavity implies:

- no spurious local optima  
- stable convergence of Newton, Fisher scoring, and IRLS  
- predictable behavior even in high dimensions

This is one of the reasons GLMs are so widely used: the optimization landscape is benign.

### (c) Validity of envelope construction methods

The envelope construction approach of [@Nygren2006] relies on:

- log-concavity of the likelihood  
- existence of subgradients for the negative log-likelihood  
- the ability to form tight tangent-based upper bounds

For GLMs with canonical links, these conditions are naturally satisfied.  
This makes GLMs an ideal setting for likelihood-subgradient densities, mixture envelopes, and accept–reject sampling strategies.

### (d) Simplified Bayesian computation

Log-concave likelihoods interact especially well with:

- normal priors  
- normal-gamma priors  
- Laplace approximations  
- adaptive rejection sampling  
- convex optimization methods
- envelope based accept-reject sampling

Posterior modes are unique, posterior tails behave predictably, and envelope-based samplers remain efficient even in moderate dimensions.

---

This conceptual foundation sets the stage for the rest of the chapter:

- Section 2 contrasts classical and Bayesian GLM workflows.  
- Section 3 details the families and links supported in `glmb`.  
- Section 4 shows how to specify families and links in practice.  
- Section 5 returns to log-concavity and its role in estimation and sampling.
 
# 2. Generalized Linear Models in Practice: Formulas, Families, and Links

Section 1 introduced the exponential‑family structure underlying generalized linear models.  
This section explains how that structure is implemented in practice through R’s glm function.  
The goal is to show how formulas, families, and link functions work together inside glm, and how these components are passed to the model‑fitting machinery.

A GLM in R is defined by three user‑supplied components:

1. a model formula that defines the linear predictor  
2. a family specification that chooses the exponential‑family distribution  
3. a link function that connects the mean of the response to the linear predictor  

Together, these components translate the theoretical framework of Section 1 into a practical modeling interface.

## 2.1 The Formula Interface and the Linear Predictor

In R, the linear predictor is defined using a formula such as:

    y ~ x1 + x2 + x3

This corresponds to the linear predictor

\[
\eta = X \beta
\]

where X is the model matrix constructed from the formula.  
The formula interface automatically handles:

- dummy variables for factors  
- interaction terms (for example, x1:x2 or x1 * x2)  
- polynomial terms (for example, poly(x, 2))  
- offsets and weights when supplied  

Thus, the formula defines the systematic component of the GLM.

## 2.2 Family Objects: How glm Receives the Distribution and Link

The family argument in glm is not a character string.  
It is a function call that constructs a family object.  
For example:

    family = poisson(link = "log")

When glm is called, this expression is evaluated first.  
The result is a structured object containing:

- the name of the distribution  
- the link function $g(\mu)$  
- the inverse link $g^{-1}(\eta)$  
- the variance function $V(\mu)$  
- the derivative of the inverse link  
- deviance and AIC functions  
- initialization and validation rules  

glm then uses this object to:

- map between $\mu$ and $\eta$  
- compute IRLS weights  
- evaluate deviance residuals  
- check that $\mu$ and $\eta$ lie in valid domains  
- compute likelihood-based quantities when available

### Specifying a non‑default link

The link is modified by passing an argument to the family constructor.  
Examples include:

    family = binomial(link = "probit")
    family = poisson(link = "identity")
    family = Gamma(link = "log")

In all cases, glm receives a family object with the appropriate link embedded inside it.

### Binomial response formats

The binomial and quasibinomial families accept responses in three forms:

- a factor (success vs failure)  
- a numeric vector of proportions with weights  
- a two‑column matrix of successes and failures  

This flexibility is unique to the binomial family and reflects its exponential‑family structure.

### Quasi‑families

The quasi, quasibinomial, and quasipoisson families:

- do not correspond to true exponential‑family likelihoods  
- allow user‑specified variance functions  
- allow over‑dispersion  
- still use the same link‑function machinery  

They behave like GLMs but without a fixed likelihood.

## 2.3 Link Functions: Connecting Means to Linear Predictors

The link function $g(\mu) = \eta$ determines how the mean of the response relates to the linear predictor.  
Each family has a canonical link, which ensures that:

- the canonical parameter equals the linear predictor ($\theta = \eta$)  
- the log-likelihood is often concave in $\beta$  
- IRLS has a simple form  
- the score equations are linear in the sufficient statistics

Examples of canonical links include:

- Gaussian: identity  
- Binomial: logit  
- Poisson: log  
- Gamma: inverse  
- Inverse Gaussian: $1 / \mu^{2}$

Noncanonical links (for example, probit, cloglog, identity for binomial) are also available.  
They use the same family‑object machinery but may lose some of the computational advantages of canonical links.

## 2.4 How glm Combines Formulas, Families, and Links

The glm function brings together the components above in a way that mirrors the theory of Section 1:

- The formula defines the linear predictor $\eta = X \beta$.  
- The family object provides the variance function $V(\mu)$ and the exponential-family functions $b(\theta)$, $b'(\theta)$, and $b''(\theta)$.  
- The link provides $g(\mu)$, $g^{-1}(\eta)$, and the derivative of the inverse link.  
- The IRLS algorithm solves the likelihood equations using the curvature implied by $V(\mu)$.  
- With canonical links, the log-likelihood is typically log-concave, ensuring a unique maximum and stable convergence.

### A critical example: how glm receives formula, family, and link

A single line of code captures the entire GLM specification in R:

    glm(counts ~ outcome + treatment,
        family = poisson(link = "log"))

This line shows all three components working together:

1. **Formula**  
   `counts ~ outcome + treatment`  
   tells glm how to build the model matrix X, and therefore the linear predictor $\eta = X \beta$.

2. **Family**  
   `poisson(...)`  
   constructs a family object describing the Poisson distribution and its variance function $V(\mu) = \mu$.

3. **Link**  
   `link = "log"`  
   is passed inside the family call, telling glm to use the log link  
       $g(\mu) = \log(\mu)$,  
   with inverse  
       $\mu = \exp(\eta)$.

glm evaluates the family call first, constructs the family object, builds the model matrix from the formula, and then fits the model using IRLS under the Poisson log‑link specification.

This single line illustrates exactly how R combines the formula, the family, and the link to define and fit a GLM.

## 2.5 Transition to the Complete Family–Link Reference

The concepts above describe how GLMs are specified and fitted in practice.  
Section 3 now provides a complete reference of all families and link functions implemented in glm, expressed in the exponential‑family form introduced in Section 1.


# 3. Families and Link Functions in `glm()`

Section 2 explained how formulas, families, and link functions are passed to `glm()` and how they define the structure of a generalized linear model.  
This section provides a concise overview of the families and link functions available in base R, and explains how they relate to the exponential‑family framework introduced in Section 1.

A complete, fully expanded reference of all family–link combinations—including canonical parameters, cumulant functions, and variance functions—is provided in **Appendix A**.

## 3.1 Families and Link Functions in Base R

The table below summarizes the families available in base R’s `glm()` function and the link functions supported for each family. Canonical links are marked with “(canonical)”.

| Family               | Description                                   | Supported Link Functions                                                                 |
|----------------------|-----------------------------------------------|-------------------------------------------------------------------------------------------|
| `gaussian()`         | Continuous outcomes with constant variance     | `identity` (canonical), `log`, `inverse`                                                  |
| `binomial()`         | Binary data or proportions                    | `logit` (canonical), `probit`, `cauchit`, `cloglog`, `identity`                           |
| `poisson()`          | Count data                                    | `log` (canonical), `identity`, `sqrt`                                                     |
| `Gamma()`            | Positive continuous, skewed                   | `inverse` (canonical), `identity`, `log`                                                  |
| `inverse.gaussian()` | Positive continuous with heavy tails          | `$1 / \mu^{2}$` (canonical), `identity`, `log`, `inverse`                                 |
| `quasi()`            | User-specified mean-variance relationship     | Depends on user specification                                                             |
| `quasibinomial()`    | Overdispersed binomial                        | Same as `binomial()`                                                                      |
| `quasipoisson()`     | Overdispersed Poisson                         | Same as `poisson()`                                                                       |

### Notes

- Canonical links ensure that the canonical parameter $\theta$ equals the linear predictor $\eta$, which often yields concave log-likelihoods and stable IRLS updates.  
- Quasi-families (`quasi`, `quasibinomial`, `quasipoisson`) do not correspond to true exponential-family distributions but retain the GLM mean-variance structure.  
- All families listed above integrate cleanly with the formula interface described in Section 2.

## 3.2 How Families and Links Fit the Exponential‑Family Structure

Each family in `glm()` corresponds to a specific exponential‑family distribution of the form

\[
f(y \mid \theta, \phi)
= \exp\left\{
\frac{y\theta - b(\theta)}{a(\phi)} + c(y,\phi)
\right\}.
\]

The choice of **family** determines:

- the canonical parameter \( \theta \)  
- the cumulant function \( b(\theta) \)  
- the variance function \( V(\mu) = b''(\theta) a(\phi) \)  

The choice of **link function** determines:

- how the mean \( \mu \) relates to the linear predictor \( \eta \)  
- whether the canonical parameter equals the linear predictor (canonical links)  
- the curvature of the log‑likelihood and the behavior of IRLS  

Canonical links (e.g., logit for binomial, log for Poisson) often yield:

- concave log‑likelihoods  
- simpler score equations  
- stable IRLS updates  

Noncanonical links remain valid but may alter curvature and convergence properties.

## 3.3 Where to Find the Full Mathematical Forms

The full exponential‑family expansions for **every** family–link combination—including:

- \( g(\mu) = \eta \)  
- \( g^{-1}(\eta) \)  
- canonical parameter \( \theta \)  
- cumulant function \( b(\theta) \)  
- variance function \( V(\mu) \)

are provided in **Appendix A**.

This keeps the main text focused on concepts while still giving advanced users access to the complete mathematical reference.

## 3.4 Why This Matters for Bayesian GLMs

The Bayesian extensions used in `glmb()` and `Prior_Setup()` rely on the same structure:

- The likelihood is exponential‑family, often log‑concave.  
- The linear predictor is defined through the same formula interface.  
- Canonical links ensure that gradients and subgradients exist, enabling envelope construction and efficient sampling.  
- Normal and normal‑gamma priors interact cleanly with the likelihood because both live in a convex, well‑behaved parameter space.

In short, the classical GLM framework provides the mathematical and computational foundation on which the Bayesian methods in later chapters are built.


# 4. Bayesian GLMs with `glmb()`

The function `glmb()` is a Bayesian extension of the classical `glm()` function.  
Its interface mirrors `glm()` as closely as possible: users specify a model using a formula, choose a likelihood family, and then supply a prior distribution through the `pfamily` argument.  
This design preserves the familiar GLM workflow while enabling full Bayesian inference.

## 4.1 Relationship to Classical GLMs

The setup for `glmb()` follows the same structure as `glm()`:

- the **formula** defines the linear predictor  
- the **family** defines the likelihood and link function  
- the **model frame**, **model matrix**, **offsets**, and **weights** are constructed identically  
- the returned object inherits from `"glm"` and `"lm"`  

This compatibility ensures that standard generics—`summary()`, `predict()`, `residuals()`, `extractAIC()`, and others—work naturally with `glmb` objects.

## 4.2 The `pfamily` Argument: Specifying Priors

The key addition in `glmb()` is the required `pfamily` argument, which specifies the prior distribution for the regression coefficients.  
The `pfamily` system parallels how `glm()` uses `family`:

- `family` → likelihood and link  
- `pfamily` → prior distribution and hyperparameters  

The default prior is a multivariate normal:

    pfamily = dNormal(mu, Sigma)

The helper function `Prior_Setup()` constructs sensible defaults for `mu` and `Sigma`, using a reparameterized form of Zellner's g-prior.  
Users may also fully customize the prior.

Supported prior families include:

- **dNormal** (all likelihood families)  
- **dNormalGamma** (Gaussian family)  
- **dIndependent_Normal_Gamma** (Gaussian family)

## 4.3 Supported Likelihood Families

`glmb()` currently supports:

- **Gaussian** (identity link)  
- **Poisson** and **quasipoisson** (log link)  
- **Gamma** (log link)  
- **Binomial** and **quasibinomial** (logit, probit, cloglog links)

These match the most commonly used GLM families.

## 4.4 A Direct Illustration: Calling `glmb()` with Formulas, Families, and Priors

Just as a classical GLM is defined by a formula and a likelihood family:

    glm(counts ~ outcome + treatment,
        family = poisson(link = "log"))

a Bayesian GLM adds one additional component: the prior family.

A typical workflow uses `Prior_Setup()` to construct prior parameters:

    ps <- Prior_Setup(counts ~ outcome + treatment,
                      family = poisson(link = "log"))
    mu <- ps$mu
    V  <- ps$Sigma

The corresponding Bayesian call mirrors the classical one:

    glmb.D93 <- glmb(counts ~ outcome + treatment,
                     family  = poisson(link = "log"),
                     pfamily = dNormal(mu = mu, Sigma = V))

This single line shows how `glmb()` receives:

- the **formula** (to build the model matrix),  
- the **family** (to define the likelihood and link),  
- the **pfamily** (to define the prior distribution).

The result is a set of independent posterior draws for coefficients, fitted values, linear predictors, and deviance, along with posterior summaries such as the posterior mode and DIC.

## 4.5 Posterior Sampling

For any supported combination of likelihood family, link, and prior family, `glmb()` generates **independent draws** from the posterior distribution—no MCMC chains are required.

- For the **Gaussian** family with normal or normal‑gamma priors, draws come from closed‑form conjugate posteriors.  
- For all other cases, `glmb()` uses an accept–reject sampler based on likelihood‑subgradient envelopes.

By default:

- `n = 1000` posterior draws are generated  
- parallel CPU simulation is used  
- OpenCL acceleration can be enabled for envelope construction

## 4.6 Returned Object

A `glmb` object contains:

- posterior draws of coefficients, fitted values, linear predictors, and deviance  
- posterior means and posterior mode  
- DIC components (`pD`, `Dbar`, `Dthetabar`, `DIC`)  
- the underlying `"glm"` object  
- model frame, design matrix, response, and prior specification  
- envelope diagnostics (`iters`)

Because `glmb` inherits from `"glm"` and `"lm"`, most classical methods apply directly.

## 4.7 Related Functions

The package also includes:

- **`lmb()`** — Bayesian version of `lm()` for Gaussian models  
- **`rglmb()` and `rlmb()`** — minimal interfaces used internally by `glmb()`  

These functions share the same computational engine but expose fewer features.

# 5. Log‑Concavity, Envelopes, and Posterior Computation

The Bayesian methods implemented in `glmb()` rely on the exponential‑family structure described in Sections 1–3.  
This section explains, at a high level, why the posterior distribution is well‑behaved for generalized linear models and how `glmb()` exploits this structure to generate independent posterior draws.

## 5.1 Why Log‑Concavity Matters

For the likelihood families supported by `glmb()`, the log‑likelihood is **concave** in the canonical parameter.  
When combined with a log‑concave prior (such as the multivariate normal used by default), the posterior density is also log‑concave.  
This ensures:

- a **unique posterior mode**,  
- stable numerical optimization,  
- well‑behaved curvature around the mode,  
- efficient envelope construction for accept–reject sampling.

Canonical links (e.g., logit for binomial, log for Poisson) preserve concavity and are therefore especially convenient.

## 5.2 Envelope Construction

For non‑Gaussian models, `glmb()` uses an accept–reject sampler based on **likelihood‑subgradient envelopes**.  
The idea is to build a tight, convex upper bound on the negative log‑likelihood using tangent points.  
This envelope:

- bounds the log‑likelihood everywhere,  
- is easy to sample from,  
- becomes tighter as more tangent points are added.

The `Gridtype` and `n_envopt` arguments control how many tangent points are used, trading off envelope tightness against construction cost.  
The component `iters` in the returned object reports how many candidate draws were generated before acceptance.

## 5.3 Posterior Computation Strategy

Posterior sampling in `glmb()` proceeds in two stages:

1. **Mode finding**  
   A classical GLM fit is used as the starting point, and the posterior mode is obtained by optimizing the sum of the log‑likelihood and log‑prior.

2. **Independent sampling**  
   - For Gaussian models with conjugate priors, draws come from closed‑form posterior distributions.  
   - For all other supported families, the envelope‑based accept–reject sampler generates **independent** posterior draws.

Because the sampler produces independent draws, there are no chains, no burn‑in, and no convergence diagnostics.  
This makes posterior summaries straightforward and computationally efficient.

## 5.4 Summary

The computational methods in `glmb()` leverage the structure of exponential‑family likelihoods and log‑concave priors to produce fast, reliable Bayesian inference for generalized linear models.  
These methods ensure that the Bayesian extension behaves predictably across all supported families and links, while maintaining a workflow that closely parallels the classical `glm()` function.



# Appendix A. Full Exponential‑Family Forms for All `glm()` Families and Links

This appendix provides a complete reference for the exponential‑family forms associated with every family–link combination implemented in base R’s `glm()` function.  
These tables expand the conceptual overview in Section 3 by listing:

- the family  
- the link function  
- the mean–link relationship \( g(\mu) = \eta \)  
- the inverse link \( \mu = g^{-1}(\eta) \)  
- the canonical parameter \( \theta \)  
- the cumulant function \( b(\theta) \)  
- the variance function \( V(\mu) \)

All expressions follow the exponential‑family form introduced in Section 1:

\[
f(y \mid \theta, \phi)
= \exp\left\{
\frac{y\theta - b(\theta)}{a(\phi)} + c(y,\phi)
\right\}.
\]

---

## Appendix A. Exponential-family and link reference tables

## A.1 Gaussian Family

| Family | Link | \( g(\mu)=\eta \) | \( \mu=g^{-1}(\eta) \) | \( \theta \) | \( b(\theta) \) | \( V(\mu) \) |
|--------|-------|-------------------|-------------------------|--------------|------------------|--------------|
| Gaussian | identity (canonical) | \( \eta=\mu \) | \( \mu=\eta \) | \( \theta=\mu \) | \( \theta^2/2 \) | \( 1 \) |
| Gaussian | log | \( \eta=\log(\mu) \) | \( \mu=e^\eta \) | \( \theta=\mu \) | \( \theta^2/2 \) | \( 1 \) |
| Gaussian | inverse | \( \eta=1/\mu \) | \( \mu=1/\eta \) | \( \theta=\mu \) | \( \theta^2/2 \) | \( 1 \) |

---

## A.2 Binomial Family

Exponential‑family core:

\[
b(\theta)=\log(1+e^\theta), \quad
\mu=\frac{e^\theta}{1+e^\theta}, \quad
V(\mu)=\mu(1-\mu).
\]

| Family | Link | \( g(\mu)=\eta \) | \( \mu=g^{-1}(\eta) \) | \( \theta \) | \( b(\theta) \) | \( V(\mu) \) |
|--------|-------|-------------------|-------------------------|--------------|------------------|--------------|
| Binomial | logit (canonical) | \( \eta=\log(\mu/(1-\mu)) \) | \( \mu=\frac{e^\eta}{1+e^\eta} \) | \( \theta=\eta \) | \( \log(1+e^\theta) \) | \( \mu(1-\mu) \) |
| Binomial | probit | \( \eta=\Phi^{-1}(\mu) \) | \( \mu=\Phi(\eta) \) | \( \theta=\log(\mu/(1-\mu)) \) | same | same |
| Binomial | cloglog | \( \eta=\log[-\log(1-\mu)] \) | \( \mu=1-e^{-e^\eta} \) | \( \theta=\log(\mu/(1-\mu)) \) | same | same |
| Binomial | cauchit | \( \eta=\tan\{\pi(\mu-1/2)\} \) | \( \mu=\frac{1}{2}+\frac{1}{\pi}\arctan(\eta) \) | \( \theta=\log(\mu/(1-\mu)) \) | same | same |
| Binomial | identity | \( \eta=\mu \) | \( \mu=\eta \) | \( \theta=\log(\mu/(1-\mu)) \) | same | same |

---

## A.3 Poisson Family

\[
b(\theta)=e^\theta, \quad
\mu=e^\theta, \quad
V(\mu)=\mu.
\]

| Family | Link | \( g(\mu)=\eta \) | \( \mu=g^{-1}(\eta) \) | \( \theta \) | \( b(\theta) \) | \( V(\mu) \) |
|--------|-------|-------------------|-------------------------|--------------|------------------|--------------|
| Poisson | log (canonical) | \( \eta=\log(\mu) \) | \( \mu=e^\eta \) | \( \theta=\eta \) | \( e^\theta \) | \( \mu \) |
| Poisson | identity | \( \eta=\mu \) | \( \mu=\eta \) | \( \theta=\log(\mu) \) | same | same |
| Poisson | sqrt | \( \eta=\sqrt{\mu} \) | \( \mu=\eta^2 \) | \( \theta=\log(\mu) \) | same | same |

---

## A.4 Gamma Family

\[
b(\theta)=-\log(-\theta), \quad
\mu=-1/\theta, \quad
V(\mu)=\mu^2.
\]

| Family | Link | \( g(\mu)=\eta \) | \( \mu=g^{-1}(\eta) \) | \( \theta \) | \( b(\theta) \) | \( V(\mu) \) |
|--------|-------|-------------------|-------------------------|--------------|------------------|--------------|
| Gamma | inverse (canonical) | \( \eta=1/\mu \) | \( \mu=1/\eta \) | \( \theta=-1/\mu \) | \( -\log(-\theta) \) | \( \mu^2 \) |
| Gamma | identity | \( \eta=\mu \) | \( \mu=\eta \) | \( \theta=-1/\mu \) | same | same |
| Gamma | log | \( \eta=\log(\mu) \) | \( \mu=e^\eta \) | \( \theta=-1/\mu \) | same | same |

---

## A.5 Inverse Gaussian Family

\[
b(\theta)=\sqrt{-2\theta}, \quad
\mu=\frac{1}{\sqrt{-2\theta}}, \quad
V(\mu)=\mu^3.
\]

| Family | Link | \( g(\mu)=\eta \) | \( \mu=g^{-1}(\eta) \) | \( \theta \) | \( b(\theta) \) | \( V(\mu) \) |
|--------|-------|-------------------|-------------------------|--------------|------------------|--------------|
| Inverse Gaussian | \( 1/\mu^2 \) (canonical) | \( \eta=1/\mu^2 \) | \( \mu=1/\sqrt{\eta} \) | \( \theta=-1/(2\mu^2) \) | \( \sqrt{-2\theta} \) | \( \mu^3 \) |
| Inverse Gaussian | identity | \( \eta=\mu \) | \( \mu=\eta \) | \( \theta=-1/(2\mu^2) \) | same | same |
| Inverse Gaussian | log | \( \eta=\log(\mu) \) | \( \mu=e^\eta \) | \( \theta=-1/(2\mu^2) \) | same | same |
| Inverse Gaussian | inverse | \( \eta=1/\mu \) | \( \mu=1/\eta \) | \( \theta=-1/(2\mu^2) \) | same | same |

---

## A.6 Quasi Families

These are not true exponential families, but `glm()` allows them.

| Family | Link Functions | Variance Function |
|--------|----------------|-------------------|
| quasi | any link | user‑specified |
| quasibinomial | same as binomial | \( \mu(1-\mu) \) up to scale |
| quasipoisson | same as poisson | \( \mu \) up to scale |

---
