Why Put Uncertainty Around a Fitted Curve?
A fitted curve summarizes an estimated relationship between a predictor and the mean outcome. The curve alone can look more certain than the data justify: a smooth line does not show how precisely its height has been estimated at each predictor value. An uncertainty band adds that information and helps readers distinguish a well-supported part of the curve from a less precise estimate.
Here the target is the conditional mean of the outcome at a given predictor value, not the outcome of a particular individual. The band should therefore be calculated for estimates of that mean. It should also be plotted over a stated range and labeled in units that make the graph interpretable.
Pointwise Intervals for a Curved Mean
A common nonlinear curve is nonlinear in the predictor but linear in its coefficients. For example, a quadratic mean model can be written using a vector of basis functions. At predictor value \(x\), let that vector be \(\mathbf{z}(x)\), let the coefficient vector be \(\boldsymbol{\beta}\), and write the conditional mean as \(m(x)=\mathbf{z}(x)^\mathsf{T}\boldsymbol{\beta}\). The fitted mean is \(\hat{m}(x)=\mathbf{z}(x)^\mathsf{T}\hat{\boldsymbol{\beta}}\).
For the standard interval calculation below, assume the mean model is correctly specified and the errors are independent, normally distributed with mean zero and constant variance. Conditional on the observed predictor values, these assumptions make the usual \(t\)-interval for the mean exact. In practice, the estimated standard error and degrees of freedom must come from the fitted model. A pointwise interval is calculated at one specified \(x\) at a time.
If the fitted curve is linear in its coefficients, the standard error at \(x\) follows from the estimated covariance matrix of those coefficients. Write \(\widehat{\operatorname{Cov}}(\hat{\boldsymbol{\beta}})\) for that matrix. The variance of a linear combination is obtained by multiplying the covariance matrix on both sides by its coefficient vector:
This formula accounts for uncertainty in every estimated coefficient and for covariance between coefficients. It explains why the precision can change along a curve: the basis vector \(\mathbf{z}(x)\) changes with \(x\), so the same coefficient uncertainty can contribute differently at different locations.
Worked Example: A Pointwise Interval at One Predictor Value
Suppose a hypothetical study measures an outcome concentration in milligrams per litre (mg/L) at doses measured in milligrams per day (mg/day). The observed doses range from 0 to 20 mg/day. A quadratic curve is fitted using \(u=(x-10)/10\) and the basis vector \(\mathbf{z}(x)=(1,u,u^2-0.5)^\mathsf{T}\). The fitted coefficients are \((30,4,-1)^\mathsf{T}\), and the estimated coefficient covariance matrix is diagonal with entries 1, 0.04, and 0.01. The residual degrees of freedom are 16.
At \(x=20\) mg/day, \(u=1\), so the basis vector is \((1,1,0.5)^\mathsf{T}\). The fitted mean is
Using the stated covariance matrix, the estimated variance and standard error of this fitted mean are
For a 95% interval with 16 degrees of freedom, use \(t_{0.975,16}\approx2.120\). The margin of error is \(2.120(1.021)=2.165\) mg/L, giving
At a dose of 20 mg/day, the fitted conditional mean concentration is 33.5 mg/L, and the pointwise 95% confidence interval is approximately 31.34 to 35.67 mg/L. This describes uncertainty about the mean at that dose; it is not a range expected to contain 95% of individual outcomes.
Turning Pointwise Intervals into a Plotted Band
To draw a band, select a sequence of predictor values across the range of interest. At each value, calculate the fitted mean and its pointwise interval. Plot the fitted means as the curve, then plot the lower and upper interval limits as boundary curves or shade the region between them. The calculations should use the fitted model's standard errors and degrees of freedom at each value, not one standard error reused indiscriminately across the graph.
The justification for the standard error formula is a direct variance calculation. At fixed \(x\), the fitted mean is the scalar linear combination \(\mathbf{z}(x)^\mathsf{T}\hat{\boldsymbol{\beta}}\). For any vector \(\mathbf{a}\) and random vector \(\mathbf{B}\), the variance of \(\mathbf{a}^\mathsf{T}\mathbf{B}\) is \(\mathbf{a}^\mathsf{T}\operatorname{Cov}(\mathbf{B})\mathbf{a}\). Substituting \(\mathbf{a}=\mathbf{z}(x)\) and \(\mathbf{B}=\hat{\boldsymbol{\beta}}\) gives
Estimating this variance and taking its square root gives the standard error used at that predictor value. The \(t\) multiplier then scales the standard error to form the interval. This derivation also shows why omitting covariance terms, when they are nonzero, can give an incorrect band.
Worked Example: Calculating Several Points for a Band
Use the hypothetical fitted curve and covariance matrix from the previous example. For this model, \(u=(x-10)/10\), the fitted curve is \(30+4u-(u^2-0.5)\), and the estimated coefficient covariance matrix has diagonal entries 1, 0.04, and 0.01. Calculate pointwise 95% intervals at doses 0, 10, and 20 mg/day, using \(t_{0.975,16}=2.120\).
At 0 mg/day, \(u=-1\), giving the basis vector \((1,-1,0.5)^\mathsf{T}\). Thus the fitted mean is \(30-4-0.5=25.5\) mg/L, and its standard error is
The margin is \(2.120(1.021)=2.165\) mg/L, so the interval is \(25.5\pm2.165\), or approximately 23.34 to 27.67 mg/L.
At 10 mg/day, \(u=0\), so the basis vector is \((1,0,-0.5)^\mathsf{T}\). The fitted mean is \(30.5\) mg/L, and the standard error is
The margin is \(2.120\sqrt{1.0025}\approx2.123\) mg/L, giving \(30.5\pm2.123\), or approximately 28.38 to 32.62 mg/L.
At 20 mg/day, the calculation from the earlier example gives a fitted mean of 33.5 mg/L and an interval of approximately 31.34 to 35.67 mg/L. These three intervals are points from the band, not a replacement for calculating intervals across the full plotting grid.
Label the Scale and the Scope
A useful figure makes clear what each axis measures and which estimates are displayed. If the outcome is concentration in mg/L and the predictor is dose in mg/day, those units belong on the respective axes. State the confidence level in the caption or legend, identify the shaded region as a pointwise confidence band for the conditional mean, and give the predictor range used to fit the curve or to display estimates.
Worked Example: Showing Why the Observed Range Matters
Suppose the dose measurements for the hypothetical study ran from 0 to 20 mg/day. A plotting grid from 0 through 20 mg/day displays fitted means within the observed predictor range. The graph caption could state: “Fitted mean concentration (mg/L) by dose (mg/day), with pointwise 95% confidence intervals; observed doses ranged from 0 to 20 mg/day.”
The fitted equation can also produce a number at 25 mg/day. There \(u=1.5\), so the fitted mean is \(30+4(1.5)-(1.5^2-0.5)=34.25\) mg/L. The standard error from the stated covariance matrix is
The corresponding model-based interval would be \(34.25\pm2.120(1.059)\), approximately 32.00 to 36.50 mg/L. But 25 mg/day is outside the observed range. Calculating an interval there does not add data support or establish that the fitted curve remains appropriate at that dose. If it is shown at all, the extrapolated portion must be clearly distinguished from estimates within the observed range.
What the Band Does—and Does Not—Say
The band communicates uncertainty in the estimated conditional mean under the fitted model and its assumptions. It does not include the full random variation of individual outcomes around that mean. Consequently, a confidence band for the mean is generally narrower than a prediction interval for a new individual outcome. Do not label one as the other.
Also, the intervals defined here are pointwise: each interval is constructed for one fixed predictor value. A 95% pointwise interval does not mean there is a 95% probability that the entire unknown curve lies within all the plotted limits at once. The distinction between pointwise coverage and coverage of a whole curve requires a different interpretation.
Common Mistakes
- Using the wrong target. A confidence band for the mean is not an interval for individual outcomes. Name the conditional mean as the target.
- Leaving off units or the outcome scale. A curve without labeled axes may be impossible to interpret. State predictor and outcome units, and identify any scale transformation if one was used.
- Extending the band without qualification. A model can return estimates outside the observed predictor range, but computation alone does not support extrapolation. Mark the observed range and explain the limitation.
- Calling pointwise intervals a guarantee for the whole curve. The stated confidence level applies at a fixed predictor value under the model assumptions, not automatically to every point simultaneously.
Check Your Understanding
Use the definitions and calculations in this tutorial to answer the following questions.
- What quantity is estimated by a pointwise confidence band around a fitted regression curve?
- Why can the standard error of a fitted mean differ at two predictor values on the same curve?
- A fitted mean is 18 units with standard error 2 units, and the appropriate \(t\) critical value is 2.1. Calculate its pointwise interval and state its interpretation.
- Why is a confidence interval for the mean not an interval expected to contain 95% of individual outcomes?
- A curve is fitted using predictor values from 3 to 15. What should a graph communicate if estimates are also shown at predictor value 18?