Tutorials › Generalized Linear Models › Mean–Variance Diagnostic Plots for Family Selection

Choosing Continuous Families · Tutorial 645 of 981

Mean–Variance Diagnostic Plots for Family Selection

Use binned plots to compare candidate variance functions while accounting for unequal group sizes and covariate-driven differences in conditional means.

Intermediate 10 min read

What You'll Learn

  • Define bins and calculate their empirical means and unbiased sample variances
  • Understand how unequal bin sizes affect the precision of plotted variances
  • Derive how variation in conditional means can inflate a raw within-bin variance
  • Compare empirical patterns with candidate conditional variance functions
  • Use residual-based summaries and interpret their limitations

What a Mean–Variance Plot Can Show

For a continuous response, a mean–variance diagnostic plot places a measure of response variability against the response mean. Its purpose is to check whether the observed scale of variation is broadly compatible with a candidate conditional variance function. For example, a candidate might have variance proportional to the mean, to the square of the mean, or to some other function \(V(\mu)\). The plot can reveal a marked mismatch, but it is a screening tool: it does not by itself establish that a distributional family is correct.

The central distinction is between conditional variation—variation in \(Y_i\) around its mean at a given covariate value—and variation caused by different conditional means among observations grouped together. A raw variance calculated within a broad bin can include both. Ignoring that distinction may make an appropriate conditional variance function appear too large or to grow too quickly.

Definition: For a bin \(b\) containing \(m_b \geq 2\) responses \(Y_i\), the empirical mean and unbiased sample variance are $$ \bar{Y}_b=\frac{1}{m_b}\sum_{i\in b}Y_i, \qquad S_b^2=\frac{1}{m_b-1}\sum_{i\in b}(Y_i-\bar{Y}_b)^2. $$ A raw mean–variance plot places the point \((\bar{Y}_b,S_b^2)\) for each bin. A conditional mean–variance model instead describes \(\operatorname{Var}(Y_i\mid x_i)=\phi V(\mu_i)\), where \(\mu_i=E[Y_i\mid x_i]\), \(V\) is the candidate variance function, and \(\phi>0\) is a scale factor.

The bins should represent a meaningful ordering, usually based on a covariate or on fitted conditional means from a mean model. Binning on fitted means makes the plot relevant to the proposed mean structure, but fitted means are estimates, not known values. Binning on a covariate can be easier to describe, but covariate bins may contain a wide range of fitted means. State what defines the bins and how many observations each contains; both details affect interpretation.

Calculating and Reading the Binned Summaries

For each bin, calculate its response mean and sample variance using the formulas above. Plot one point per bin, and report or display the bin size \(m_b\). Do not treat the points as equally precise just because they appear with equal visual weight. A sample variance from a small bin is generally noisier than one from a large bin. Bins with very few observations may produce erratic variances and should not be interpreted as stable evidence about a variance function.

Candidate functions imply different broad patterns. If \(\operatorname{Var}(Y_i\mid x_i)=\phi\mu_i\), variance grows in proportion to the mean. If it is \(\phi\mu_i^2\), variance grows quadratically; the squared coefficient of variation, \(\operatorname{Var}(Y_i\mid x_i)/\mu_i^2\), is then constant. These are conditional statements about individual observations. A plotted bin variance is an aggregate summary and need not lie exactly on either curve, even when that conditional model is correct.

Worked Example: Two Bins With a Quadratic Pattern

Suppose two bins contain the responses \(1,2,3,4\) and \(2,4,6,8\). Calculate the plotted points and compare their variances with their means.

For the first bin, \(\bar{Y}_1=(1+2+3+4)/4=2.5\). Its squared deviations from 2.5 are \(2.25,0.25,0.25,2.25\), so \(S_1^2=(2.25+0.25+0.25+2.25)/3=5/3\approx1.67\).

For the second bin, \(\bar{Y}_2=(2+4+6+8)/4=5\). Its squared deviations are \(9,1,1,9\), so \(S_2^2=(9+1+1+9)/3=20/3\approx6.67\).

The plotted points are approximately \((2.5,1.67)\) and \((5,6.67)\). The variance-to-mean ratios are approximately \(0.67\) and \(1.33\), so they are not constant. But \(S_1^2/\bar{Y}_1^2=(5/3)/(25/4)=4/15\), and \(S_2^2/\bar{Y}_2^2=(20/3)/25=4/15\). The two points are consistent with a quadratic scaling pattern in this simple comparison. Two bins do not establish a model; they illustrate how comparing ratios can highlight different growth patterns.

Why Unequal Bin Sizes Matter

A bin's sample variance has sampling variability, even if all observations in it share the same mean and variance. Under the specific assumption of independent observations from \(N(\mu,\sigma^2)\), the sample variance satisfies \(\operatorname{Var}(S_b^2)=2\sigma^4/(m_b-1)\). Thus the standard deviation of \(S_b^2\) is \(\sigma^2\sqrt{2/(m_b-1)}\): it decreases as bin size increases. This formula is a useful benchmark under normal sampling, not a universal uncertainty formula for arbitrary continuous families.

Worked Example: Comparing Precision Across Unequal Bins

Suppose two bins each come from a normal distribution with variance \(\sigma^2=4\), but one contains \(m_1=4\) observations and the other \(m_2=16\). Compare the standard deviations of their sample variances under this benchmark.

For the bin of size 4, \(\operatorname{Var}(S_1^2)=2(4^2)/(4-1)=32/3\), so \(\operatorname{SD}(S_1^2)=\sqrt{32/3}\approx3.27\).

For the bin of size 16, \(\operatorname{Var}(S_2^2)=2(4^2)/(16-1)=32/15\), so \(\operatorname{SD}(S_2^2)=\sqrt{32/15}\approx1.46\).

The larger bin has less than half the standard deviation of the smaller bin's variance estimate. Equal-looking discrepancies in a plot therefore need not carry equal evidential weight. Record bin sizes, avoid overinterpreting small bins, and do not fit a trend to the plotted points as though their precision were identical.

When group sizes differ substantially, equal-count bins can make the precision of the variance estimates more comparable, though they may cover wider ranges of fitted means in some parts of the data than in others. Equal-width bins can make the horizontal scale easier to interpret, but may leave extreme bins sparsely populated. The choice is a trade-off; report it rather than presenting the binning as inconsequential.

Covariate Variation Can Inflate Raw Bin Variance

The following identity gives a precise account of what a raw sample variance measures when observations in a bin have different conditional means. Let the responses in a bin be independent, with \(E[Y_i]=\mu_i\) and \(\operatorname{Var}(Y_i)=\sigma_i^2\), where these expectations and variances are conditional on their covariates. Write \(\bar{\mu}=m^{-1}\sum_{i=1}^m\mu_i\).

Result: For independent responses with finite variances, $$ E[S^2] = \frac{1}{m}\sum_{i=1}^m \sigma_i^2 + \frac{1}{m-1}\sum_{i=1}^m(\mu_i-\bar{\mu})^2. $$ The first term is the average conditional variance. The second term is nonnegative and represents variation among the conditional means within the bin.

To prove the identity, use \(\sum_i(Y_i-\bar{Y})^2=\sum_i(Y_i-\bar{\mu})^2-m(\bar{Y}-\bar{\mu})^2\). The expectation of the first sum is \(\sum_i[\sigma_i^2+(\mu_i-\bar{\mu})^2]\). Independence gives \(E[(\bar{Y}-\bar{\mu})^2]=m^{-2}\sum_i\sigma_i^2\). Subtracting \(m\) times this last quantity leaves \((1-1/m)\sum_i\sigma_i^2+\sum_i(\mu_i-\bar{\mu})^2\). Dividing by \(m-1\) gives the stated identity. \(\square\)

The identity explains why a raw within-bin variance can overstate conditional variance when a bin contains a range of fitted means. The effect does not disappear merely because the sample variance uses deviations from the bin's own sample mean: the conditional means themselves differ within that bin.

Worked Example: Separating Conditional Variance From Mean Variation

Consider a bin with four independent observations whose conditional means are \(1,1,5,5\). Suppose a candidate variance function is \(V(\mu)=\mu\) with scale \(\phi=1\), so their conditional variances are \(1,1,5,5\). What raw sample variance should the bin produce on average?

The average conditional variance is \((1+1+5+5)/4=3\). The mean of the four conditional means is \(\bar{\mu}=(1+1+5+5)/4=3\). Their squared deviations sum to \((1-3)^2+(1-3)^2+(5-3)^2+(5-3)^2=16\).

The mean-variation contribution to \(E[S^2]\) is \(16/(4-1)=16/3\). Therefore \(E[S^2]=3+16/3=25/3\approx8.33\), although the average conditional variance is only 3. A raw plot point near 8.33 would not, by itself, refute the candidate conditional variance \(V(\mu)=\mu\); the bin's mean heterogeneity accounts for the difference.

If instead the candidate is \(V(\mu)=\mu^2\) with \(\phi=1\), the average conditional variance is \((1+1+25+25)/4=13\). The same mean-variation contribution gives \(E[S^2]=13+16/3=55/3\approx18.33\). Comparing a raw bin variance with either candidate's conditional variance at the single bin mean \(\bar{\mu}=3\) would miss this within-bin structure.

Adjusting the Diagnostic for Fitted Means

When covariates cause appreciable variation in fitted means within a bin, one option is to use individual fitted means \(\hat{\mu}_i\) and residuals \(e_i=Y_i-\hat{\mu}_i\). If the conditional means were known exactly, the average squared residual in a bin would target the average conditional variance, not the raw variance inflated by differences among means.

Result: If the conditional means \(\mu_i\) are known and responses are independent with finite conditional variances \(\sigma_i^2\), then $$ E\left[\frac{1}{m}\sum_{i=1}^m(Y_i-\mu_i)^2\right] =\frac{1}{m}\sum_{i=1}^m\sigma_i^2. $$ Indeed, \(E[(Y_i-\mu_i)^2]=\operatorname{Var}(Y_i)=\sigma_i^2\) for each \(i\); summing these expectations and dividing by \(m\) proves the result. \(\square\)

In practice, fitted means are estimated from the same data, so replacing \(\mu_i\) by \(\hat{\mu}_i\) does not preserve that exact expectation in general. Model fitting can make residuals smaller, and the amount of this effect can depend on leverage and the fitting procedure. Treat a residual-based plot as a diagnostic summary, not as an unbiased estimate of the conditional variance unless its construction and uncertainty have been justified for the setting.

For a proposed variance function, compare the binned pattern with the function evaluated over the fitted means in each bin, rather than only at the bin's empirical mean. For example, a simple aggregate benchmark is the average of \(\phi V(\hat{\mu}_i)\) over the observations in that bin. If raw variances are plotted, the identity above also shows the mean-heterogeneity contribution that must be considered. These comparisons help distinguish an unsuitable variance trend from an overly broad grouping of different conditional means.

Common Pitfall and Practical Interpretation

Wrong reasoning: “The sample variance in this bin is larger than \(V(\bar{Y}_b)\), so the candidate variance function must be wrong.” This reasoning treats every response in the bin as if it had the same conditional mean and treats the plotted variance as an exact measurement.

Correction: The raw variance can include both average conditional variance and variation in conditional means. Check how much the fitted means vary within each bin, account for bin size, and compare with an aggregate of the candidate variances over the observations. A visible departure from the candidate pattern is a reason to investigate—not a stand-alone decision about the family.

Mean–variance plots are useful because they compress a complex pattern into a view that is often easy to interpret. They are most informative when bins contain enough observations, their sizes and definitions are reported, and conditional means do not vary greatly within them—or that variation is explicitly addressed. They are less informative when bins are sparse, covariates produce substantial within-bin mean differences, or the fitted means used to form the bins are themselves unstable.

Key takeaway: A binned raw variance is not automatically a conditional variance. Read it alongside bin size and within-bin fitted-mean variation, and use the plot to screen candidate variance functions rather than to certify a distributional family.

Check Your Understanding

Use the definitions and results above to answer the following questions.

  1. Why is the sample variance calculated with denominator \(m_b-1\) rather than \(m_b\) in the stated definition?
  2. For independent observations with different conditional means, what are the two contributions to the expected within-bin sample variance?
  3. How does the normal-theory standard deviation of a sample variance change as bin size increases?
  4. Why might a bin's raw variance be much larger than the candidate conditional variance evaluated at the bin's empirical mean?
  5. What limitation arises when individual fitted means are substituted for known conditional means in a residual-based plot?
Clinical Biostats