GLM Fundamentals
This page covers the statistical theory behind the GLM tab. See that page for usage instructions.
Model Formulation
GLM (the generalized linear model) extends the normal linear model to the exponential family of distributions defined in the next section, in order to handle response variables that a normal distribution does not fit—binary outcomes, counts, and positive continuous values—within a regression framework. It was introduced by Nelder & Wedderburn (1972). A GLM is defined by three components:
- Distribution family: The response variable follows a distribution in the exponential family
- Linear predictor: (a linear combination of predictors)
- Link function: A monotonic function such that , connecting the linear predictor to the mean
Exponential Family
The distribution of the response changes with the kind of data: Binomial for binary outcomes, Poisson for counts. GLM avoids rebuilding the estimation theory for each distribution by restricting the choice to the exponential family. Within this family, the differences between distributions reduce to a single function expressing the mean-variance relationship, and replacing that function lets the same estimation algorithm (IRLS) cover every family.
A family of distributions is called an exponential family if its density (or mass) function can be written as:
Here, is called the natural (canonical) parameter, the dispersion parameter, and the log-partition function; is a known function determined by the family (see the table below). From this definition, the mean and variance follow as derivatives of the log-partition function :
Rewriting as a function of gives the variance function , which expresses the mean-variance relationship through a single function. The per-family forms of are tabulated in Variance Functions and Overdispersion.
Exponential family parameters for each distribution family:
| Family | (natural parameter) | |||
|---|---|---|---|---|
| Gaussian | ||||
| Binomial | ||||
| Poisson | ||||
| Gamma | ||||
| Negative Binomial |
- In the Binomial row, is the proportion of successes (, ), is the number of successes at observation , is the number of trials at observation (not the sample size but the per-observation trial count), and is the success probability. When , it reduces to the Bernoulli distribution
- The Negative Binomial is displayed as in the MIDAS UI; on this page we use to avoid confusion with the exponential family natural parameter. The Negative Binomial belongs to the exponential family only when is known. In MIDAS's automatic estimation mode, is estimated by maximizing the profile likelihood (with profiled out) in an outer loop (see GLM usage). The standard errors for reported in this mode are computed from the information matrix with treated as known, so uncertainty in is not reflected
Choosing the Link Function
The link function is a monotonic function connecting the linear predictor to the expected value of the response. A link function satisfying (the natural parameter) is called the canonical link. While the distribution family is mostly determined by the type of the response, the link function leaves room for choice. For how the family is chosen, see Choosing a distribution family.
The first criterion is the effect scale: whether the coefficients are to be read as differences in the response or as ratios. With the Identity link, coefficients directly represent differences in the response. With the Log link, addition on the linear predictor becomes multiplication on the mean, so reads as a ratio—a rate ratio (IRR) for Poisson and Negative Binomial. With Logit, is an odds ratio (OR). For Logit and Log, the coefficient table shows the column corresponding to this interpretation.
| Link Function | Formula | Coefficient Interpretation | Canonical Link For |
|---|---|---|---|
| Identity | is a difference in the response | Gaussian | |
| Logit | is an odds ratio | Binomial | |
| Log | is a ratio (multiplicative effect) | Poisson | |
| Inverse | is a change on the scale | Gamma | |
| Probit | is a change in (the z-value of the probability) | — |
What most strongly supports a particular effect scale is knowledge of how the data arise. If each factor scales the rate by a constant multiple, effects add up on the log scale. If the response can be thought of as an unobserved continuous variable crossing a threshold, coefficients read as effects on the scale of that variable, and assuming a normal distribution for it gives Probit (see the threshold model in GLMM Fundamentals).
The canonical link is the default choice when the effect scale does not settle the question. Since , becomes a sufficient statistic for , and the log-likelihood is concave in . When the design matrix has full rank and the MLE exists, the solution is unique and IRLS converges stably1. These are properties of estimation convenience; being canonical does not make the model correct.
Non-canonical links forfeit these properties but may be chosen when the effect scale takes priority. For example, the canonical link for Gamma is Inverse (), which puts coefficients on a scale that is hard to interpret. The Log link ( as a multiplicative effect) is more commonly used in practice.
A link chosen for the effect scale is not guaranteed to be compatible with the family's domain. For example, Poisson + Identity, chosen to read rate differences, produces a fitted mean outside the domain (positive values) when the linear predictor goes negative for some observation.
Parameter Estimation (IRLS)
GLM parameters are estimated by maximum likelihood. Under regularity conditions (differentiability of the log-likelihood, the true parameter being an interior point of the parameter space, etc.), the estimator is consistent, asymptotically normal, and asymptotically efficient. In general no closed-form solution exists, so IRLS (Iteratively Reweighted Least Squares) is used2.
At each iteration, working weights and an adjusted dependent variable are computed, then the weighted least squares problem:
is solved to update . is a diagonal matrix, and its -th diagonal entry and the -th component of are computed from the current and the link function as:
where is the variance function and is the derivative of the link function. For Grouped Binomial, the variance of observation is , as given by in the exponential family table, so is additionally multiplied by the trial count . See Nelder & Wedderburn (1972) for the original formulation of IRLS for GLMs. Iteration stops when the change that the next iteration would make to the coefficients, measured by their estimated covariance matrix, is at most the convergence threshold.
With the canonical link, the concavity of the log-likelihood ensures stable convergence. Non-canonical links may lead to slower convergence or convergence failure.
Coefficient Standard Errors and Confidence Intervals
The confidence intervals for the coefficients reported by the GLM tab are Wald intervals . The standard error is the square root of the -th diagonal entry of the estimated covariance matrix , where is the IRLS weight matrix evaluated at the converged .
The estimated dispersion parameter is determined per family. Poisson, Binomial, and Negative Binomial use . Gaussian uses the residual deviance divided by ; since the Gaussian deviance is , this value equals . Gamma uses . The deviance-based estimator is not used for Gamma because it is not consistent there (McCullagh & Nelder, 1989). Why Negative Binomial uses both when is estimated and when it is specified is discussed in Variance Functions and Overdispersion.
The quantile is taken from the distribution with degrees of freedom for families whose is estimated from the data, and from the standard normal distribution for families with . For the families that use the distribution, reflects the uncertainty in estimating .
For Gaussian + Identity, the coverage probability of this interval (the probability that the interval contains the true value) matches the nominal level in finite samples if the mean structure is correct and the errors are independent and normally distributed with equal variance. For all other family/link combinations, the interval is an approximation based on the asymptotic normality of the maximum likelihood estimator. If the model is correct, its coverage probability approaches the nominal level as the sample grows.
Variance Functions and Overdispersion
As described in the Exponential Family section, the variance function is the second derivative of the log-partition function rewritten in terms of . Through the relationship , it defines the mean-variance relationship for each family.
| Family | |||
|---|---|---|---|
| Gaussian | (= ) | ||
| Binomial | |||
| Poisson | |||
| Gamma | |||
| Negative Binomial |
Poisson and Binomial assume a dispersion parameter . When the actual data variance exceeds this assumption, the condition is called overdispersion. Overdispersion leads to underestimated standard errors and confidence intervals that are too narrow. To diagnose overdispersion, use the Deviance/df ratio shown in the Deviance Goodness-of-Fit section of the GLM Diagnostics tab, opened via View Diagnostics. Under the assumption, this ratio should be close to 1, so a value far from 1 suggests overdispersion. Note that the ratio fluctuates more around 1 when is small.
When overdispersion is detected with Poisson data, switching to Negative Binomial adds a term to the variance, explicitly modeling the extra dispersion. Once is given, the Negative Binomial distribution has the variance , so MIDAS uses both when is estimated and when it is specified. When is estimated, the overdispersion is absorbed into . When is specified, MIDAS computes the standard errors, confidence intervals, and prediction intervals for the Negative Binomial distribution with that . If the variance of the data exceeds for the specified , the standard errors are underestimated, as they are for Poisson under overdispersion. To check whether the specified matches the variance of the data, use the Deviance/df ratio, which the GLM Diagnostics tab also shows for a model with a specified .
However, for binary data with (logistic regression), each observation follows Bernoulli, and once the mean is fixed the marginal variance is determined as well. There is no degree of freedom in the per-observation variance, so there is simply nothing to compare against to say "the data variance exceeds the theoretical variance." This is why Pearson and deviance cannot detect overdispersion at the individual level. This does not mean overdispersion is absent — only that it cannot be detected from the same data; extra dispersion arising from clusters or repeated measurements (e.g., treating multiple patients from the same hospital as independent) can still exist and must be handled separately (see the glossary). Classical overdispersion diagnostics and remedies are meaningful only for grouped Binomial data with .
For grouped Binomial overdispersion, MIDAS does not currently support quasi-binomial or Beta-Binomial alternatives. If the extra dispersion arises from cluster structure, introducing random effects via GLMM is an option. When overdispersion is suspected, check the estimated dispersion parameter and consider that standard errors and confidence intervals may be underestimated.
Confidence Intervals for the Mean Response and Prediction Intervals
In the formulas below, is the estimated dispersion parameter defined in Coefficient Standard Errors and Confidence Intervals, and the quantile follows the rule in that section. With the vector of predictor values at the prediction point (its first element is 1 in a model with an intercept), is defined so that is the estimated variance of the linear predictor at the prediction point.
The confidence interval for the mean response is the Wald interval on the link scale, , transformed to the response scale via . Because is monotonic, the transformation does not change the coverage probability of the interval. With a non-linear link, the transformed interval is not symmetric around . The accuracy of this interval is the same as for the coefficient confidence intervals.
With the Inverse link, the link-scale interval is truncated to before the transformation. gives a positive mean only for , and if the model is also correct at the prediction point, the true lies in this range. Truncating the interval therefore does not change its coverage probability. When the lower end is 0 or less, the confidence interval for the mean response is . At a prediction point where itself is 0 or less, is not a positive value that the mean can take. MIDAS treats such a point as one where the fitted model gives no mean, and computes neither the confidence interval for the mean response nor the prediction interval.
With the Identity link for Gamma and Poisson, the link-scale interval is truncated to for the same reason. The mean of these two families is positive, and with the Identity link, so the true is positive. When the lower end is 0 or less, the confidence interval for the mean response is . MIDAS treats a prediction point where itself is 0 or less in the same way as with the Inverse link, and computes neither the point estimate of the mean nor the intervals.
The prediction interval covers the variability of a new observation . This variability cannot be captured by transforming a link-scale interval, so the computation depends on the family. All families except Gaussian + Identity use a plug-in method. A plug-in method treats the estimated parameters as if they were the true values and computes the interval from those values. Unlike a confidence interval, it does not account for parameter estimation uncertainty.
- Gaussian + Identity: The analytical formula accounts for both the variance of a new observation () and the estimation uncertainty of the mean ()
- Gaussian + non-Identity link: A plug-in method is used: . The non-linear link transformation prevents exact incorporation of estimation uncertainty on the scale in closed form. As a result, prediction intervals for this combination are a simplified form that does not reflect estimation uncertainty, meaning predictions at the center of the data and at extrapolation points receive the same interval width. Building the interval on the link scale and back-transforming, as well as a first-order delta-method approximation, both weaken coverage guarantees under non-linear links or in small samples, so MIDAS uses neither
- Poisson, Binomial, Gamma, Negative Binomial: A plug-in quantile method computes the quantiles of the fitted distribution directly:
- Poisson: quantiles of Poisson
- Binomial: quantiles of Binomial with success probability and trial count (for grouped Binomial, each row's value of the training Trials column in the prediction dataset; for binary data), divided by so the interval is reported on the success-proportion scale
- Gamma: quantiles of the Gamma distribution with mean , shape , and scale
- Negative Binomial: quantiles of the Negative Binomial distribution with mean and ( in automatic estimation mode, the specified value in fixed mode)
For discrete distributions (Poisson, Binomial, Negative Binomial), quantiles are rounded conservatively: each bound is the smallest integer satisfying , where, for a confidence level , for the lower bound and for the upper bound. Under the plug-in distribution, the coverage probability therefore meets or exceeds the nominal level. For individual Binomial data (), the only quantile candidates are , limiting the informativeness of the interval.
The plug-in methods do not account for parameter estimation uncertainty, so the actual coverage probability may fall below the stated confidence level, particularly in small samples or for predictions far from the observed data range.
See also
- The GLM Tab - How to run GLM analysis and interpret results
- OLS Fundamentals - Mathematical background of OLS, a special case of GLM
- GLMM Fundamentals - Generalized linear mixed model theory with random effects
- Glossary - Statistical term definitions
References
- Nelder, J. A., & Wedderburn, R. W. M. (1972). Generalized linear models. Journal of the Royal Statistical Society: Series A, 135(3), 370-384. https://www.jstor.org/stable/2344614
- McCullagh, P., & Nelder, J. A. (1989). Generalized Linear Models (2nd ed.). Chapman and Hall.
Footnotes
-
The exception where the MLE does not exist is complete separation—when a linear combination of predictors perfectly separates the response—where the log-likelihood remains concave and full-rank but has no finite maximum. Binary logistic regression is the canonical example, and similar cases arise in other discrete-response models such as multinomial logit. ↩
-
The exception is Gaussian + Identity: and make and in the formulas in the main text, so the weights do not depend on the data and IRLS reaches the OLS solution in a single iteration from any starting point. ↩
Also available as a Markdown file.