10.6 Practice problems
Problem 10.6.1. Consider the model \(y = \beta _0 + \beta _2x^2 + \varepsilon \), without a linear term.
- (a)
- Rewrite it in terms of \(z = x - c\), and show that it becomes a quadratic in \(z\) whose coefficients satisfy a constraint.
- (b)
- Explain why testing \(H_0\colon \beta _1 = 0\) in the full quadratic \(y = \beta _0 + \beta _1x + \beta _2x^2 + \varepsilon \) is usually not a sensible way to simplify the model.
Show solution
Solution. (a) With \(x = z + c\), \(\beta _0 + \beta _2(z + c)^2 = (\beta _0 + \beta _2c^2) + 2\beta _2c\,z + \beta _2z^2\). This is \(\gamma _0 + \gamma _1z + \gamma _2z^2\) with the constraint \(\gamma _1 = 2c\gamma _2\): the turning point is forced to be at \(z = -\gamma _1/(2\gamma _2) = -c\), that is, at \(x = 0\). Dropping the linear term is the statement that the curve turns exactly at the origin of \(x\), which is a property of the coding, not of the data, unless \(x = 0\) has a special meaning.
(b) In the full quadratic, \(\beta _1 + 2\beta _2x\) is the slope, so \(\beta _1\) is the slope at \(x = 0\). Whether that is zero depends on where the origin is: by Theorem 10.1.2, changing the origin changes \(\beta _1\) but not the fit. A test of \(\beta _1 = 0\) asks whether the turning point is at \(x = 0\), which is seldom a question of interest. The hierarchy principle keeps all lower-order terms.
Problem 10.6.2. For \(x = 1, 2, 3, 4, 5\) and \(y = 1, 5, 8, 7, 6\):
- (a)
- find the orthogonal polynomials \(P_1\) and \(P_2\) (scaled to integer values);
- (b)
- fit the quadratic by orthogonal polynomials, give the analysis of variance, and test the quadratic term;
- (c)
- write the fitted model in terms of \(x\) and find the turning point.
Show solution
Solution. (a) Here \(n = 5\), \(u = x - 3\) takes the values \(-2, \dots , 2\), and \((n^2 - 1)/12 = 2\), so \(P_1 = u = -2, -1, 0, 1, 2\) and \(P_2 = u^2 - 2 = 2, -1, -2, -1, 2\), with \(\sum P_1^2 = 10\) and \(\sum P_2^2 = 14\).
(b) \(\sum P_1y = -2 - 5 + 0 + 7 + 12 = 12\) and \(\sum P_2y = 2 - 5 - 16 - 7 + 12 = -14\), so \(\hat \alpha _1 = 1.2\) and \(\hat \alpha _2 = -1\), and \(\bar y = 27/5 = 5.4\). Then \(SS(\alpha _1) = 144/10 = 14.4\) and \(SS(\alpha _2) = 196/14 = 14\). With \(\sum y^2 = 175\), \(SS_T = 175 - 27^2/5 = 29.2\), so \(SS_{\mathrm {Res}} = 29.2 - 14.4 - 14 = 0.8\) on \(2\) degrees of freedom, \(MS_{\mathrm {Res}} = 0.4\).
| Source | SS | df | MS | \(F_0\) |
| Linear | 14.4 | 1 | 14.4 | 36 |
| Quadratic | 14.0 | 1 | 14.0 | 35 |
| Residual | 0.8 | 2 | 0.4 | |
| Total | 29.2 | 4 |
\(F_0 = 35 > F_{0.05,1,2} = 18.51\), so the quadratic term is significant.
(c) \(\hat y = 5.4 + 1.2u - (u^2 - 2) = 7.4 + 1.2u - u^2\), and with \(u = x - 3\), \(\hat y = 7.4 + 1.2x - 3.6 - (x^2 - 6x + 9) = -5.2 + 7.2x - x^2\). The turning point is at \(u = 0.6\), \(x = 3.6\), where \(\hat y = 7.4 + 0.72 - 0.36 = 7.76\).
Problem 10.6.3. Suppose the \(x\) values are symmetric about \(\bar x\), and fit the cubic \(y = \beta _0 + \beta _1u + \beta _2u^2 + \beta _3u^3 + \varepsilon \) with \(u = x - \bar x\). Show that, after reordering the columns as \((\mathbf {1}, \mathbf {u}^2 \mid \mathbf {u}, \mathbf {u}^3)\), \(\mathbf {X}^\top \mathbf {X}\) is block diagonal, and deduce that adding \(u^3\) to the centred quadratic changes \(\hat \beta _1\) but not \(\hat \beta _0\) or \(\hat \beta _2\).
Show solution
Solution. The entries of \(\mathbf {X}^\top \mathbf {X}\) are the sums \(\sum u_i^{a + b}\) for columns \(u^a\) and \(u^b\). An even column (\(a = 0, 2\)) with an odd column (\(b = 1, 3\)) has \(a + b\) odd, and the sum is zero by Theorem 10.1.3. So \(\mathbf {X}^\top \mathbf {X} = \operatorname {diag}(\mathbf {A}_{\mathrm {even}}, \mathbf {A}_{\mathrm {odd}})\), and its inverse is block diagonal too. The normal equations split into two separate systems: \((\hat \beta _0, \hat \beta _2)\) from the even columns alone and \((\hat \beta _1, \hat \beta _3)\) from the odd columns alone. Adding \(u^3\) enlarges only the odd system, so \(\hat \beta _0\) and \(\hat \beta _2\) are unchanged, while \(\hat \beta _1\) changes because \(\sum u^4 \ne 0\) couples \(\mathbf {u}\) and \(\mathbf {u}^3\). For the irrigation data, adding \(\hat \alpha _3P_3 = \frac 16(u^3 - 7u)/6\) to the quadratic of Example 10.2.2 gives the cubic \(\hat y = 26.143 + 2.806u - u^2 + 0.0278u^3\): the even coefficients \(26.143\) and \(-1\) are unchanged, and \(\hat \beta _1\) moves from \(3\) to \(3 - 7/36 = 2.806\).
Problem 10.6.4. A fitted second-order model in two coded variables is \[ \hat y = 50 + 2x_1 - 2x_2 + x_1^2 + x_2^2 + 4x_1x_2 . \] Find the stationary point, write the surface in canonical form, and describe it.
Show solution
Solution. Here \(\mathbf {b} = (2, -2)^\top \) and \(\mathbf {B} = \begin {pmatrix} 1 & 2 \\ 2 & 1 \end {pmatrix}\), with \(\det \mathbf {B} = -3\) and \(\mathbf {B}^{-1} = -\frac 13\begin {pmatrix} 1 & -2 \\ -2 & 1 \end {pmatrix}\). Then \(\mathbf {B}^{-1}\mathbf {b} = -\frac 13(2 + 4, -4 - 2)^\top = (-2, 2)^\top \), so \(\mathbf {x}_s = -\frac 12(-2, 2)^\top = (1, -1)^\top \) and \(\hat y_s = 50 + \frac 12(2 + 2) = 52\). The eigenvalues of \(\mathbf {B}\) are \(1 + 2 = 3\), with eigenvector \((1, 1)/\sqrt 2\), and \(1 - 2 = -1\), with eigenvector \((1, -1)/\sqrt 2\), so \[ \hat y = 52 + 3w_1^2 - w_2^2 . \] The eigenvalues have opposite signs: \((1, -1)\) is a saddle point, neither a maximum nor a minimum. The response increases fastest away from it along \(w_1\), the direction in which \(x_1\) and \(x_2\) change together, and decreases along \(w_2\). To increase the response, move along \(w_1\), keeping in mind that the model is only trustworthy inside the region of the data.
- (a)
- In the truncated power representation of Theorem 10.3.1, show that \(s'''\) jumps by \(6\gamma _i\) at \(t_i\).
- (b)
- Count the parameters of a cubic spline with \(h\) knots in another way: start from \(h + 1\) unrelated cubics and subtract the number of continuity conditions.
Show solution
Solution. (a) The terms \(\beta _0 + \dots + \beta _3x^3\) have constant third derivative \(6\beta _3\), and \((x - t_l)_+^3\) has third derivative \(6\) for \(x > t_l\) and \(0\) for \(x < t_l\). So \(s'''(x) = 6\beta _3 + 6\sum _{t_l < x}\gamma _l\), a step function that rises by \(6\gamma _i\) as \(x\) crosses \(t_i\).
(b) \(h + 1\) separate cubics have \(4(h + 1)\) parameters. At each of the \(h\) knots, the value and the first and second derivatives must match: \(3h\) conditions. That leaves \(4(h + 1) - 3h = h + 4\), in agreement with the theorem.
Problem 10.6.6. With the uniform kernel, \(K(t) = 1\) for \(|t| \le 1\) and \(0\) otherwise, and \(h = 1\):
- (a)
- show that for equally spaced \(x\) with unit spacing, the kernel estimate at an interior \(x_i\) is the moving average \((y_{i-1} + y_i + y_{i+1})/3\);
- (b)
- compute the estimates at \(x = 1, 4, 7\) for the irrigation data and \(\operatorname {tr}\mathbf {S}\);
- (c)
- compare \(\operatorname {tr}\mathbf {S}\) with the triangular kernel with \(h = 2\) (Example 10.5.2).
Show solution
Solution. (a) The observations with \(|x_j - x_i| \le 1\) are \(x_{i-1}, x_i, x_{i+1}\), each with weight \(1\), so the weighted average is their plain average.
(b) \(\tilde y(4) = (23 + 26 + 27)/3 = 25.33\). At the ends only two observations are within \(1\): \(\tilde y(1) = (8 + 16)/2 = 12\) and \(\tilde y(7) = (29 + 26)/2 = 27.5\). The weight of \(y_i\) in its own estimate is \(\frac 12\) at the two ends and \(\frac 13\) at the five interior points, so \(\operatorname {tr}\mathbf {S} = 2(\frac 12) + 5(\frac 13) = 2.67\).
(c) Both kernels reach the same neighbours, but the uniform kernel gives them full weight, so it smooths more: \(2.67\) effective parameters against \(3.83\). The end estimate \(12\) is even further from \(y_1 = 8\) than the triangular kernel’s \(10.67\).
Questions on this section
Stuck on something here? Ask below and it stays attached to this topic.