| Source | \(\sum P_j\bar y\) | SS | df | \(F\) |
|---|---|---|---|---|
| Doses | 18.3700 | 5 | 228.75 | |
| Linear | 19.147 | 15.7112 | 1 | 978.21 |
| Quadratic | -8.567 | 2.6210 | 1 | 163.19 |
| Cubic | 1.480 | 0.0365 | 1 | 2.27 |
| Quartic | 0.107 | 0.0012 | 1 | 0.08 |
| Quintic | -0.100 | 0.0001 | 1 | 0.01 |
| Error | 0.1927 | 12 | ||
| Total | 18.5628 | 17 |
13 Polynomial Regression, Orthogonal Polynomials and Optimum Doses
When the relation between \(y\) and \(x\) is curved, but the curvature is smooth and the range of \(x\) is limited, a polynomial in \(x\) is often an adequate empirical model. Yield response to fertilizer, irrigation, plant density and seed rate typically rises, levels off and may fall (diminishing returns), a shape well described by a quadratic. Although the fitted curve is not a straight line, the polynomial model is linear in the parameters, so all the theory of the previous chapters applies (Draper and Smith 1998; Montgomery, Peck, and Vining 2021; Gomez and Gomez 1984).
13.1 Polynomial models
The \(k\)th degree polynomial in one variable is
\[y=\beta_0+\beta_1x+\beta_2x^2+\cdots+\beta_kx^k+\varepsilon. \tag{13.1}\]
Setting \(x_j=x^j\) turns it into a multiple linear regression, so \(\hat{\boldsymbol\beta}=(\mathbf X'\mathbf X)^{-1}\mathbf X'\mathbf y\) with \(\mathbf X\) having columns \(\mathbf 1,\mathbf x,\mathbf x^2,\ldots,\mathbf x^k\). The second degree (quadratic) model
\[y=\beta_0+\beta_1x+\beta_2x^2+\varepsilon \tag{13.2}\]
is the most widely used. \(\beta_1\) is the linear effect and \(\beta_2\) the quadratic effect (curvature): \(\beta_2<0\) gives a curve that is concave downwards with a maximum, \(\beta_2>0\) a curve with a minimum.
Guidelines for polynomial fitting
- Order: keep the order as low as possible. A polynomial of degree \(n-1\) passes through all \(n\) points but is useless. Transformations or nonlinear models (Chapter 17) are often better than high-order polynomials. Rarely use more than degree 3.
- Model building: either increase the order until the highest term is non-significant (forward selection), or start with a high order and delete non-significant terms from the top (backward elimination). The two need not agree.
- Hierarchy: if \(x^2\) is in the model, \(x\) should be too, because the model should be invariant to shifting the origin of \(x\).
- Ill-conditioning: \(x\), \(x^2\), \(x^3\) are highly correlated when the range of \(x\) is narrow relative to its mean. Centering \(x\) (using \(x-\bar x\)) or using orthogonal polynomials removes this non-essential collinearity.
- Extrapolation: polynomials behave wildly outside the range of the data. A fitted quadratic predicts negative yields at high doses.
Example 13.1 The replicated nitrogen trial of Example 8.2 showed significant lack of fit for a straight line. Fit a quadratic and test it.
Solution
The quadratic fit is
\[\hat y=2.4336+0.03280N-9.561\times10^{-5}N^2,\]
with \(R^2=0.9876\). Both \(\hat\beta_1\) (\(t=21.50\)) and \(\hat\beta_2\) (\(t=-13.06\)) are highly significant. The lack of fit test now gives \(F=0.785\) on (3, 12) df (\(p=0.525\)), which is not significant: the quadratic adequately describes the response.
13.2 Orthogonal polynomials
Fitting \(1,x,x^2,\ldots\) directly has two drawbacks: the columns are highly correlated, and adding a higher-order term changes all the lower-order coefficients, so the model must be refitted. Both are avoided by using orthogonal polynomials:
\[y_i=\alpha_0P_0(x_i)+\alpha_1P_1(x_i)+\alpha_2P_2(x_i)+\cdots+\alpha_kP_k(x_i)+\varepsilon_i, \tag{13.3}\]
where \(P_j(x)\) is a polynomial of degree \(j\) and the polynomials are orthogonal over the design points:
\[\sum_{i=1}^nP_j(x_i)=0\ (j\ge1),\qquad \sum_{i=1}^nP_j(x_i)P_l(x_i)=0\ (j\neq l),\qquad P_0(x)=1.\]
Then \(\mathbf X'\mathbf X\) is diagonal, and
\[\hat\alpha_j=\frac{\sum_{i=1}^nP_j(x_i)y_i}{\sum_{i=1}^nP_j^2(x_i)},\qquad SS(\hat\alpha_j)=\frac{\left[\sum_iP_j(x_i)y_i\right]^2}{\sum_iP_j^2(x_i)},\qquad V(\hat\alpha_j)=\frac{\sigma^2}{\sum_iP_j^2(x_i)}. \tag{13.4}\]
The estimates are uncorrelated, adding a term of higher degree does not alter the earlier estimates, and the regression sum of squares splits into independent single-degree-of-freedom components (linear, quadratic, cubic, …), each tested by \(F=SS(\hat\alpha_j)/MS_{Res}\).
Equally spaced levels
When the \(n\) levels of \(x\) are equally spaced with interval \(d\), write \(u=(x-\bar x)/d\). The orthogonal polynomials are
\[\begin{aligned} P_1(x)&=\lambda_1u,\\ P_2(x)&=\lambda_2\left[u^2-\frac{n^2-1}{12}\right],\\ P_3(x)&=\lambda_3\left[u^3-u\left(\frac{3n^2-7}{20}\right)\right],\\ P_4(x)&=\lambda_4\left[u^4-u^2\left(\frac{3n^2-13}{14}\right)+\frac{3(n^2-1)(n^2-9)}{560}\right], \end{aligned} \tag{13.5}\]
where the constants \(\lambda_j\) are chosen to make all values integers. These values are tabulated (Table 13.1) and are widely used for partitioning treatment sums of squares in quantitative factor experiments.
| Levels | Degree | Coefficients | \(\sum P^2\) | \(\lambda\) |
|---|---|---|---|---|
| 3 | 1 | \(-1,\ 0,\ 1\) | 2 | 1 |
| 2 | \(1,\ -2,\ 1\) | 6 | 3 | |
| 4 | 1 | \(-3,\ -1,\ 1,\ 3\) | 20 | 2 |
| 2 | \(1,\ -1,\ -1,\ 1\) | 4 | 1 | |
| 3 | \(-1,\ 3,\ -3,\ 1\) | 20 | 10/3 | |
| 5 | 1 | \(-2,\ -1,\ 0,\ 1,\ 2\) | 10 | 1 |
| 2 | \(2,\ -1,\ -2,\ -1,\ 2\) | 14 | 1 | |
| 3 | \(-1,\ 2,\ 0,\ -2,\ 1\) | 10 | 5/6 | |
| 4 | \(1,\ -4,\ 6,\ -4,\ 1\) | 70 | 35/12 | |
| 6 | 1 | \(-5,\ -3,\ -1,\ 1,\ 3,\ 5\) | 70 | 2 |
| 2 | \(5,\ -1,\ -4,\ -4,\ -1,\ 5\) | 84 | 3/2 | |
| 3 | \(-5,\ 7,\ 4,\ -4,\ -7,\ 5\) | 180 | 5/3 | |
| 4 | \(1,\ -3,\ 2,\ 2,\ -3,\ 1\) | 28 | 7/12 | |
| 5 | \(-1,\ 5,\ -10,\ 10,\ -5,\ 1\) | 252 | 21/10 |
When each level is replicated \(r\) times, the computations use the level means \(\bar y_i\) and are multiplied by \(r\): \(SS_j=r\left(\sum P_j\bar y_i\right)^2/\sum P_j^2\).
Example 13.2 In the nitrogen trial (six equally spaced doses 0, 40, …, 200 kg/ha; \(r=3\)), partition the dose sum of squares into linear, quadratic, cubic, quartic and quintic components.
Solution
The dose means are \(2.397,\ 3.637,\ 4.490,\ 4.963,\ 5.167,\ 5.213\). Using the six-level coefficients of Table 13.1:
For example, the linear component is \(SS_L=3(19.147)^2/70=15.7112\). The five components add up to the dose SS (18.3700). With \(MS_{Error}=0.01606\) and \(F_{0.05}(1,12)=4.75\), the linear and quadratic components are significant and the higher-order components are not: the response is adequately described by a quadratic, in agreement with Example 13.1.
13.3 Optimum and economic doses
For the quadratic response \(\hat y=b_0+b_1x+b_2x^2\) with \(b_2<0\):
Physical (technical) optimum
The dose giving maximum yield satisfies \(d\hat y/dx=b_1+2b_2x=0\):
\[x_{\max}=-\frac{b_1}{2b_2},\qquad \hat y_{\max}=b_0-\frac{b_1^2}{4b_2}. \tag{13.6}\]
The second derivative \(2b_2<0\) confirms a maximum.
Economic optimum dose
The farmer’s aim is maximum profit, not maximum yield. With price \(p_y\) per unit of produce and cost \(p_x\) per unit of input, profit (above other costs) is \(\pi=p_y\hat y-p_xx\). Setting \(d\pi/dx=0\):
\[p_y(b_1+2b_2x)=p_x\quad\Rightarrow\quad x^*=\frac{p_x/p_y-b_1}{2b_2}. \tag{13.7}\]
At \(x^*\) the marginal product \(d\hat y/dx\) equals the price ratio \(p_x/p_y\): the last unit of input just pays for itself. Since \(p_x/p_y>0\) and \(b_2<0\), \(x^*<x_{\max}\). The economic optimum is less sensitive to the exact curve than the physical optimum, because the profit curve is flat near its maximum.
Example 13.3 For the quadratic response of Example 13.1 (yield in t/ha, N in kg/ha), find the physical optimum dose and the economic optimum dose when paddy sells at Rs 23,000 per tonne and nitrogen costs Rs 13 per kg.
Solution
By Equation 13.6,
\[x_{\max}=-\frac{0.03280}{2(-9.561\times10^{-5})}=171.5\ \text{kg N/ha},\qquad\hat y_{\max}=5.246\ \text{t/ha}.\]
The price ratio is \(p_x/p_y=13/23000=5.652\times10^{-4}\) t per kg. By Equation 13.7,
\[x^*=\frac{5.652\times10^{-4}-0.03280}{2(-9.561\times10^{-5})}=168.6\ \text{kg N/ha},\]
with expected yield 5.246 t/ha. Reducing N from 172 to 169 kg/ha costs only 0.8 kg/ha of grain while saving 3 kg of N.
The quadratic forces a symmetric response around the maximum, and often overestimates the optimum dose. Other response functions used in fertilizer research are the square-root model \(y=b_0+b_1\sqrt x+b_2x\), the Mitscherlich (exponential) model \(y=A(1-e^{-c(x+b)})\) (Mitscherlich 1909), and the linear-plateau model. The latter two are nonlinear (Chapter 17). When two or more quantitative factors are studied together (for example N and K), a second-order response surface \(y=\beta_0+\sum\beta_ix_i+\sum\beta_{ii}x_i^2+\sum\sum\beta_{ij}x_ix_j+\varepsilon\) is fitted, and its stationary point is found by solving the equations \(\partial\hat y/\partial x_i=0\).
13.4 R practical
nd <- read.csv("csv/ndose.csv")
q <- lm(yield ~ N + I(N^2), data = nd) # raw quadratic
summary(q)#>
#> Call:
#> lm(formula = yield ~ N + I(N^2), data = nd)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.27357 -0.03163 0.01933 0.08698 0.17119
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2.434e+00 6.488e-02 37.51 3.04e-16 ***
#> N 3.280e-02 1.526e-03 21.50 1.10e-12 ***
#> I(N^2) -9.561e-05 7.322e-06 -13.06 1.35e-09 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 0.124 on 15 degrees of freedom
#> Multiple R-squared: 0.9876, Adjusted R-squared: 0.9859
#> F-statistic: 596.3 on 2 and 15 DF, p-value: 5.085e-15
anova(q, lm(yield ~ factor(N), data = nd)) # lack of fit of the quadratic#> Analysis of Variance Table
#>
#> Model 1: yield ~ N + I(N^2)
#> Model 2: yield ~ factor(N)
#> Res.Df RSS Df Sum of Sq F Pr(>F)
#> 1 15 0.23058
#> 2 12 0.19273 3 0.037845 0.7854 0.5248
# Orthogonal polynomials: poly() and contr.poly()
qo <- lm(yield ~ poly(N, 2), data = nd)
summary(qo)$coef # uncorrelated estimates#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 4.311111 0.02922316 147.52379 3.911134e-25
#> poly(N, 2)1 3.963737 0.12398336 31.96991 3.247574e-15
#> poly(N, 2)2 -1.618948 0.12398336 -13.05778 1.351304e-09
contr.poly(6) # normalized coefficients for 6 levels#> .L .Q .C ^4 ^5
#> [1,] -0.5976143 0.5455447 -0.3726780 0.1889822 -0.06299408
#> [2,] -0.3585686 -0.1091089 0.5217492 -0.5669467 0.31497039
#> [3,] -0.1195229 -0.4364358 0.2981424 0.3779645 -0.62994079
#> [4,] 0.1195229 -0.4364358 -0.2981424 0.3779645 0.62994079
#> [5,] 0.3585686 -0.1091089 -0.5217492 -0.5669467 -0.31497039
#> [6,] 0.5976143 0.5455447 0.3726780 0.1889822 0.06299408
# Partition of dose SS into polynomial components
nd$Nf <- factor(nd$N); contrasts(nd$Nf) <- contr.poly(6)
summary(aov(yield ~ Nf, data = nd),
split = list(Nf = list(Linear = 1, Quadratic = 2, Cubic = 3, Quartic = 4, Quintic = 5)))#> Df Sum Sq Mean Sq F value Pr(>F)
#> Nf 5 18.370 3.674 228.752 1.81e-11 ***
#> Nf: Linear 1 15.711 15.711 978.214 7.18e-13 ***
#> Nf: Quadratic 1 2.621 2.621 163.189 2.40e-08 ***
#> Nf: Cubic 1 0.037 0.037 2.273 0.158
#> Nf: Quartic 1 0.001 0.001 0.076 0.788
#> Nf: Quintic 1 0.000 0.000 0.007 0.933
#> Residuals 12 0.193 0.016
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Optimum doses
b <- coef(q); px <- 13; py <- 23000
c(physical = unname(-b[2] / (2 * b[3])),
economic = unname((px / py - b[2]) / (2 * b[3])))#> physical economic
#> 171.5206 168.5648
plot(yield ~ N, data = nd, pch = 19, col = "darkgreen",
xlab = "Nitrogen (kg/ha)", ylab = "Grain yield (t/ha)")
xx <- seq(0, 200, 1); lines(xx, predict(q, data.frame(N = xx)), lwd = 2)
abline(v = -b[2] / (2 * b[3]), lty = 2); abline(v = (px / py - b[2]) / (2 * b[3]), lty = 3)
Fisher, Yates and orthogonal polynomials
Tables of orthogonal polynomial coefficients were published by R. A. Fisher in 1921 for the analysis of the Broadbalk wheat yields (Fisher 1921), and later extended by Fisher and Yates in their Statistical Tables for Biological, Agricultural and Medical Research (1938). Before computers, orthogonal polynomials turned the formidable task of fitting a cubic into a few additions and multiplications. The economics of fertilizer response, including the economic optimum dose, was developed by Earl Heady and John Dillon at Iowa State in the 1950s and became the basis of fertilizer recommendations worldwide.
“With four parameters I can fit an elephant, and with five I can make him wiggle his trunk.”
- John von Neumann
13.5 Practical exercises
13.5.1 Practical 13.1: Orthogonal polynomials for a phosphorus trial
A phosphorus trial on groundnut with four equally spaced levels (0, 30, 60, 90 kg P₂O₅/ha) in an RCBD with 3 replications gave mean pod yields of 18, 24, 27 and 28 q/ha. The error mean square was 1.2 with 6 df. Partition the treatment sum of squares into linear, quadratic and cubic components.
Solution
Using the four-level coefficients of Table 13.1:
| Component | Coefficients | \(\sum P\bar y\) | \(\sum P^2\) | SS \(=r(\sum P\bar y)^2/\sum P^2\) | \(F\) |
|---|---|---|---|---|---|
| Linear | \(-3,-1,1,3\) | 33 | 20 | 163.35 | 136.12 |
| Quadratic | \(1,-1,-1,1\) | -5 | 4 | 18.75 | 15.62 |
| Cubic | \(-1,3,-3,1\) | 1 | 20 | 0.15 | 0.12 |
| Treatments | 182.25 |
The components add up to the treatment SS. With \(F_{0.05}(1,6)=5.99\), the linear and quadratic components are significant and the cubic is not: the response is quadratic, with diminishing returns.
Doing it in R
means <- c(18, 24, 27, 28); r <- 3; MSE <- 1.2
P <- cbind(Linear = c(-3, -1, 1, 3), Quadratic = c(1, -1, -1, 1), Cubic = c(-1, 3, -3, 1))
SS <- r * colSums(P * means)^2 / colSums(P^2)
cbind(SS = SS, F = SS / MSE, p = pf(SS / MSE, 1, 6, lower.tail = FALSE))#> SS F p
#> Linear 163.35 136.125 2.389409e-05
#> Quadratic 18.75 15.625 7.513076e-03
#> Cubic 0.15 0.125 7.357649e-01
c(sum(SS), r * sum((means - mean(means))^2)) # components add to treatment SS#> [1] 182.25 182.25
contr.poly(4) # R's normalized version#> .L .Q .C
#> [1,] -0.6708204 0.5 -0.2236068
#> [2,] -0.2236068 -0.5 0.6708204
#> [3,] 0.2236068 -0.5 -0.6708204
#> [4,] 0.6708204 0.5 0.2236068
13.5.2 Practical 13.2: Optimum and economic dose of phosphorus
Fit a quadratic response to the mean yields of Practical 13.1 and find the physical optimum dose and the economic optimum dose when groundnut pods sell at Rs 6,000 per quintal and P₂O₅ costs Rs 60 per kg.
Solution
The fitted quadratic is \(\hat y=18.050+0.2350x-0.001389x^2\) (q/ha, kg/ha). By Equation 13.6, \(x_{\max}=-\dfrac{0.2350}{2(-0.001389)}=84.6\) kg/ha, with maximum yield 27.99 q/ha; this lies inside the tested range but close to its upper end, so the estimate depends heavily on the highest dose. The price ratio is \(60/6000=0.01\) q per kg, and by Equation 13.7
\[x^*=\frac{0.01-0.2350}{2(-0.001389)}=81.0\ \text{kg P}_2\text{O}_5\text{/ha}.\]
Doing it in R
gn <- data.frame(P = c(0, 30, 60, 90), y = c(18, 24, 27, 28))
q <- coef(lm(y ~ P + I(P^2), data = gn))
xmax <- -q[2] / (2 * q[3]); xeco <- (60 / 6000 - q[2]) / (2 * q[3])
c(physical = unname(xmax), economic = unname(xeco),
ymax = unname(q[1] + q[2] * xmax + q[3] * xmax^2))#> physical economic ymax
#> 84.6000 81.0000 27.9905
13.6 Chapter Summary
Fill in the blanks
Answers are given at the end of the chapter.
A polynomial regression model is linear in the __________.
In \(y=\beta_0+\beta_1x+\beta_2x^2+\varepsilon\), \(\beta_2<0\) gives a curve with a __________.
If \(x^2\) is in a polynomial model, \(x\) should also be included; this is the principle of __________.
The collinearity between \(x\) and \(x^2\) can be reduced by __________ \(x\).
With orthogonal polynomials, the matrix \(\mathbf X'\mathbf X\) is __________.
The estimate of the \(j\)th orthogonal polynomial coefficient is \(\hat\alpha_j=\) __________.
The linear coefficients for four equally spaced levels are __________.
The dose giving maximum yield in a quadratic response is __________.
At the economic optimum, the marginal product equals the __________.
The economic optimum dose is always __________ than the physical optimum.
Short-answer questions
Why is a polynomial model called a linear model?
State the guidelines for fitting polynomial models.
What is ill-conditioning in polynomial regression and how is it overcome?
What are orthogonal polynomials? State their advantages.
Write the orthogonal polynomials of degree 1 and 2 for equally spaced levels.
How is a treatment sum of squares partitioned into polynomial components?
Derive the physical optimum dose for a quadratic response.
Derive the economic optimum dose.
Why is the economic optimum smaller than the physical optimum?
Name other response functions used in fertilizer experiments.
Numerical and conceptual questions
Answers are given at the end of the chapter.
A quadratic response is \(\hat y=2.5+0.04x-0.0001x^2\) (t/ha, kg/ha). Find the physical optimum dose and maximum yield.
For Question 1, with output price Rs 20,000/t and input cost Rs 20/kg, find the economic optimum.
Four equally spaced doses with \(r=4\) gave means 20, 28, 33, 35. Compute the linear and quadratic sums of squares.
For Question 3, verify that the linear, quadratic and cubic SS add to the dose SS.
Write the coefficients of \(P_1\) and \(P_2\) for five levels and verify orthogonality.
If \(\hat y=10+3x-0.5x^2\), what is the marginal product at \(x=2\)?
Why should a fitted quadratic not be used to predict at doses beyond the experimental range?
Using Equation 13.5, derive the quadratic coefficients for three levels.
Important formulae
Quadratic model:
\[ y=\beta_0+\beta_1x+\beta_2x^2+\varepsilon \]
Orthogonal polynomial estimates and sums of squares:
\[ \hat\alpha_j=\frac{\sum P_j(x_i)y_i}{\sum P_j^2(x_i)},\qquad SS_j=\frac{(\sum P_jy_i)^2}{\sum P_j^2} \]
Orthogonal polynomials for equally spaced levels:
\[ P_1=\lambda_1u,\qquad P_2=\lambda_2\left[u^2-\frac{n^2-1}{12}\right],\qquad u=\frac{x-\bar x}d \]
Optimum doses:
\[ x_{\max}=-\frac{b_1}{2b_2},\qquad x^*=\frac{p_x/p_y-b_1}{2b_2} \]
Quick revision
- Polynomials → linear in parameters; keep low order; respect hierarchy.
- Centering or orthogonal polynomials → remove collinearity among powers.
- Orthogonal polynomials → diagonal \(\mathbf X'\mathbf X\), independent single-df SS components.
- Physical optimum → \(-b_1/2b_2\); economic optimum → marginal product = price ratio.
- Do not extrapolate polynomials.
Answers to fill in the blanks
1. Parameters 2. Maximum 3. Hierarchy 4. Centering 5. Diagonal 6. \(\sum P_jy/\sum P_j^2\) 7. \(-3,\ -1,\ 1,\ 3\) 8. \(-b_1/(2b_2)\) 9. Price ratio (\(p_x/p_y\)) 10. Smaller
Solutions to numerical and conceptual questions
\(x_{\max}=0.04/0.0002=200\) kg/ha; \(\hat y_{\max}=2.5+8-4=6.5\) t/ha (Equation 13.6).
\(p_x/p_y=20/20000=0.001\); \(x^*=(0.001-0.04)/(-0.0002)=195\) kg/ha (Equation 13.7).
\(\sum P_1\bar y=-60-28+33+105=50\), \(SS_L=4(50)^2/20=500\); \(\sum P_2\bar y=20-28-33+35=-6\), \(SS_Q=4(36)/4=36\).
\(\sum P_3\bar y=-20+84-99+35=0\), \(SS_C=0\). Dose SS \(=4\sum(\bar y-29)^2=4(81+1+16+36)=536=500+36+0\).
\(P_1=(-2,-1,0,1,2)\), \(P_2=(2,-1,-2,-1,2)\); \(\sum P_1=\sum P_2=0\) and \(\sum P_1P_2=-4+1+0-1+4=0\).
\(d\hat y/dx=3-x=1\) at \(x=2\).
The quadratic is an empirical approximation within the range; beyond it the curve falls symmetrically and can predict negative yields.
\(n=3\), \(u=-1,0,1\), \((n^2-1)/12=2/3\): \(u^2-2/3=1/3,\ -2/3,\ 1/3\); with \(\lambda_2=3\): \(1,\ -2,\ 1\).