Tutorials › Regression Analysis (Undergraduate) › Building Cubic Regression Models

Polynomial Regression · Tutorial 433 of 991

Building Cubic Regression Models

You will learn how to write and use a cubic regression model, and why its cubed term allows patterns that a quadratic model cannot represent.

Intermediate 10 min read

What You'll Learn

  • Write a cubic conditional-mean model with linear, squared, and cubed predictor terms.
  • Distinguish a polynomial in the predictor from a model that is nonlinear in its coefficients.
  • State the assumptions needed for cubic regression and conditions for estimating its coefficients.
  • Explain why the cubed term permits curve patterns beyond those available from a quadratic.
  • Calculate fitted predictions and interpret the cubic term without treating it as a standalone slope.

Why Add a Cubed Term?

A quadratic regression can represent a curved relationship whose bend has one general direction across the predictor range. Some relationships are more flexible: their rate of change in response may itself change in a way that a single quadratic curve cannot capture. A cubic regression adds the predictor raised to the third power, allowing a wider range of shapes while retaining the linear and squared terms.

The purpose of adding a term is not to make a model look more complicated. It is to give the model a form that can represent a plausible pattern in the conditional mean of the response. The cubic term changes the possible fitted curve, but it does not by itself establish that the relationship is cubic, explain why the pattern occurs, or guarantee that a cubic model is appropriate.

Definition and Model Assumptions

Definition: A cubic regression model for a quantitative response \(Y_i\) and quantitative predictor \(x_i\) specifies the conditional mean as $$ \mathrm{E}(Y_i\mid x_i)=\beta_0+\beta_1x_i+\beta_2x_i^2+\beta_3x_i^3. $$ The observed response is written \(Y_i=\beta_0+\beta_1x_i+\beta_2x_i^2+\beta_3x_i^3+\varepsilon_i\), where \(\varepsilon_i\) is the error for observation \(i\).

The model includes the intercept, the linear term, the squared term, and the cubed term. Including the lower-order terms is the usual hierarchical specification: the cubic term is added to a model that already contains the linear and quadratic terms. The coefficients \(\beta_0,\beta_1,\beta_2,\beta_3\) are unknown parameters, estimated from the data.

Although the mean is a cubic function of \(x_i\), the model is linear in its coefficients: every coefficient appears as a multiplier and is not raised to a power or placed inside another function. This means the usual least-squares method can estimate the coefficients by treating \(x_i\), \(x_i^2\), and \(x_i^3\) as predictor columns.

Before fitting the model, state the conditions being assumed. The conditional mean should be adequately represented by the specified cubic over the predictor range of interest. The errors should have conditional mean zero, be independent across observations, and have constant conditional variance \(\sigma^2\). Normal errors, conditional on the predictor values, are an additional assumption when exact small-sample normal-theory inference is used. The predictor values must provide enough distinct information to estimate four coefficients; at least four distinct \(x\)-values are needed for the four columns to have full rank, and more than four observations are needed to leave residual degrees of freedom for estimating error variation.

These conditions are assumptions about the data and model, not consequences of writing down a cubic equation. In practice, the study design and residual patterns can help assess whether independence, constant variance, and the proposed mean pattern are reasonable. A cubic polynomial should not be taken as a guarantee that every feature of the data has been modeled correctly.

What the Cubic Term Adds

A quadratic model is obtained by setting \(\beta_3=0\). If that coefficient is not zero, the cubed term contributes an amount \(\beta_3x^3\) to the fitted mean. Its contribution varies with \(x\): it is small near zero and grows in magnitude as \(|x|\) grows. The squared term also remains in the model, so the final curve is determined by all three predictor terms together, not by \(\beta_3\) alone.

One algebraic way to see the extra flexibility is to compare successive changes in fitted means at equally spaced predictor values. For a quadratic, those changes have a constant second difference. For a cubic, the second differences can vary across the predictor range. Thus a cubic can represent a pattern whose bending changes in a way a quadratic cannot. This is a statement about the range of possible fitted shapes; whether a particular data set calls for that extra flexibility is a separate modeling question.

The coefficients also depend on the predictor’s units. If \(Y\) is measured in response units and \(x\) in predictor units, then \(\beta_1\) has units of response units per predictor unit, \(\beta_2\) has response units per predictor unit squared, and \(\beta_3\) has response units per predictor unit cubed. As with other polynomial models, none of these higher-order coefficients should be read in isolation as the overall change in response for a one-unit increase in \(x\).

Worked Example: Specifying and Using a Cubic Model

Suppose a laboratory exercise uses a hypothetical chemical dose \(x\), measured in dose-units, to predict a response \(Y\), measured in response-units. The observations cover several dose levels. Assume the design and residual checks are consistent with independent errors, a roughly constant error variance, and a cubic conditional mean over the observed dose range. For illustration, suppose least squares gives the fitted model $$ \widehat{\mathrm{E}}(Y\mid x)=12+2x-0.4x^2+0.05x^3. $$

The specification includes all four terms: an intercept, \(x\), \(x^2\), and \(x^3\). To calculate the fitted response at \(x=4\) dose-units, substitute \(4\) in every predictor term: $$ \hat{Y}(4)=12+2(4)-0.4(4^2)+0.05(4^3). $$ The arithmetic is $$ \hat{Y}(4)=12+8-6.4+3.2=16.8. $$ The model’s fitted conditional mean at a dose of 4 dose-units is therefore 16.8 response-units. This is a model-based predicted mean, not a claim that every observation at that dose will equal 16.8.

The cubed term contributes \(0.05(4^3)=3.2\) response-units to this particular fitted value. It would be incorrect to call 0.05 the change in response for every one-unit increase in dose: the contribution from the cubed term itself changes with \(x\), and the other terms contribute too.

Worked Example: Keeping the Lower-Order Terms

Consider a hypothetical model relating a predictor \(x\), measured in index-units, to an outcome \(Y\), measured in score-units. Suppose the specified conditional mean is $$ \mathrm{E}(Y\mid x)=30+1.5x-0.2x^2+0.08x^3. $$ Assume the observations provide enough distinct predictor values to estimate all four coefficients, and that independence, mean-zero errors, and constant conditional variance are reasonable for this illustration.

At \(x=2\), the separate contributions to the fitted mean are $$ 30,\qquad 1.5(2)=3,\qquad -0.2(2^2)=-0.8,\qquad 0.08(2^3)=0.64. $$ Therefore, $$ \widehat{\mathrm{E}}(Y\mid 2)=30+3-0.8+0.64=32.84\text{ score-units}. $$ At \(x=3\), the cubed-term contribution is $$ 0.08(3^3)=0.08(27)=2.16\text{ score-units}, $$ rather than the \(0.64\) score-units it contributed at \(x=2\). The full fitted mean at \(x=3\) is $$ 30+1.5(3)-0.2(3^2)+0.08(3^3) =30+4.5-1.8+2.16 =34.86\text{ score-units}. $$

The change in fitted mean between these two particular predictor values is \(34.86-32.84=2.02\) score-units. It is not equal to the cubic-term contribution at either point, because the intercept, linear term, and squared term also affect both fitted means. This illustrates why \(\beta_3\) describes a component of the curve rather than a standalone effect.

A Short Justification of the Added Flexibility

The difference argument can be shown directly. Let \(m(x)=\beta_0+\beta_1x+\beta_2x^2+\beta_3x^3\), and take predictor values separated by a fixed spacing \(h\). Define the first difference as \(m(x+h)-m(x)\); the second difference is the difference between two successive first differences.

For the quadratic portion, the second difference is constant: $$ \bigl[\beta_2(x+2h)^2-\beta_2(x+h)^2\bigr] -\bigl[\beta_2(x+h)^2-\beta_2x^2\bigr] =2\beta_2h^2. $$ The intercept and linear term have zero second difference. For the cubic portion, expanding the terms gives $$ \bigl[(x+2h)^3-(x+h)^3\bigr] -\bigl[(x+h)^3-x^3\bigr] =6h^2x+6h^3. $$ Thus the second difference of the full cubic mean is $$ 2\beta_2h^2+\beta_3(6h^2x+6h^3), $$ which varies with \(x\) when \(\beta_3\ne 0\). A quadratic cannot produce this changing second-difference pattern, while a cubic can. This algebra explains the extra shape flexibility without requiring a cubic term to be present in every useful model.

Worked Example: Seeing a Pattern a Quadratic Cannot Match

For a hypothetical response measured in response-units, consider the cubic mean function \(m(x)=20+x^3-3x\), with \(x\) measured in predictor-units. Treat the following values as an illustration of the model’s shape, and suppose the error assumptions stated earlier are reasonable for observations around this mean.

At the equally spaced predictor values \(-2,-1,0,1,2\), the fitted means are $$ m(-2)=20-8+6=18,\quad m(-1)=20-1+3=22,\quad m(0)=20,\quad m(1)=20+1-3=18,\quad m(2)=20+8-6=22. $$ The first differences are \(4,-2,-2,4\), so the second differences are \(-6,0,6\). Because these second differences are not constant, no quadratic function can match all five values at these equally spaced points. A cubic term permits this varying pattern.

This example does not mean every data set with uneven second differences should automatically be fit with a cubic. Observed values include error, and the choice of mean function must be considered in context. The calculation only demonstrates that cubic regression can express a pattern outside the quadratic model’s shape restrictions.

Building the Model Carefully

1
Name the response and predictor.
Specify which variable is \(Y\), which is \(x\), and the units in which each is recorded.
2
Write the hierarchical cubic form.
Include \(1\), \(x\), \(x^2\), and \(x^3\) as the four model columns, with a separate coefficient for each.
3
Check that the data can support estimation.
There must be at least four distinct predictor values for the four coefficients to be identifiable; there should also be observations beyond the minimum to assess residual variation.
4
Keep the assumptions and interpretation in view.
Consider whether the mean pattern and error assumptions are plausible over the data range, and interpret predictions as conditional means rather than guaranteed individual outcomes.

Common Mistakes and Why the Model Matters

  • Keeping only the cubed term. Fitting \(Y=\beta_0+\beta_3x^3+\varepsilon\) imposes a different and more restricted form than the usual cubic model. The hierarchical cubic specification retains the linear and squared terms.
  • Calling \(\beta_3\) the slope. The cubed coefficient is the coefficient of one component, not a constant overall change in \(Y\). The full fitted mean combines the linear, squared, and cubed terms.
  • Assuming cubic means better. An added term gives a model more possible shapes, but does not ensure a better description of the underlying relationship. The proposed model must still make sense for the data and question.
  • Ignoring units. The squared and cubed coefficients have different units from the linear coefficient. Reporting them without the predictor and response scales can obscure their meaning.
  • Treating a prediction as an observed value. A fitted conditional mean describes the model’s average response at a given predictor value; individual observations can differ because of error.

Cubic regression matters because it offers a controlled extension of quadratic modeling: one additional term makes more varied mean patterns representable while preserving the familiar polynomial structure. A well-specified model makes its terms, units, and assumptions explicit. The added flexibility is useful only when it is supported by the data and appropriate to the scientific question.

Check Your Understanding

Answer each question using the cubic model and examples in this tutorial.

  1. Write the full cubic regression mean function and identify each predictor term.
  2. In a cubic model, what does it mean to say the model is linear in its coefficients?
  3. Why should a cubic model ordinarily retain the linear and squared terms as well as the cubed term?
  4. For a quadratic mean function evaluated at equally spaced predictor values, what is true of its second differences?
  5. A fitted cubic model predicts a conditional mean of 25 response-units at a particular \(x\). Does this mean each observation at that \(x\) will equal 25? Explain.