From Observations to a Quadratic Curve
A scatterplot may show a relationship that bends rather than following a straight line. A quadratic regression represents one kind of bend: the fitted slope changes steadily as the predictor changes. The useful question is not only how to calculate the curve, but how to explain what it says over the range of data—and where that explanation stops.
This tutorial follows a hypothetical dataset of plant stress scores recorded at different fertilizer doses. The goal is to fit a quadratic least-squares model, report its equation, interpret its turning point and local slopes, and calculate predictions that could be plotted with the observed data. The numbers are illustrative, not results from a real experiment.
Worked Example: Fit the Quadratic Model
Worked Example: Fitting the Plant-Stress Data
Suppose seven independently observed plots, under comparable conditions, have these fertilizer doses and stress scores. Dose is measured in grams per square metre, and stress score is in points.
| Dose \(x\) (g/m²) | Observed stress score \(y\) (points) |
|---|---|
| 0 | 27.8 |
| 1 | 26.2 |
| 2 | 23.2 |
| 3 | 20.0 |
| 4 | 17.8 |
| 5 | 17.8 |
| 6 | 21.2 |
A centered predictor makes the arithmetic easier. Set \(t=x-3\), so the observed \(t\)-values are \(-3,-2,-1,0,1,2,3\). Write the fitted model as \(\hat y=A+Bt+Ct^2\). For these values, \(\sum t=0\), \(\sum t^2=28\), and \(\sum (t^2-4)^2=84\). The sample mean response is \(154/7=22\).
The least-squares slope for the centered linear component is \(B=\sum ty/\sum t^2=(-42)/28=-1.5\) points per unit of \(t\). The quadratic coefficient is \(C=\sum (t^2-4)y/\sum (t^2-4)^2=42/84=0.5\) points per squared unit of \(t\). Since the average of \(t^2\) is \(28/7=4\), the fitted value at \(t=0\) is \(A=\bar y-C(4)=22-0.5(4)=20\) points. Thus the centered fit is \(\hat y=20-1.5t+0.5t^2\).
The residuals, observed minus fitted, are \(-1.2,1.2,1.2,0,-1.2,-1.2,1.2\) points. They sum to zero and are orthogonal to both \(t\) and \(t^2\): \(\sum e_i=0\), \(\sum t_ie_i=0\), and \(\sum t_i^2e_i=0\). These are the least-squares normal equations, so this curve minimizes the sum of squared residuals. The seven distinct predictor values also ensure that the three model columns \(1,t,t^2\) are linearly independent.
To express the fit using the original dose \(x\), substitute \(t=x-3\): \(\hat y=20-1.5(x-3)+0.5(x-3)^2=29-4.5x+0.5x^2\). The fitted equation is therefore \(\hat y=29-4.5x+0.5x^2\), with predicted stress in points for dose \(x\) in grams per square metre. The intercept, 29 points, is the fitted score at zero dose; it is not the average score in the dataset.
Why Centered and Original Equations Agree
Centering changes the coefficients used to describe the curve, but it does not change its fitted values. Expanding the centered equation gives the original equation:
The two forms are useful for different explanations. In the centered equation, the coefficient on \(t\) is the fitted slope at \(x=3\), the center of the observed doses. In the original equation, the coefficient on \(x\) alone is not the slope at every dose; the quadratic term changes the slope. Neither equation says that fertilizer dose causes stress to change. A causal conclusion would require a suitable study design and supporting assumptions.
Worked Example: Interpret the Vertex and Local Slopes
Worked Example: Locating the Minimum and Describing Change
The fitted curve is \(\hat y=29-4.5x+0.5x^2\). Because its quadratic coefficient is positive, it opens upward and has a minimum at its vertex. For a quadratic \(a+bx+cx^2\), the vertex occurs at \(x=-b/(2c)\). Substitution gives \(x=-(-4.5)/(2(0.5))=4.5\) g/m². The predicted stress there is \(\hat y=29-4.5(4.5)+0.5(4.5)^2=29-20.25+10.125=18.875\) points.
The fitted vertex is \((4.5,18.875)\): within the observed dose range of 0 to 6 g/m², the curve reaches its lowest fitted score at a dose of 4.5 g/m². This is a feature of the fitted curve, not proof that 4.5 g/m² is an optimal dose in a biological or causal sense.
The local slope at dose \(x\) is the derivative of the fitted curve: \(d\hat y/dx=-4.5+2(0.5)x=x-4.5\). Its units are stress-score points per (g/m²). For example, at \(x=2\), the slope is \(2-4.5=-2.5\) points per (g/m²); at \(x=5\), it is \(5-4.5=0.5\) points per (g/m²). The negative slope describes a decreasing fitted curve at \(x=2\), while the positive slope describes an increasing fitted curve at \(x=5\). The slope is zero at the vertex. These are local rates of change, not predictions that the score changes by exactly that amount for every one-unit dose increase across the whole range.
Worked Example: Calculate Predictions for a Plot
Worked Example: Tabulating the Fitted Curve
To plot the fitted curve over the observed range, evaluate the equation at a sequence of doses from 0 through 6 g/m². For instance, at \(x=2\), \(\hat y=29-4.5(2)+0.5(2)^2=29-9+2=22\) points. At \(x=4.5\), the calculation gives 18.875 points, as in the vertex calculation. The full set of integer-dose predictions is:
| Dose \(x\) (g/m²) | Observed score (points) | Fitted score \(\hat y\) (points) |
|---|---|---|
| 0 | 27.8 | 29 |
| 1 | 26.2 | 25 |
| 2 | 23.2 | 22 |
| 3 | 20.0 | 20 |
| 4 | 17.8 | 19 |
| 5 | 17.8 | 19 |
| 6 | 21.2 | 20 |
A plot would show the seven observed points and a smooth curve passing through the fitted values, not necessarily through each observation. In this example the observations at doses 0 and 2 are respectively 1.2 points below and 1.2 points above their fitted values. The fitted values at doses 4 and 5 are both 19 points, while each corresponding observed score is 17.8 points. A residual is the vertical difference between an observed point and its fitted value.
The curve is U-shaped over the displayed range, with the fitted minimum between the observed doses 4 and 5. Plotting predictions at intermediate doses, such as 4.5, helps show the curve’s shape; it does not add new observed information.
Check the Fit and Respect Its Limits
A fitted equation is a compact description of the pattern in the data, not a guarantee that the quadratic model is appropriate. A useful check is to examine the scatterplot and residuals for structure the curve has failed to capture. In the example, the residuals are modest relative to the overall response values, but that fact alone does not establish that the quadratic mean model, independence, or constant variance is reasonable. With only seven observations, there is also limited information for assessing assumptions.
The equation is supported by observations only from 0 to 6 g/m². Predictions within this interval use doses inside the observed range, though they may still be imperfect. Predictions beyond it are extrapolations: the same polynomial can rise rapidly as dose increases, but the observed data do not establish that the pattern continues. Even an in-range minimum should be reported as the fitted minimum, not as a proven biological threshold or recommendation.
A clear applied report gives the fitted equation with units, identifies whether the vertex lies within the observed predictor range, and describes slopes at relevant predictor values. It also states that the curve summarizes an association in the observed data and notes the range beyond which the model has not been checked. These details make a plotted quadratic informative without implying more than the fit can support.
Check Your Understanding
Use the fitted model and data in this tutorial to answer the following.
- What is the fitted stress score at a dose of 3 g/m²? Show the substitution into the original-scale equation.
- At what dose does the fitted curve reach its minimum, and is that dose within the observed range?
- Calculate the local slope at 1 g/m² and interpret its sign and units.
- Why is the coefficient \(-4.5\) not the slope at every dose?
- What would be one limitation of using this fitted equation to predict stress at 10 g/m²?