Tutorials › Exam PA - Predictive Analytics › Inverse Gaussian GLMs For Positive Outcomes

Exam PA · GLM Families and Model Construction · Tutorial 306 of 966

Inverse Gaussian GLMs For Positive Outcomes

Learn when an inverse Gaussian GLM is appropriate, how its variance depends on the mean, and how to select a link and fit the model in R.

Intermediate 10 min read

What You'll Learn

  • State the inverse Gaussian distribution and its mean–variance relationship using the dispersion parameter.
  • Derive the inverse Gaussian variance function from its exponential-family form.
  • Assess when cubic growth in variance makes this family a reasonable choice for positive outcomes.
  • Compare log and reciprocal-square links, including the mean constraints imposed by each.
  • Specify an inverse Gaussian GLM in R and calculate fitted means and variances.

Why Use an Inverse Gaussian GLM?

Some outcomes are strictly positive and right-skewed, and their variability can increase sharply as their expected value rises. In an actuarial setting, a hypothetical insurer might model the positive settlement time for claims that have already settled. A model for such an outcome should account not only for its positive range but also for how its variance changes with its mean.

The inverse Gaussian family is one option when the conditional variance grows approximately with the cube of the conditional mean. This is a stronger growth rate than the quadratic mean–variance relationship of the Gamma family. The choice is about the assumed conditional distribution and variance pattern; it does not follow just from an outcome being positive or skewed.

Definition: An inverse Gaussian random variable with mean \(\mu>0\) and shape parameter \(\lambda>0\), written \(Y\sim IG(\mu,\lambda)\), has density $$ f(y;\mu,\lambda)=\sqrt{\frac{\lambda}{2\pi y^3}}\exp\left(-\frac{\lambda(y-\mu)^2}{2\mu^2y}\right), \qquad y>0. $$ Its expectation is \(E[Y]=\mu\) and its variance is \(\operatorname{Var}(Y)=\mu^3/\lambda\). In GLM notation, write \(\phi=1/\lambda\), so \(\operatorname{Var}(Y)=\phi\mu^3\).

For a GLM, the response must be positive and continuous. Conditional on the predictors, observations are typically assumed independent, with \(Y_i\) following an inverse Gaussian distribution with mean \(\mu_i\) and a common dispersion \(\phi>0\). The linear predictor specifies the mean through a link, \(g(\mu_i)=\eta_i=x_i^\mathsf{T}\beta\). The family describes the conditional response distribution; the link describes how the mean relates to predictors.

Deriving the Cubic Variance Function

The inverse Gaussian variance function can be verified from its density. Put \(\lambda=1/\phi\), expand the quadratic in the exponent, and write the density in exponential-family form. This identifies the variance from the second derivative of the cumulant function.

1
Expand the exponent.
\(\frac{(y-\mu)^2}{\mu^2y}=\frac{y}{\mu^2}-\frac{2}{\mu}+\frac{1}{y}\). Therefore the part of the log density involving \(y\) and \(\mu\) is \(-\frac{y}{2\phi\mu^2}+\frac{1}{\phi\mu}-\frac{1}{2\phi y}\).
2
Identify the natural parameter.
Set \(\theta=-1/(2\mu^2)\) and \(b(\theta)=-1/\mu=-\sqrt{-2\theta}\). The density has the exponential-family form \(\exp\{[y\theta-b(\theta)]/\phi+c(y,\phi)\}\), where terms not involving \(\theta\) are included in \(c(y,\phi)\).
3
Differentiate the cumulant function.
\(b'(\theta)=(-2\theta)^{-1/2}=\mu\), and \(b''(\theta)=(-2\theta)^{-3/2}=\mu^3\). For this exponential-family form, the conditional mean is \(b'(\theta)\) and the conditional variance is \(\phi b''(\theta)\). Thus \(\operatorname{Var}(Y\mid x)=\phi\mu^3\).

This derivation explains why the mean and variance cannot be selected independently under this model. Once the family and dispersion are specified, a larger fitted mean entails a larger conditional variance at the cubic rate. For example, multiplying the mean by two multiplies the variance by eight if \(\phi\) stays fixed.

Choosing a Link and Respecting Its Range

The canonical parameter is \(\theta=-1/(2\mu^2)\). A link proportional to this quantity is a canonical-link choice; software commonly provides the reciprocal-square link \(g(\mu)=1/\mu^2\), which differs from \(\theta\) by a nonzero constant factor. The reciprocal-square link requires \(\eta>0\), because the mean is \(\mu=1/\sqrt{\eta}\).

A log link, \(g(\mu)=\log(\mu)\), is often convenient because every real-valued linear predictor gives a positive fitted mean: \(\mu=\exp(\eta)\). This avoids negative fitted means, but it does not make every choice of link appropriate for every data set. An identity link would require \(\eta>0\) for every observation; an inverse link \(g(\mu)=1/\mu\) likewise requires a positive linear predictor. Check the link's domain and the fitted values, rather than assuming that the family alone guarantees valid means.

In R, a typical specification is `glm(time ~ age + channel, data = claims, family = inverse.gaussian(link = "log"))`. The response column `time` must contain strictly positive numeric observations. R also allows the reciprocal-square link using `link = "1/mu^2"`; it is the usual default for `inverse.gaussian()`. After fitting, `predict(fit, type = "response")` returns fitted means on the response scale. A fitted mean is not an individual outcome, and the variance at that mean is \(\hat\phi\hat\mu_i^3\), when a dispersion estimate \(\hat\phi\) is available.

Worked Example: Calculating Variability at Two Mean Levels

Suppose the positive settlement time, in days, for a hypothetical claim has an inverse Gaussian distribution with mean \(\mu=20\) days and dispersion \(\phi=0.01\) days\(^{-1}\). Equivalently, its shape parameter is \(\lambda=1/\phi=100\) days. Calculate the variance and standard deviation. Also find the variance when the mean is 40 days and the dispersion remains unchanged.

Method. Use the inverse Gaussian variance relationship \(\operatorname{Var}(Y)=\phi\mu^3\). At 20 days, \(20^3=20\times20\times20=8{,}000\), so the variance is \(0.01\times8{,}000=80\) days squared. The standard deviation is \(\sqrt{80}=8.9442719\) days.

At 40 days, \(40^3=64{,}000\), so the variance is \(0.01\times64{,}000=640\) days squared. The mean doubled, and the variance increased by a factor of \(640/80=8\), as the cubic relationship predicts. The standard deviation at 40 days is \(\sqrt{640}=25.2982213\) days.

Check and exam trap. Rounding only at the final step, to three decimal places, gives standard deviations of 8.944 and 25.298 days. A common error is to use \(\phi\mu^2\), which would give \(0.01\times20^2=4\) days squared at the first mean. That is not the inverse Gaussian variance function; the exponent on \(\mu\) is three.

Using a Log Link for Positive Fitted Means

With a log link, the coefficients describe changes in the logarithm of the conditional mean. Exponentiating a coefficient gives a multiplicative change in the mean for a one-unit predictor increase, holding other predictors fixed. The dispersion is separate: it governs the scale of conditional variation around the mean, while the link and coefficients specify the mean structure.

Worked Example: Fitted Means and Variances Under a Log Link

A hypothetical model for positive claim-resolution time in days uses \(x\), the number of required document checks, and has \(\log(\mu)=\log(10)+\log(2)x\). Suppose the fitted dispersion is \(\phi=0.02\) days\(^{-1}\). Calculate the fitted means and variances for \(x=0\) and \(x=2\), and interpret the change.

Method. Under the log link, \(\mu=\exp(\eta)\). At \(x=0\), \(\eta=\log(10)+\log(2)\times0=\log(10)\), so \(\hat\mu_0=\exp(\log(10))=10\) days. The variance is \(0.02\times10^3=0.02\times1{,}000=20\) days squared.

At \(x=2\), \(\eta=\log(10)+2\log(2)=\log(10)+\log(4)=\log(40)\). Thus \(\hat\mu_2=40\) days, and the variance is \(0.02\times40^3=0.02\times64{,}000=1{,}280\) days squared. The fitted mean is four times as large, and the variance is \(1{,}280/20=64\) times as large, which equals \(4^3\).

Interpretation and check. Each additional document check multiplies the fitted mean by \(\exp(\log 2)=2\), holding other predictors fixed. Increasing \(x\) by two therefore multiplies the mean by four. The results are positive, as required, and the variance ratio agrees with the cubic variance function. The common mistake is to report \(1{,}280\) as a standard deviation: it is a variance in days squared, not a standard deviation in days.

Reciprocal-Square Link: Calculation and Constraint

The reciprocal-square link can also produce positive means, but only when its linear predictor is positive. Its inverse link is \(g^{-1}(\eta)=1/\sqrt{\eta}\) for \(\eta>0\). A linear predictor that is zero or negative does not map to a finite positive mean under this link. This constraint matters when fitting and when predicting for new predictor values.

Worked Example: Applying the Reciprocal-Square Link

Suppose a hypothetical inverse Gaussian GLM for positive repair duration uses \(g(\mu)=1/\mu^2\), with fitted linear predictor \(\eta=0.25-0.1875x\), where \(x\) is a nonnegative equipment-use index. Calculate the fitted means at \(x=0\) and \(x=1\), and assess whether a prediction at \(x=2\) is valid.

Method. The inverse link is \(\mu=1/\sqrt{\eta}\), so first calculate \(\eta\) and check that it is positive. At \(x=0\), \(\eta=0.25\), and \(\hat\mu=1/\sqrt{0.25}=1/0.5=2\) days.

At \(x=1\), \(\eta=0.25-0.1875=0.0625\). Since \(\sqrt{0.0625}=0.25\), the fitted mean is \(1/0.25=4\) days. At \(x=2\), \(\eta=0.25-0.375=-0.125\). This is outside the link's domain, so there is no valid positive fitted mean from this inverse link at \(x=2\).

Check and exam trap. The valid fitted means are 2 and 4 days; the negative predictor at \(x=2\) is not a negative mean and should not be reported as one. It indicates that this linear predictor and link do not yield a valid prediction there. A common mistake is to apply the inverse formula without checking its domain. In practice, assess the link constraint for both observed data and the prediction range.

When the Family Is and Is Not a Reasonable Choice

An inverse Gaussian GLM is a candidate when the response is strictly positive and continuous, and a cubic relationship between conditional mean and variance is plausible. Compare this assumption with the outcome's observed scale and with alternative candidate models; positivity alone is not sufficient evidence. The choice should also be assessed using appropriate diagnostics and validation, rather than treated as a fact about the data.

The distribution does not directly model exact zeros, negative observations, or discrete counts. If a response includes zero, do not silently replace zero with a small positive number just to make an inverse Gaussian fit possible. First clarify how the zero arises and whether the intended target is a positive outcome conditional on being nonzero or a response that includes a separate zero-generating process. That distinction changes what is being modeled.

For the inverse Gaussian model, keep these checks in view:

  • Confirm that the response is numeric, continuous, and strictly positive.
  • State the conditional mean model and link explicitly, and check that every fitted linear predictor is in the link's valid range.
  • Use the inverse Gaussian variance function \(\phi\mu^3\), not a variance function from a different GLM family.
  • Interpret fitted values as conditional means, and distinguish variance from standard deviation.
  • Do not assume that a positive fitted mean by itself establishes a good fit.

These choices are aligned with the SOA Exam PA (Predictive Analytics) syllabus: specify the response family and link to match the target and the assumptions being made, then interpret the resulting model on the appropriate scale.

Check Your Understanding

Work through each calculation and check that the link and response conditions are satisfied.

  1. A response has an inverse Gaussian distribution with mean 12 and dispersion \(\phi=0.05\). Calculate its variance and standard deviation, rounding the standard deviation to three decimal places. (Answer: variance \(=86.4\); standard deviation \(=9.295\).)
  2. A log-link model has \(\log(\mu)=\log(4)+x\log(1.5)\) and dispersion \(\phi=0.01\). For \(x=2\), calculate the fitted mean and variance. (Answer: mean \(=9\); variance \(=7.29\).)
  3. Under the reciprocal-square link, a case has linear predictor \(\eta=0.04\) and dispersion \(\phi=0.08\). Calculate its fitted mean and variance. (Answer: mean \(=5\); variance \(=10\).)
  4. Two inverse Gaussian outcomes have means 8 and 16 and share dispersion \(\phi=0.03\). Calculate both variances and their ratio, larger divided by smaller. (Answer: variances \(=15.36\) and \(122.88\); ratio \(=8\).)
  5. A proposed inverse Gaussian GLM has a response column containing several exact zeros, and the analyst plans to replace them with 0.001. Is that automatically justified by the inverse Gaussian model? (Answer: no; exact zeros are outside its support, and replacing them changes the data without establishing a suitable model for how zeros arise.)
Clinical Biostats