Tutorials › Regression Analysis (Undergraduate) › Worked Example: Comparing Quadratic and Cubic Fits

Polynomial Regression · Tutorial 443 of 991

Worked Example: Comparing Quadratic and Cubic Fits

Fit quadratic and cubic curves to the same data, compare their shapes and nested-model evidence, and decide what the comparison supports within the observed predictor range.

Intermediate 10 min read

What You'll Learn

  • Fit and describe quadratic and cubic curves using the same centered predictor.
  • Recognize the cubic model as a one-parameter extension of the quadratic model.
  • Calculate the nested-model F statistic from the two residual sums of squares.
  • Interpret the cubic-term test and its p-value without treating nonsignificance as proof of no curvature.
  • Compare fitted shapes over the observed range and avoid unsupported extrapolation.

Why Compare Quadratic and Cubic Fits?

A quadratic curve can represent one broad bend: its slope changes steadily as the predictor changes. A cubic curve is more flexible and can represent a bend whose direction or strength changes across the range. That flexibility can improve fit, but it also costs a parameter and may describe sample noise rather than a dependable feature. Comparing the curves therefore involves both their fitted shapes and evidence about whether the extra cubic term improves the fit enough to justify its inclusion.

The comparison is meaningful when both models use the same response, predictor, observations, and least-squares fitting method. The cubic model must contain every term in the quadratic model; then the models are nested, and a partial \(F\) test can assess the added cubic term. A test result is not a substitute for looking at the curves over the observed predictor range.

The Models and the Nested-Model Test

Definition: For a predictor \(x\) and response \(Y\), a quadratic regression model has conditional mean \(E(Y\mid x)=\beta_0+\beta_1x+\beta_2x^2\). A cubic regression model has conditional mean \(E(Y\mid x)=\beta_0+\beta_1x+\beta_2x^2+\beta_3x^3\). The cubic model contains the quadratic model as the special case \(\beta_3=0\).

For the usual exact \(F\) test, assume the errors are independent, normally distributed with mean zero and common variance \(\sigma^2\), and that the stated polynomial form adequately describes the conditional mean. The predictor values are treated as fixed, or as given by a design independent of the errors. These assumptions support the model-based reference distribution; they should not be inferred merely from a small p-value or a large one.

Let \(SSE_Q\) and \(SSE_C\) be the residual sums of squares from the quadratic and cubic fits, respectively. If the cubic model adds \(q\) terms, the partial \(F\) statistic is

$$ F=\frac{(SSE_Q-SSE_C)/q}{SSE_C/df_C}, $$

where \(df_C=n-p_C\) is the cubic model's residual degrees of freedom and \(p_C\) is its number of fitted coefficients, including the intercept. For a quadratic-versus-cubic comparison, \(q=1\), and the null hypothesis is \(H_0:\beta_3=0\); the alternative is \(H_a:\beta_3\ne 0\). Under \(H_0\) and the assumptions above, the statistic follows an \(F\) distribution with \(1\) and \(df_C\) degrees of freedom.

Worked Example: Fitting Both Curves to Hypothetical Dose-Response Data

Worked Example: Fitting Both Curves to Hypothetical Dose-Response Data

Suppose a hypothetical experiment records a response score \(Y\) at eight dose settings. The predictor \(x\) is dose measured as a centered dose-unit value; negative values mean below the chosen center. Fit quadratic and cubic least-squares curves to the same observations.

Dose \(x\) (dose units)Response \(Y\) (score points)
-3.511.74
-2.516.64
-1.520.66
-0.515.60
0.521.86
1.520.60
2.520.24
3.520.14

The least-squares quadratic fit is \(\hat{Y}_Q=20.0300+0.9867x-0.3038x^2\), with \(SSE_Q=27.2219\) score-points-squared. The cubic fit is \(\hat{Y}_C=20.0300+0.4625x-0.3038x^2+0.0567x^3\), with \(SSE_C=25.3145\) score-points-squared (coefficients rounded to four decimals). As a check, the fitted values of each model sum to the same total as the responses, 147.48, as least squares with an intercept requires. The terms use powers of dose, so the coefficient units differ: for example, the cubic coefficient is in score points per dose-unit cubed.

The data and fits can be checked by noting that the cubic curve's difference from the quadratic curve is \(0.0567x^3-0.5242x\), not just \(0.0567x^3\), because the fitted linear coefficient changes when the cubic term is included. The fitted quadratic and cubic curves both pass through the same fitted value at \(x=0\), namely 20.03 score points; with doses placed symmetrically about zero, the intercept and quadratic coefficient are unchanged by adding the cubic term. The cubic fit has a smaller residual sum of squares, as it must: setting its cubic coefficient to zero would reproduce the quadratic model, so least squares cannot fit worse when that term is added.

Worked Example: Testing Whether the Cubic Term Adds Evidence

Worked Example: Testing Whether the Cubic Term Adds Evidence

Use the fits above to test whether the cubic term improves the model beyond the quadratic terms. There are eight observations. The quadratic fit has three coefficients and the cubic fit has four, so \(df_C=8-4=4\). One term is added, giving \(q=1\).

The reduction in residual sum of squares is \(27.2219-25.3145=1.9074\) score-points-squared. The cubic model's residual mean square is \(25.3145/4=6.3286\) score-points-squared. Thus

$$ F=\frac{(27.2219-25.3145)/1}{25.3145/4} =\frac{1.9074}{6.3286} =0.3014. $$

Under \(H_0:\beta_3=0\), this is compared with an \(F\) distribution with 1 and 4 degrees of freedom. The corresponding p-value is \(p=0.6122\). At a significance level such as \(\alpha=0.05\), the result is not statistically significant: these data do not provide strong evidence that adding the cubic term improves the mean model beyond the quadratic terms. This is not evidence that the true cubic coefficient is exactly zero.

For one added coefficient, the partial \(F\) statistic equals the square of the corresponding \(t\) statistic. Here \(t=\sqrt{0.3014}=0.549\), with 4 degrees of freedom, giving the same two-sided p-value. This equivalence is specific to a one-coefficient addition; a comparison adding several terms uses a joint \(F\) test.

Worked Example: Comparing the Fitted Shapes in Context

Worked Example: Comparing the Fitted Shapes in Context

For the dose-response fits, compare their predictions at three points within the observed range, \(-3.5\), \(0\), and \(3.5\) dose units. At \(x=-3.5\), the quadratic prediction is \(20.03+0.9867(-3.5)-0.3038(-3.5)^2\approx12.86\) score points. The cubic prediction is \(20.03+0.4625(-3.5)-0.3038(-3.5)^2+0.0567(-3.5)^3\approx12.26\) score points.

At \(x=0\), both predict 20.03 score points. At \(x=3.5\), the quadratic prediction is \(20.03+0.9867(3.5)-0.3038(3.5)^2\approx19.76\) score points, while the cubic prediction is \(20.03+0.4625(3.5)-0.3038(3.5)^2+0.0567(3.5)^3\approx20.36\) score points. Thus the cubic curve sits about 0.60 score points below the quadratic curve at \(x=-3.5\) and about 0.60 above it at \(x=3.5\), while the fitted curves agree at the center.

The fitted cubic curve is a plausible description of a shape that differs on either side of the center, but its improvement is not compelling by the stated test. Given the limited sample and the nonsignificant added-term test, the quadratic fit is a defensible simpler summary over these observed dose settings, provided residual checks do not reveal a serious lack of fit. The comparison does not establish that the quadratic relationship is true, nor that the cubic curve would be inappropriate in another setting.

How to Make a Defensible Comparison

A nested-model test addresses a particular question: whether the reduction in residual variation from the added term is large relative to the cubic model's residual variation. It does not decide every aspect of model quality. Before interpreting the result, check that the comparison uses the same observations and response scale, that the model hierarchy is respected, and that the error assumptions are reasonable for the intended inference.

In practice, inspect a plot of both fitted curves across the observed \(x\)-values and examine residuals from the candidate fit for systematic patterns, changing spread, and unusually influential observations. With only eight observations, such checks have limited ability to reveal violations, and normality is particularly difficult to assess. If the design has independent experimental units, that supports the independence assumption; if measurements are repeated on the same unit, independence cannot simply be presumed. Any p-value should be described as conditional on the model assumptions.

A cubic fit can have a visibly different shape even if its added term is not significant. Conversely, statistical evidence for a cubic term does not automatically make the cubic model scientifically useful. Consider whether the shape is meaningful in context, whether it is supported by enough observations across the range, and whether it improves the intended description or prediction. Restrict conclusions to the observed range; a polynomial can change direction sharply beyond the data.

Common pitfall: “The cubic model has a smaller SSE, so it is automatically the better model.” The SSE cannot increase when a nested term is added, even if that term captures only random variation. Compare the reduction in SSE with the cubic model's residual variation using the nested-model test, and also assess whether the fitted shape is sensible over the observed range. A nonsignificant result is not proof that the quadratic model is exactly correct.
Key takeaway: A quadratic-versus-cubic comparison combines a shape comparison with a one-term nested-model test. Report the fitted curves, the partial \(F\) statistic and its degrees of freedom, the p-value, and a cautious conclusion tied to the observed predictor range.

Check Your Understanding

Use these questions to check both the calculation and the interpretation.

  1. For a quadratic model with \(SSE_Q=24\) and a cubic model with \(SSE_C=18\), based on \(n=12\) observations, calculate the cubic model's residual degrees of freedom and the partial \(F\) statistic.
  2. State the null hypothesis for comparing a quadratic fit with a cubic fit, and explain what a small p-value would indicate.
  3. Why must both models be fitted to the same observations for this nested-model comparison?
  4. If the cubic model has a smaller SSE but its added-term test is not significant, what can and cannot be concluded?
  5. Why should a conclusion about which curve is defensible be restricted to the observed predictor range?