Tutorials › Regression Analysis (Undergraduate) › A Spline Dose-Response Analysis of Air Pollution

Integrated Applied Case Studies · Tutorial 970 of 991

A Spline Dose-Response Analysis of Air Pollution

Work through a hypothetical air-pollution analysis using a spline to describe lung function, compare its shape with a linear model, and communicate uncertainty and limits carefully.

Advanced 10 min read

What You'll Learn

  • Define a piecewise-linear spline using a knot and a hinge term.
  • Interpret exposure slopes on either side of the knot in outcome units.
  • Compare a spline model with a linear model using a test of slope change.
  • Calculate and interpret uncertainty for a spline coefficient and a fitted contrast.
  • Use residuals to check for signs of model misfit.
  • Explain why fitted curves should not be confidently extended beyond the observed exposure range.

Why Allow a Dose-Response Curve to Bend?

A straight-line regression describes a constant change in the average outcome for each unit increase in exposure. That can be a useful summary, but it may not describe every setting well: the association between air pollution and lung function might be weaker over one exposure range and stronger over another. A piecewise-linear spline allows the fitted line to change slope at a selected exposure value, called a knot, while remaining continuous there.

The aim is not to make a curve look complicated. It is to describe a plausible change in the exposure-response pattern, compare that description with a simpler linear fit, and report what the data support. A spline does not by itself establish that pollution causes a change in lung function.

Model and Interpretation

Suppose \(Y_i\) is lung function, measured as forced expiratory volume in one second (FEV1) in liters, for person \(i\). Let \(x_i\) be that person's air-pollution exposure, measured in micrograms per cubic meter. For a knot \(k\), define the hinge term \((x_i-k)_+=\max(0,x_i-k)\). Below or at the knot it equals zero; above the knot it equals the amount by which exposure exceeds the knot.

Definition: A piecewise-linear spline with one knot \(k\) is a regression model with a linear exposure term and a hinge term. With age and smoking status as adjustment variables, one example is

\(Y_i=\beta_0+\beta_1 z_i+\beta_2 h_i+\beta_3(\text{age}_i-40)+\beta_4\text{smoker}_i+\varepsilon_i\),

where \(z_i=(x_i-k)/10\) and \(h_i=(x_i-k)_+/10\). Here, \(\text{smoker}_i=1\) for a smoker and \(0\) otherwise. The factor of 10 means the exposure slopes are expressed per 10 micrograms per cubic meter. The coefficient \(\beta_1\) is the slope below the knot; \(\beta_1+\beta_2\) is the slope above it. The coefficient \(\beta_2\) is the change in slope at the knot.

This specification gives one straight segment on each side of the knot. It does not create a jump at the knot: the hinge term is zero there, and the two segments meet at the same fitted value. The model's slopes describe adjusted mean associations: they compare expected FEV1 at different exposures while holding the listed adjustment variables fixed.

Why the Spline Is Continuous

The hinge term determines the change in slope without adding a discontinuity in the fitted mean. To see this, temporarily hold age and smoking status fixed and write the exposure part of the mean as a function of \(x\).

$$ \begin{aligned} m(x)&=\beta_0+\beta_1\frac{x-k}{10} +\beta_2\frac{(x-k)_+}{10}+\text{fixed adjustment terms}\\ &= \begin{cases} \beta_0+\beta_1\frac{x-k}{10}+\text{fixed terms},&x\leq k,\\ \beta_0+(\beta_1+\beta_2)\frac{x-k}{10}+\text{fixed terms},&x>k. \end{cases} \end{aligned} $$

At \(x=k\), both expressions equal \(\beta_0\) plus the same fixed adjustment terms, so the fitted mean is continuous. Below the knot, the derivative with respect to exposure is \(\beta_1/10\) liters per microgram per cubic meter; above it, the derivative is \((\beta_1+\beta_2)/10\). Because the coefficients here are defined per 10 exposure units, it is often clearest to report the slopes directly in liters per 10 micrograms per cubic meter.

Assumptions and the Comparison with a Line

Before using coefficient tests or confidence intervals, specify the regression model and its assumptions. For the model above, the usual conditions are that the observations are independent, the conditional mean is described adequately by the included terms, and the errors have mean zero and constant variance at fixed predictor values. Normal errors are additionally used for exact small-sample \(t\) and \(F\) inference. In an application, these conditions cannot be guaranteed from a formula alone: the study design and residual diagnostics provide evidence about whether they are reasonable.

To compare the spline with a straight line, fit both models to the same analysis sample, using the same adjustment variables. The linear model is the spline model with \(H_0:\beta_2=0\). Under this null hypothesis, the slope does not change at the knot. A test of this one coefficient therefore assesses evidence for a slope change at that knot, conditional on the other terms. It does not test every possible nonlinear curve, nor does failure to reject prove that the true relationship is linear.

For a single coefficient, the usual test statistic is \(t=\hat{\beta}_2/SE(\hat{\beta}_2)\), with residual degrees of freedom \(df\). Its equivalent partial \(F\)-statistic is \(F=t^2\), with 1 numerator degree of freedom and the same residual degrees of freedom. This comparison relies on the regression assumptions stated above; in particular, the usual finite-sample reference distributions rely on normal errors.

Worked Example: Calculating the Two Exposure Slopes

Suppose a hypothetical analysis uses a knot at \(20\) micrograms per cubic meter and estimates \(\hat{\beta}_1=-0.120\) and \(\hat{\beta}_2=-0.080\), with FEV1 measured in liters. Calculate and interpret the exposure slopes on either side of the knot.

Below the knot, the slope per 10 micrograms per cubic meter is \(\hat{\beta}_1=-0.120\) liters. Above the knot, add the slope change:

$$ \hat{\beta}_1+\hat{\beta}_2 =-0.120+(-0.080) =-0.200\text{ liters per 10 micrograms per cubic meter}. $$

Thus, in this fitted model, a 10-microgram-per-cubic-meter exposure increase is associated with an estimated \(0.120\)-liter lower mean FEV1 below the knot and a \(0.200\)-liter lower mean FEV1 above it, at fixed age and smoking status. These are model-based associations, not evidence on their own that changing exposure would cause those differences.

For a 35-year-old nonsmoker, the predicted mean at exposure \(10\) is \(3.200+(-0.120)(-1)+(-0.080)(0)+(-0.025)(-5)=3.445\) liters, if the fitted intercept is \(3.200\), the age coefficient is \(-0.025\) liters per year, and exposure and age are centered as in the model. At exposure \(30\), the prediction is \(3.200+(-0.120)(1)+(-0.080)(1)+(-0.025)(-5)=3.125\) liters. The fitted difference is \(3.125-3.445=-0.320\) liters. Both predictions use the same adjustment values, and both exposures are on opposite sides of the knot.

Worked Comparison with a Linear Fit

The spline-versus-line comparison focuses on the added hinge term. It should not be confused with asking whether exposure is associated with the outcome at all: a test of \(\beta_2\) concerns whether the slope changes, not whether both segment slopes are zero.

Worked Example: Testing for a Slope Change

In a hypothetical sample of \(n=180\) people, an adjusted spline fit estimates \(\hat{\beta}_2=-0.080\) liters per 10 micrograms per cubic meter, with \(SE(\hat{\beta}_2)=0.035\). The model has five estimated coefficients, including the intercept, so \(df=180-5=175\). Test \(H_0:\beta_2=0\) against a two-sided alternative.

The assumptions for the usual coefficient test are independent observations, an adequately specified conditional mean and constant error variance; normal errors support the exact \(t\) reference distribution. The hypothetical report also states that the residual plots show no strong pattern or major variance increase. Those plots are useful checks, although they cannot prove the assumptions.

The test statistic is

$$ t=\frac{\hat{\beta}_2}{SE(\hat{\beta}_2)} =\frac{-0.080}{0.035} =-2.286. $$

With \(df=175\), the two-sided \(p\)-value is approximately \(0.023\). Equivalently, \(F=(-2.286)^2=5.23\), with 1 and 175 degrees of freedom. At significance level \(\alpha=0.05\), the result is evidence against \(H_0\): the fitted slope change is statistically distinguishable from zero under the model assumptions. This is evidence for a slope change at the chosen knot, not proof that this knot or spline is the uniquely correct description.

Uncertainty for Coefficients and Fitted Differences

A coefficient estimate is not exact. A confidence interval for \(\beta_2\) describes uncertainty about the slope change, while a confidence interval for a fitted difference describes uncertainty about a particular contrast in adjusted mean FEV1. These intervals answer different questions. A pointwise interval for the mean at one exposure also does not, by itself, give a simultaneous confidence band for the entire curve.

For an ordinary two-sided \(t\)-based interval, the estimate plus or minus the appropriate critical value times its standard error gives the interval. This calculation requires the model and inference assumptions to be reasonable; interpreting a fitted contrast also requires that the compared covariate values make sense for the data.

Worked Example: Interpreting Uncertainty in the Slope Change

Continue the hypothetical analysis with \(\hat{\beta}_2=-0.080\), \(SE(\hat{\beta}_2)=0.035\), and \(df=175\). The 95% \(t\)-critical value is approximately \(1.974\). The interval is

$$ -0.080\pm1.974(0.035) =-0.080\pm0.0691 =(-0.149,\,-0.0109). $$

The 95% confidence interval for the change in slope is approximately \(-0.149\) to \(-0.0109\) liters per 10 micrograms per cubic meter. Under the model, the data are compatible with a negative slope change in this range. The interval does not mean there is a 95% probability that the fixed parameter lies between these endpoints.

For another quantity, suppose the estimated adjusted mean difference in FEV1 between exposure \(35\) and exposure \(20\), at age \(40\) and for a nonsmoker, is \(-0.300\) liters. Suppose the standard error of that fitted contrast, calculated using the coefficient covariance matrix, is \(0.061\) liters. Its 95% interval is \( -0.300\pm1.974(0.061)=-0.300\pm0.120=-0.420\) to \(-0.180\) liters. This interval expresses uncertainty in that estimated mean difference, not in an individual person's future FEV1.

Inspecting Residuals and the Exposure Range

A residual is an observed outcome minus the fitted outcome: \(e_i=y_i-\hat{y}_i\). Residuals plotted against fitted values and exposure can reveal patterns that suggest the mean structure misses curvature, the spread changes with exposure, or a few observations deserve closer examination. A curved pattern in residuals may indicate that the chosen two-segment shape is inadequate; a fan-shaped pattern may suggest nonconstant variance. A plot without obvious patterns is reassuring but does not establish that the model is correct.

The hinge construction guarantees continuity, not good fit. The knot should be chosen and reported transparently, and a spline with one knot can still be too simple or unnecessarily flexible for a particular data set. Diagnostic findings should be described with their consequences: for example, unexplained curvature weakens confidence in the reported slopes, while a few extreme residuals may make estimates sensitive to individual observations.

Worked Example: Checking a Residual

Suppose a hypothetical participant is a 40-year-old nonsmoker with exposure \(30\), and the fitted coefficients are \(\hat{\beta}_0=3.200\), \(\hat{\beta}_1=-0.120\), \(\hat{\beta}_2=-0.080\), and \(\hat{\beta}_3=-0.025\). At exposure \(30\), both scaled exposure terms equal \(1\); the centered age term equals zero. The fitted FEV1 is

$$ \hat{y}=3.200+(-0.120)(1)+(-0.080)(1)+(-0.025)(0)=3.000\text{ liters}. $$

If the observed FEV1 is \(2.880\) liters, the residual is \(e=2.880-3.000=-0.120\) liters. The observation is \(0.120\) liters below the fitted mean. That residual alone does not show that the model is poor; its meaning depends partly on the surrounding residual pattern and the observation's influence on the fit.

Finally, keep interpretation within the observed exposure range. If the hypothetical sample includes exposures from \(8\) to \(40\) micrograms per cubic meter, estimates within that range are supported by observed exposure values, though support may be sparse near the endpoints. Beyond \(40\), the upper segment continues as a straight line by mathematical construction; the data do not show that the same slope continues there. Report such extrapolations as unsupported by the observed range, rather than as confident dose-response conclusions. The same caution applies when the age or other adjustment values in a prediction are far from those represented in the sample.

Common Mistakes and Reporting

  • Calling the knot a jump. The hinge-term spline is continuous at the knot; it changes slope, not fitted level.
  • Interpreting \(\beta_2\) as the upper slope. It is the change in slope. The upper slope is \(\beta_1+\beta_2\).
  • Treating a nonsignificant slope-change test as proof of a straight line. The test may have limited precision and only assesses a slope change at the specified knot.
  • Turning an adjusted association into a causal claim. Adjustment for age and smoking does not rule out all confounding in an observational analysis.
  • Extending the fitted upper segment confidently beyond the data. A model can calculate an extrapolated value, but calculation is not empirical support.

A clear report identifies the outcome and exposure units, the knot, the adjustment variables, the estimated segment slopes, and uncertainty relevant to the question. It also states how the spline compares with the linear fit, summarizes important residual findings, and names the observed exposure range. This makes both the curve and its limitations interpretable.

Check Your Understanding

Answer each question using the definitions and calculations in this tutorial.

  1. In a one-knot spline, what does the hinge coefficient represent, and how is the upper-segment slope calculated?
  2. If \(\hat{\beta}_1=-0.10\) and \(\hat{\beta}_2=0.04\) liters per 10 exposure units, what is the fitted slope above the knot? Interpret its sign.
  3. What null hypothesis is tested when comparing this spline with a linear model that has the same adjustment variables?
  4. A residual is negative. What does that say about the observed outcome relative to its fitted value?
  5. Why is a prediction above the largest observed exposure not automatically a reliable dose-response conclusion?