Chapters 5 to 10 studied one variable at a time, or two groups. Most scientific questions ask how one measured quantity depends on another: how the weight of a finished rod depends on that of the rough casting, how mortality depends on smoking, how the price of a car depends on its age. This chapter gives the basic toolkit for a pair of variables. It begins without probability: the method of least squares fits the line (or, after a transformation, an exponential, power or logistic curve) closest to a cloud of points, and the residuals show whether it fits. It then adds the simple linear model, in which \(Y\) is normal with mean \(\beta_0+\beta_1x\), and derives the sampling laws that give tests and intervals for the slope, the intercept, the variance, the average response and a single new observation. It ends with correlation: the correlation coefficient, the bivariate normal law, the exact test of independence, and a warning about how the number \(r\) is misread. The book states most of these results and proves a few; these notes add the missing arguments (why the least squares line is the unique minimiser, what the residuals must satisfy, where the growth laws come from, why \(\mathrm{E}(Y\mid x)\) is the best predictor, the complete proof of the independence and chi-squared facts of Appendix 11.A.1, the likelihood ratio behind the slope test, the exact width of the intervals and why a prediction interval never shrinks to zero, the bivariate normal density with its normalising constant, the maximum likelihood estimates of its five parameters, and why the test of \(\rho=0\) is the test of the slope) and correct a few rounding slips and one misprint of the printed text.
Course home Ch. 1 Introduction Ch. 2 Probability Ch. 3 Random variables Ch. 4 Special distributions Ch. 5 Estimation Ch. 6 Hypothesis testing Ch. 7 Normal-based inference Ch. 8 Types of data Ch. 9 Two-sample inference Ch. 10 Goodness of fit Ch. 11 Regression Ch. 12 Analysis of variance Ch. 13 Randomized blocks Ch. 14 Nonparametric statistics
Each Filling the gap box completes a step or a proof the book leaves out, and each selected question asks you to apply the chapter. Try it yourself first. When you are stuck, open Hint 1; the next hint unlocks one minute after you open the previous one, so take one hint at a time and think about it before moving on: the key idea first, then the tools, then the steps, with intermediate results to aim for. The full proof or solution appears after the last hint and unlocks two minutes later: use it to check your own argument. If you use a generative AI assistant, use it the same way: ask for a hint or for the next step only, then check what it says against these notes (why I teach this way). Spotted a mistake? Use the Report an error link at the end of each box: confirmed errors are corrected and listed, with thanks, in the errata.
They follow the book. Sections carry the book's numbers (11.1 to 11.6, with Appendix 11.A.1 placed inside Section 11.3 where Theorem 11.3.3 is stated) and numbered items keep theirs (Theorem 11.3.4, Case Study 11.2.1, Question 11.3.16). Everything is written in new words; the book is cited for each result, example and figure, and numbered equations keep their number, e.g. \((11.3.5)\).
Filling the gaps. Wherever the book says "it can be shown", leaves a step as a "why?", gives the proof of a theorem for one of its parts only ("the results for \(\hat\beta_0\) follow similarly"), states a test without proof or defers to an appendix, an orange Filling the gap box gives the full argument. Proofs and derivations start hidden: open one with its bar, or use the button below. Each gap box and each selected question offers graded hints, one at a time, before the full proof or solution.
Figures and demonstrations. Fifteen figures of the chapter (11.2.1 to 11.2.6, 11.2.8, 11.2.10 to 11.2.12, 11.3.1, 11.3.3 to 11.3.5 and 11.4.1) are reproduced; three own figures (x11.1 to x11.3) show four ways in which \(r\) misleads, regression towards the mean, and how the placement of the \(x\) values controls the precision of the slope. The sketches of the shapes of the exponential and power curves (Figures 11.2.7 and 11.2.9), the schematic of the simple linear model (Figure 11.3.2) and the sketch of a curved scatter plot (Figure 11.6.1) are not redrawn. All are computed by the Python code. The ▶ Demo boxes open an interactive demonstration already set to the case being discussed: two are new for this chapter and three graduate and applied-course demonstrations are reused.
R. J. Larsen and M. L. Marx, An Introduction to Mathematical Statistics and Its Applications, 6th edition, Pearson (2018), Chapter 11, pages 520–579. Section, case-study, figure, equation and question numbers below refer to this book. Further reading is listed in the references.
The explanations, derivations, figures and code are my own; equations are cited by their numbers in the book.
Regression is also developed, at other levels and in other words, in the companion courses of this site. Where a proof there is complete, these notes give the statement and a short sketch and link to it rather than repeating it.
Earlier chapters of this course: sums and covariances of random variables (Section 3.9), linear combinations of normal variables (Theorem 4.3.3), maximum likelihood (Definition 5.2.1), the generalized likelihood ratio (Definition 6.5.1), and, above all, the normal-sample theorem, Fisher's lemma and the \(t\), \(\chi^2\) and \(F\) laws of Section 7.3 (Theorem 7.3.2, Filling the gap 7.4, Definition 7.3.3). The regression theorems of this chapter are the same theorems with a straight line in place of a single mean and \(n-2\) degrees of freedom in place of \(n-1\).
New here: why the least squares line is the unique minimiser (Filling the gap 11.1) and what its residuals must satisfy (11.2), the growth laws behind the three curved models and what fitting on a transformed scale actually does (11.3, 11.4), why the regression curve is the best predictor (11.5), the maximum likelihood estimates in full (11.6), the intercept and the covariance of the estimates (11.7), the identities for the residual sum of squares (11.8) and Appendix 11.A.1 in full (11.9), the slope test as a likelihood ratio test (11.10), the intercept and variance intervals (11.11), the average-response and prediction intervals with their widths (11.12 to 11.14), two slopes (11.15), correlation (11.16, 11.17), the bivariate normal law and the exact test of independence (11.18 to 11.22) and how not to read \(r\) (11.23).
Notation. For data \((x_i,y_i)\), \(i=1,\dots,n\): \(\bar x,\bar y\) are the means, \(S_{xx}=\sum(x_i-\bar x)^2\), \(S_{yy}=\sum(y_i-\bar y)^2\), \(S_{xy}=\sum(x_i-\bar x)(y_i-\bar y)\). The book writes \(\hat\beta_0,\hat\beta_1\) in bold for the estimators (random variables) and plain for their values; here \(\hat\beta_0,\hat\beta_1\) are used for both and the context says which. The least squares slope is \(b=\hat\beta_1=S_{xy}/S_{xx}\), the fitted value \(\hat y_i=\hat\beta_0+\hat\beta_1x_i\), the residual \(e_i=y_i-\hat y_i\), the residual sum of squares \(\mathrm{SSE}=\sum e_i^2\) and \(S^2=\mathrm{SSE}/(n-2)\). \(t_{\alpha,\nu}\) is the number with \(\mathrm{P}(T_\nu\ge t_{\alpha,\nu})=\alpha\), \(\chi^2_{p,\nu}\) the \(p\)-quantile of \(\chi^2_\nu\).
Prerequisites. Chapter 7 (Section 7.3) for the \(t\), \(\chi^2\) and \(F\) laws and the normal-sample theorem, Chapter 6 for the generalized likelihood ratio, Chapter 5 for maximum likelihood, Chapter 4 for linear combinations of normal variables and Chapter 3 for covariance.
pp. 520–521 Experimenters constantly need to describe how the parts of a system relate to each other, because a relationship that is understood can be predicted and perhaps controlled: how smoking, diet and pollution together drive a disease, how market indices move a stock price. Real systems involve many variables, but most of the ideas can be seen with two, and the whole chapter is about two. It moves through four levels of probabilistic structure. In Section 11.2 the pairs \((x_i,y_i)\) are just points in a plane and the question is geometric: which line, or which curve, lies closest to them? In Section 11.3 each \(y_i\) becomes the value of a random variable \(Y_i\) whose mean depends on a fixed \(x_i\), which makes inference possible. Section 11.4 lets both coordinates be random and measures their dependence by the correlation coefficient, and Section 11.5 specialises to the bivariate normal law. The closing section is about misreading the correlation coefficient.
See also (companion courses): Section 13.1 of the graduate course for simple regression with random or fixed predictors; Section 3.1 of the applied course.
pp. 520–521 Given \(n\) points \((x_1,y_1),\dots,(x_n,y_n)\), which polynomial \(p(x)=a+\sum_{j=1}^mb_jx^j\) of degree \(m\) lies closest? "Closest" is defined by the total squared vertical distance \[ L=\sum_{i=1}^n\big[y_i-p(x_i)\big]^2, \] and the least squares polynomial is the one whose coefficients minimise \(L\). The case \(m=1\), a straight line \(y=a+bx\), is the one used throughout the chapter. (For a polynomial of any degree \(L\) is a quadratic function of the coefficients, so the minimiser solves a linear system, the normal equations, exactly as below; Question 11.2.19 asks for the system for \(y=a+bx+c\sin x\).) Squares are used, rather than absolute values, because they give a smooth \(L\) with a closed-form minimiser and, as Section 11.3 shows, because they are the maximum likelihood criterion when the errors are normal.
Given points \((x_1,y_1),\dots,(x_n,y_n)\) that do not all have the same \(x\), the line \(y=a+bx\) minimising \(L=\sum_{i=1}^n[y_i-(a+bx_i)]^2\) has slope and intercept \[ b=\frac{n\sum x_iy_i-\big(\sum x_i\big)\big(\sum y_i\big)}{n\sum x_i^2-\big(\sum x_i\big)^2}=\frac{S_{xy}}{S_{xx}},\qquad a=\frac{\sum y_i-b\sum x_i}{n}=\bar y-b\bar x. \]
The book proves this by setting the two partial derivatives to zero and solving by Cramer's rule. That shows the solution is the only stationary point; it does not show it is a minimum, and it assumes without saying so that \(n\sum x_i^2-(\sum x_i)^2\ne0\), that is, that the \(x_i\) are not all equal. The box below closes both gaps with a proof that needs no second derivatives.
Claim: if \(S_{xx}>0\), \(L(a,b)\) has exactly one minimiser, \(b=S_{xy}/S_{xx}\), \(a=\bar y-b\bar x\); the fitted line passes through \((\bar x,\bar y)\); the pair \((a,b)\) solves the normal equations of Question 11.2.12.
For any trial line, split the residual \(y_i-a-bx_i\) into a part that does not involve \(a\) and a constant. Which terms vanish when you square and sum, and what is left that depends on \(a\) alone?
Write \(y_i-a-bx_i=(y_i-\bar y)-b(x_i-\bar x)+d\) with \(d=\bar y-a-b\bar x\) and expand. Aim for: \(L=S_{yy}-2bS_{xy}+b^2S_{xx}+nd^2\).
Minimise over \(b\) (a quadratic with leading coefficient \(S_{xx}\)), then over \(a\) with \(b\) fixed. Aim for: \(b=S_{xy}/S_{xx}\) and \(a=\bar y-b\bar x\), unique when \(S_{xx}>0\).
Multiply top and bottom of \(S_{xy}/S_{xx}\) by \(n\) to match the book, evaluate the line at \(x=\bar x\), and say what happens if all the \(x_i\) are equal.
Completing the square. For any \(a,b\) write \(y_i-a-bx_i=(y_i-\bar y)-b(x_i-\bar x)+d\) with \(d=\bar y-a-b\bar x\), which is a constant not depending on \(i\). Squaring and summing, the cross terms \(2d\sum(y_i-\bar y)\) and \(-2db\sum(x_i-\bar x)\) vanish because deviations from a mean sum to zero, so \[ L(a,b)=\underbrace{\sum_i\big[(y_i-\bar y)-b(x_i-\bar x)\big]^2}_{=S_{yy}-2bS_{xy}+b^2S_{xx}}+\,n\,(\bar y-a-b\bar x)^2. \] The first term depends on \(b\) only. It is a quadratic polynomial in \(b\) with leading coefficient \(S_{xx}>0\), so it has a unique minimum at \(b=S_{xy}/S_{xx}\) (complete the square once more: \(S_{xx}(b-S_{xy}/S_{xx})^2+S_{yy}-S_{xy}^2/S_{xx}\)). The second term is \(\ge0\) and equals zero exactly when \(a=\bar y-b\bar x\). Hence \(L\) is smallest, and only, at \(b=S_{xy}/S_{xx}\) and \(a=\bar y-b\bar x\), and its minimum value is \(S_{yy}-S_{xy}^2/S_{xx}\). No assumption about \(a\), \(b\) or calculus is needed.
The book's form. Multiply numerator and denominator of \(S_{xy}/S_{xx}\) by \(n\): \(nS_{xy}=n\sum x_iy_i-\sum x_i\sum y_i\) and \(nS_{xx}=n\sum x_i^2-(\sum x_i)^2\). This is the printed formula, and the printed \(a=(\sum y_i-b\sum x_i)/n=\bar y-b\bar x\).
The normal equations. The partial derivatives are \(\partial L/\partial a=-2\sum(y_i-a-bx_i)\) and \(\partial L/\partial b=-2\sum x_i(y_i-a-bx_i)\); setting them to zero gives \[ na+\Big(\sum x_i\Big)b=\sum y_i,\qquad \Big(\sum x_i\Big)a+\Big(\sum x_i^2\Big)b=\sum x_iy_i,\] which is the matrix equation of Question 11.2.12. Its determinant is \(n\sum x_i^2-(\sum x_i)^2=nS_{xx}\), which is positive exactly when the \(x_i\) are not all equal, so the system has the unique solution above (Cramer's rule), and by the first paragraph that solution is a global minimum (the Hessian \(2\begin{pmatrix}n&\sum x_i\\\sum x_i&\sum x_i^2\end{pmatrix}\) is positive definite for the same reason).
Through the mean point. At \(x=\bar x\) the fitted value is \(a+b\bar x=\bar y-b\bar x+b\bar x=\bar y\) (Question 11.2.13). So the least squares line is determined by its slope and the requirement that it pass through the centre of the data.
All \(x_i\) equal. If \(x_i=x_0\) for every \(i\) then \(S_{xx}=0\), the second term above still forces \(a+bx_0=\bar y\), and \(L\) has the same minimum along that whole family of lines: every line through \((x_0,\bar y)\) is a least squares line. A slope cannot be estimated from data taken at a single \(x\), which is Question 11.3.4 seen from the other side (the less spread out the \(x_i\), the worse the slope is determined). ∎
See also (companion courses): Filling the gap 13.2 proves the same theorem in the graduate course; Section 11.2.2 of the machine-learning course derives it in matrix form; Section 3.2 of the statistical learning course shows that the fitted values are the orthogonal projection of \(y\) onto the span of the constant and \(x\).
A maker of air-conditioning units rejects too many connecting rods as overweight after the costly final tooling. To discard heavy castings early, the quality department wants the relationship between the finished weight \(y\) and the rough casting weight \(x\) (in ounces). Twenty-five pairs are measured (Table 11.2.1 of the book). The sums are \(\sum x_i=66.075\), \(\sum y_i=50.12\), \(\sum x_i^2=174.672925\), \(\sum x_i y_i=132.490725\) (and \(\sum y_i^2=100.49865\)), so by Theorem 11.2.1 \[ b=\frac{25(132.490725)-(66.075)(50.12)}{25(174.672925)-66.075^2}=0.642,\qquad a=\frac{50.12-0.642(66.075)}{25}=0.308, \] and the least squares line is \(\hat y=0.308+0.642\,x\) (Figure 11.2.1). A casting of \(2.71\) oz is predicted to finish at \(0.308+0.642(2.71)=2.05\) oz; if \(2.05\) oz is too heavy, castings of \(2.71\) oz or more should be discarded before tooling. The correlation is \(r=0.915\) and the residual standard deviation \(s=0.0113\) oz (Section 11.3), so the finished weight of a given casting is predictable only to within a few hundredths of an ounce.
fig_11_2_1.Let \(a\) and \(b\) be the least squares coefficients. For any \(x\), \(\hat y=a+bx\) is the predicted value. For each data point \(\hat y_i=a+bx_i\) and the \(i\)th residual is \(e_i=y_i-\hat y_i\). A graph of \(e_i\) against \(x_i\) is a residual plot.
A residual plot is the main diagnostic of this chapter. If a straight line describes the relationship, the residuals should look like scatter around zero with no trend, bend, change of spread or isolated point; if the relationship is curved, the residuals show it much more clearly than the original plot does, because the line has already removed the dominant trend and the eye can concentrate on what is left. Why the residual plot of a straight-line fit cannot contain a linear trend, whatever the data, is the content of the next box.
Claim: the least squares residuals satisfy \(\sum e_i=0\), \(\sum x_ie_i=0\) and \(\sum\hat y_ie_i=0\). Consequently their sample correlation with \(x\), and with \(\hat y\), is exactly zero. If the data come from the simple linear model of Section 11.3, \(\mathrm{Var}(e_i)=\sigma^2(1-h_i)\) with \(h_i=\frac1n+\frac{(x_i-\bar x)^2}{S_{xx}}\), so the residuals are not independent and do not even have equal variances, though they nearly do.
The least squares line makes the derivatives of \(L\) vanish. What do those two equations say about \(\sum e_i\) and \(\sum x_ie_i\), and what follows for \(\sum\hat y_ie_i\)?
Read the normal equations as \(\sum e_i=0\) and \(\sum x_ie_i=0\) and deduce \(\sum\hat y_ie_i=0\) and zero sample correlation with \(x\). Aim for: no linear trend can remain in a residual plot.
Show \(\hat y=Hy\) with that \(H\), and \(H^2=H\) using \(\sum c_j=0\), \(\sum c_j^2=S_{xx}\). Aim for: \(I-H\) is symmetric and idempotent.
Since \(H\mu=\mu\) for a line \(\mu\), \(e=(I-H)\varepsilon\). Take the covariance. Aim for: \(\mathrm{Var}(e_i)=\sigma^2(1-h_i)\) with \(h_i=\frac1n+\frac{(x_i-\bar x)^2}{S_{xx}}\).
Orthogonality. The normal equations of Filling the gap 11.1 read \(\sum(y_i-a-bx_i)=0\) and \(\sum x_i(y_i-a-bx_i)=0\), that is, \(\sum e_i=0\) and \(\sum x_ie_i=0\). Then \(\sum\hat y_ie_i=a\sum e_i+b\sum x_ie_i=0\). Since \(\bar e=0\), the sample covariance of \(e\) with \(x\) is \(\sum(x_i-\bar x)e_i=\sum x_ie_i-\bar x\sum e_i=0\), and likewise for \(\hat y\). In vector language \(e\) is orthogonal to the constant vector and to \(x\): it lies in an \((n-2)\)-dimensional subspace, which is the geometric origin of the \(n-2\) degrees of freedom of Section 11.3.
Consequence for the plot. A pattern in a residual plot cannot be a straight-line trend: the best straight line through the residuals is the horizontal line at zero. What can show are bends (residuals positive at both ends and negative in the middle, or the reverse), a funnel (the spread of the residuals changing with \(x\)), and one or a few points far from the rest. Case Studies 11.2.2 and 11.2.3 show a bend and an isolated point.
Variances. Write \(c_i=x_i-\bar x\). Then \(\hat y_i=\bar y+b(x_i-\bar x)=\sum_jH_{ij}y_j\) with \(H_{ij}=\frac1n+\frac{c_ic_j}{S_{xx}}\). \(H\) is symmetric and \(\sum_jH_{ij}H_{jk}=\frac1n+\frac{c_ic_k}{S_{xx}}=H_{ik}\) (the cross terms contain \(\sum_jc_j=0\), and \(\sum_jc_j^2=S_{xx}\)), so \(H^2=H\) and \(I-H\) is also symmetric and idempotent. In the model \(y=\mu+\varepsilon\) with \(\mu=\beta_0+\beta_1x\), \(H\mu=\mu\) (the fitted line reproduces any exact line), so \(e=(I-H)y=(I-H)\varepsilon\) and \(\mathrm{Cov}(e)=\sigma^2(I-H)(I-H)^{\mathsf T}=\sigma^2(I-H)\). The diagonal gives \(\mathrm{Var}(e_i)=\sigma^2(1-h_i)\) with \(h_i=H_{ii}\), the leverage of point \(i\); the off-diagonals \(-\sigma^2H_{ij}\) are not zero, so the residuals are correlated (slightly, for large \(n\)). The leverage is large for \(x_i\) far from \(\bar x\): the line is pulled towards such points, and their residuals are smaller than the others'. ∎
For the first rod, \((x_1,y_1)=(2.745,2.080)\), the prediction is \(\hat y_1=0.308+0.642(2.745)=2.070\) and the residual is \(0.010\). Repeating for all 25 rods gives residuals between \(-0.024\) and \(+0.024\) oz (Table 11.2.2 of the book). Plotted against \(x\) (Figure 11.2.2) they scatter randomly: no bend, no funnel, no point that stands apart. Nothing here casts doubt on the straight line.
fig_11_2_2.Social Security payouts rose from \(\$19.2\) billion in 1965 to \(\$529.9\) billion in 2005 (Table 11.2.3; \(x\) = years after 1965, nine points five years apart). The least squares line is \(\hat y=-38.0+12.9\,x\) (Figure 11.2.3). Was it reasonable to predict \(\$543\) billion for 2010 (\(x=45\))? No. The scatter plot looks close to a line (\(r=0.98\)), but the residuals (Figure 11.2.4) are +57, +7, −21, −31, −29, −31, −8, +3 and +53 billion dollars: positive at both ends and negative in the middle, a clear bend. The underlying curve is convex, and the true 2010 figure, \(\$713\) billion, was far above the line. A decisive lesson: a high \(r\) is no guarantee that a line fits, and extrapolating a fitted line beyond the data is dangerous.
With the unrounded slope \(12.865\) the line gives \(\$540.9\) billion at \(x=45\); the book's \(543\) uses the rounded slope \(12.9\) (see Notes on the book).
fig_11_2_3.fig_11_2_4.A proposed laboratory procedure for recovering calcium oxide from solutions containing magnesium is criticised as too dependent on who performs it. It is run on ten samples of known CaO content (Table 11.2.4): nine by Chemist A and one, at \(x=31\) mg, by Chemist B. The scatter plot (Figure 11.2.5) shows a line through all ten points, \(\hat y=-0.2281+0.9948\,x\), seemingly perfect (\(r=0.99989\)). The residual plot (Figure 11.2.6) tells a different story: the residual of Chemist B is \(+0.49\) mg, three times larger than the largest of Chemist A's (\(-0.16\)) and of the opposite character to most of them. Refitting without Chemist B gives \(\hat y=-0.220+0.9919\,x\) with residual standard deviation \(0.095\), and that line predicts \(30.53\) for \(x=31\), against the \(31.1\) found by Chemist B. This does not prove that the procedure depends on the analyst (one sample cannot), but the residual plot has isolated exactly the observation that the critics' question is about, which the scatter plot did not.
fig_11_2_5.fig_11_2_6.See also (companion courses): Section 3.3.3 of the applied course on residual plots, outliers and high-leverage points; the leverage \(h_i\) of Filling the gap 11.2 is the quantity it calls the hat value.
pp. 531–541 Only a handful of curves are needed to describe most regression data, and the book treats three that can be turned into straight lines by transforming \(y\), or \(x\) and \(y\), so that Theorem 11.2.1 can be applied. Each comes from a statement about the growth rate \(\mathrm{d}y/\mathrm{d}x\):
Three more are in Table 11.2.9: \(y=1/(a+bx)\) (then \(1/y\) is linear in \(x\)), \(y=x/(a+bx)\) (\(1/y\) is linear in \(1/x\)) and \(y=1-e^{-x^b/a}\) (\(\ln\ln\frac1{1-y}\) is linear in \(\ln x\)); verifying these is Question 11.2.29 (solution below). After fitting the straight line to the transformed data, the coefficients must be transformed back (for the exponential, \(a=e^{\ln a}\)).
The book integrates the three growth equations in a line each. Claim: the positive solutions of the three differential equations are exactly the three families of curves, with the linearising transformation exact, and the logistic parameters are \(b=-kL\), \(a=-Lc\) in terms of the growth constant \(k\) and the integration constant \(c\).
Each growth law says something about \(\mathrm{d}y\) relative to a simple function of \(y\) and \(x\). Which change of variable (a logarithm, or partial fractions) turns each into \(\mathrm{d}u=\)constant\(\times\mathrm{d}v\)?
Exponential: divide \(y'=by\) by \(y\) and integrate. Aim for: \(\ln y=bx+c\), so \(y=ae^{bx}\), \(a=e^c\).
Power law: show \(\mathrm d\ln y=b\,\mathrm d\ln x\). Aim for: \(y=ax^b\), with \(b\) the elasticity, in any logarithm base.
Logistic: separate variables with the partial fractions and solve for the log odds. Aim for: \(\ln\frac{L-y}{y}=a+bx\) with \(b=-kL\), \(a=-Lc\); then solve for \(y\).
Exponential. For \(y>0\), \(\mathrm{d}y/\mathrm{d}x=by\) is \(\frac{\mathrm{d}}{\mathrm{d}x}\ln y=b\), so \(\ln y=bx+c\) and \(y=e^{c}e^{bx}=ae^{bx}\) with \(a=e^c>0\). Conversely \(y=ae^{bx}\) has \(y'=by\). So \(\ln y\) is linear in \(x\) with slope \(b\) (growth for \(b>0\), decay for \(b<0\)) and intercept \(\ln a=\ln y(0)\). A quantity that doubles every \(\tau\) units has \(e^{b\tau}=2\), \(\tau=\ln2/b\) (Case Study 11.2.4).
Power law. For \(x,y>0\), \(\mathrm{d}y/\mathrm{d}x=by/x\) says \(\frac{\mathrm{d}y}{y}=b\frac{\mathrm{d}x}{x}\), that is \(\mathrm{d}\ln y=b\,\mathrm{d}\ln x\), so \(\ln y=b\ln x+\ln a\) and \(y=ax^b\). The logarithm may be taken to any base (the book uses base 10): the slope \(b\) does not change and the intercept is \(\log a\) in that base. Interpretation: \(b\) is the elasticity, the percentage change in \(y\) per one percent change in \(x\); \(b<1\) means growth that slows (the ants), \(b>1\) growth that speeds up.
Logistic. For \(0<y<L\) use the partial fractions \(\frac1{y(L-y)}=\frac1L\big(\frac1y+\frac1{L-y}\big)\). Separating variables in \(y'=ky(L-y)\), \[ \frac1L\big[\ln y-\ln(L-y)\big]=kx+c\quad\Longrightarrow\quad \ln\frac{L-y}{y}=-L(kx+c)=a+bx,\qquad b=-kL,\ a=-Lc. \] Solving for \(y\) gives \(\frac{L-y}{y}=e^{a+bx}\), that is \(y=\dfrac{L}{1+e^{a+bx}}\) (equation 11.2.5). For growth towards a ceiling (\(k>0\)) the fitted \(b\) is negative, as in Case Study 11.2.6 (\(b=-11.4\)). The curve is S-shaped, steepest where \(y=L/2\), that is where \(a+bx=0\), at \(x=-a/b\): for the red shanks, \(2.595/11.425=0.23\) seconds. The ceiling \(L\) is not estimated by the straight-line fit: it must be supplied, and the book's advice is to read it off a plot. (If \(L\) is also unknown the model is nonlinear in \(L\) and must be fitted by numerical least squares.) The transformation also needs every \(y_i\) strictly between \(0\) and \(L\).
The other three laws of Table 11.2.9. They are verified in Question 11.2.29 (solution). ∎
Moore predicted in 1965 that the number of transistors on a chip would double every eighteen months. Table 11.2.5 lists seven Intel chips from the 8080 (1975, 4500 transistors) to the Pentium Pro (1995, 5.5 million). The scatter plot is the curved shape of \(y=ae^{bx}\) with \(b>0\), so regress \(\ln y\) on \(x\) (years after 1975). With \(\sum x_i=72\), \(\sum x_i^2=1078\), \(\sum\ln y_i=86.90093\) and \(\sum x_i\ln y_i=1009.51207\), Theorem 11.2.1 gives \(b=0.343\), \(\ln a=8.888\), \(a=7247.19\) and \[ \hat y=7247.19\,e^{0.343\,x}=7247.19\cdot2^{0.495\,x}\] (because \(e^{0.343}=2^{0.495}\)), so \(y\) doubles when \(0.495x=1\), after \(\ln 2/0.3428=2.02\) years: a little slower than Moore's 1.5 years (Figure 11.2.8). About the data. The Itanium 2 of 2003 (\(x=28\)) had \(220\) million transistors, twice what the fitted curve predicts (\(107.4\) million with the rounded exponent \(0.343\), \(106.9\) million with the unrounded \(0.3428\)). The fit on the log scale is tight (\(r^2=0.987\), residual standard deviation \(0.325\) on the \(\ln\) scale), but seven points and an extrapolation of eight years are a thin basis. An interval makes the comparison with Moore's figure concrete: the 95% interval for \(b\) from Theorem 11.3.6 applied to \(\ln y\) is \((0.297,0.388)\), so the doubling time is between \(\ln2/0.388=1.78\) and \(\ln2/0.297=2.33\) years, and 1.5 years is outside it.
fig_11_2_8.The book fits \(y=ae^{bx}\) by regressing \(\ln y\) on \(x\), and says nothing about how this differs from fitting \(a e^{bx}\) to \(y\) directly. Claim: (i) the transformed fit minimises \(\sum[\ln y_i-\ln\hat y_i]^2\), which is approximately \(\sum[(y_i-\hat y_i)/\hat y_i]^2\) (relative error), not \(\sum(y_i-\hat y_i)^2\); (ii) it is the maximum likelihood fit if \(Y=ae^{bx}\cdot e^{\varepsilon}\) with \(\varepsilon\sim\mathrm N(0,\tau^2)\), and then all the intervals of Section 11.3 apply on the log scale; (iii) the back-transformed curve estimates the median of \(Y\), not its mean, and the mean is \(e^{\tau^2/2}\) times larger; (iv) an interval for a new \(Y\) transforms exactly, an interval for the mean does not.
What quantity does a straight-line fit to \((x_i,\ln y_i)\) minimise, and what must the errors look like on the original scale for that to be the right thing to minimise?
Write the criterion in terms of \(\ln y_i-\ln\hat y_i\). Aim for: approximately a sum of squared relative errors, so small \(y\) values count as much as large ones.
Assume \(\ln Y=\alpha+\beta x+\varepsilon\), \(\varepsilon\sim\mathrm N(0,\tau^2)\). Find the median and the mean of \(Y\). Aim for: median \(e^{\alpha+\beta x}\), mean \(e^{\tau^2/2}\) times larger.
Exponentiate the endpoints of an interval for \(\ln Y_{\rm new}\) and say why the coverage is unchanged, and why an interval for the mean is not obtained this way.
(i) By Theorem 11.2.1 the fit chooses \((\alpha,\beta)=(\ln a,b)\) to minimise \(\sum(\ln y_i-\alpha-\beta x_i)^2=\sum[\ln y_i-\ln\hat y_i]^2\) where \(\hat y_i=e^{\alpha+\beta x_i}\). For a small relative error \(\delta_i=(y_i-\hat y_i)/\hat y_i\), \(\ln y_i-\ln\hat y_i=\ln(1+\delta_i)\approx\delta_i\). So a point with a small \(\hat y_i\) counts as much as one with a large \(\hat y_i\). On the transistor data, whose values run from \(4\,500\) to \(5\,500\,000\), a direct least squares fit would be decided by the last two chips alone; fitting on the log scale gives every chip a say.
(ii) If \(\ln Y_i=\alpha+\beta x_i+\varepsilon_i\) with iid \(\varepsilon_i\sim\mathrm N(0,\tau^2)\), the variables \(\ln Y_i\) satisfy the simple linear model, and Theorem 11.3.1 and everything after it apply to \((\alpha,\beta,\tau^2)\) and the data \((x_i,\ln y_i)\). The error is multiplicative: \(Y_i=ae^{bx_i}e^{\varepsilon_i}\), so the spread of \(Y\) is proportional to its level, which is the situation of data that span orders of magnitude.
(iii) \(\mathrm{P}(Y\le ae^{bx})=\mathrm{P}(\varepsilon\le0)=\tfrac12\), so \(ae^{bx}\) is the median of \(Y\) given \(x\). The mean of the lognormal variable \(e^{\varepsilon}\) is \(\mathrm{E}\,e^{\varepsilon}=e^{\tau^2/2}\) (the normal moment generating function at 1), so \(\mathrm{E}(Y\mid x)=ae^{bx}e^{\tau^2/2}\). For the transistors \(\hat\tau=0.325\) and \(e^{\hat\tau^2/2}=1.054\): the curve of Case Study 11.2.4 is about 5% below the estimated mean at every \(x\). For the ants, whose log\(_{10}\) residual standard deviation is \(0.30\), the factor in the original scale is \(e^{(0.30\ln10)^2/2}=1.27\).
(iv) The map \(t\mapsto e^t\) is increasing, so \(\mathrm{P}(\ell\le\ln Y_{\mathrm{new}}\le u)=\mathrm{P}(e^{\ell}\le Y_{\mathrm{new}}\le e^u)\): exponentiating the endpoints of the prediction interval for \(\ln Y_{\mathrm{new}}\) (Theorem 11.3.8) gives a prediction interval for \(Y_{\mathrm{new}}\) with the same coverage. The same holds for the confidence interval for the median \(e^{\alpha+\beta x}\). The interval for the mean needs the extra factor \(e^{\tau^2/2}\), which is estimated and therefore adds uncertainty. Finally, which scale is right is a modelling question, not a numerical one: on the raw scale a direct nonlinear least squares fit gives \(\hat y=22\,141e^{0.2756x}\) and a doubling time of \(2.51\) years, against \(2.02\) years from the log scale; the log-scale fit describes the early chips far better. ∎
Counting all ants in a colony is hard, counting the foragers is easy, and for the red wood ant the colony size \(y\) is modelled by \(y=ax^b\) in the number of foragers \(x\) (Table 11.2.7, 15 colonies, \(x\) from 45 to 64,512). The ranges are so large that the plot of \(y\) against \(x\) is unreadable; \(\log y\) against \(\log x\) (Figure 11.2.10) is a clean line. With \(\sum\log x_i=41.77441\), \(\sum\log y_i=52.79857\), \(\sum(\log x_i)^2=126.60450\) and \(\sum\log x_i\log y_i=156.03811\) the fit is \(b=0.876\) and \(\log a=1.08\), so \(\hat y=12.0\,x^{0.876}\). A colony with 2500 foragers is estimated at \(12.03\cdot2500^{0.876}\approx11\,400\) ants. Since \(b<1\) the colony grows less than proportionally to the foraging force: the ratio \(y/x\) in the table is large for small colonies and falls to about 2 to 3 for the largest. The unrounded fit is \(b=0.8764\), \(\log a=1.0790\), \(a=12.0\) and gives \(11\,406\); the book's \(1.08028\) comes from rounding \(b\) to \(0.876\) before computing the intercept. The residual standard deviation on the \(\log_{10}\) scale is \(0.30\), a factor of \(2\) in the colony size, so this is a rough guide.
fig_11_2_10.Photographs every \(0.04\) seconds of 38 attacks by sparrow hawks on flocks of red shanks give the average proportion airborne against time (Table 11.2.8, 15 times from \(0.04\) to \(0.60\) s). The scatter is S-shaped (Figure 11.2.11), as the logistic model predicts: only a few birds notice the hawk at first, then the alarm spreads and growth accelerates, then it slows as few birds remain on the ground. Take the ceiling \(L=1\) (the whole flock). Regressing \(\ln\frac{1-y}{y}\) on \(x\) gives \(b=-11.425\) and \(a=2.596\) (the book prints \(2.595\), from sums rounded to \(-15.91\) and \(-10.2096\); the unrounded sums are \(-15.895\) and \(-10.2049\)), so \[ \hat y=\frac1{1+e^{2.596-11.425\,x}} \] (Figure 11.2.12), which passes close to every point (the maximum difference is \(0.07\) at \(x=0.24\), where the data jump from \(0.38\) to \(0.61\)). About the data. Here the differential equation was predicted before looking at the data, which is why the logistic curve is more than a good fit. Usually the model is chosen because it fits, and the book rightly notes that an equation chosen that way says little about the mechanism.
fig_11_2_11.fig_11_2_12.See also (companion courses): Section 3.3.2 of the applied course (transformations and polynomial terms as extensions of the linear model).
pp. 543–544 Section 11.2 treated the points as mere points. It is more realistic to regard each \(y\) as the value of a random variable \(Y\): the first rod of Case Study 11.2.1 weighed \(2.745\) oz before and \(2.080\) oz after tooling, but a second casting of the same rough weight would not finish at exactly the same weight, because the tooling does not act identically each time. So to each \(x\) belongs a whole distribution of possible \(y\) values, with density \(f_{Y|x}(y)\).
Let \(f_{Y|x}(y)\) be the density of \(Y\) for a given \(x\) and \(\mathrm E(Y\mid x)\) its mean. The function \(y=\mathrm E(Y\mid x)\) is the regression curve of \(Y\) on \(x\).
Suppose that for each \(x\in[0,1]\), \(f_{Y|x}(y)=\dfrac{x+y}{x+\frac12}\), \(0\le y\le1\). It is a density because \(\int_0^1(x+y)\,\mathrm dy=x+\frac12\), and \[ \mathrm E(Y\mid x)=\int_0^1y\,\frac{x+y}{x+\frac12}\,\mathrm dy=\frac{\frac x2+\frac13}{x+\frac12}=\frac{3x+2}{6x+3},\qquad 0\le x\le1. \] The regression curve (Figure 11.3.1) decreases from \(\frac23\) at \(x=0\) through \(\frac7{12}\) at \(x=\frac12\) to \(\frac59\) at \(x=1\); the conditional densities are \(2y\), \(y+\frac12\) and \(\frac{2y+2}3\) at those three points. Its graph is curved, so a straight line is only an approximation here; the simple linear model below is the special case in which the curve is a line and the conditional densities are normal with a common spread.
fig_11_3_1.The book defines the regression curve as the conditional mean and moves on. Claim: if \(\mathrm E(Y^2)<\infty\), then \(g^*(x)=\mathrm E(Y\mid x)\) minimises the mean squared prediction error \(\mathrm E[(Y-g(X))^2]\) over all functions \(g\), the minimum being \(\mathrm E[\mathrm{Var}(Y\mid X)]\), and no other \(g\) attains it (except on a set of \(x\) of probability zero). So predicting \(Y\) from \(x\) as well as possible, in the mean-square sense, is estimating the regression curve.
Fix \(x\) and ask for the single number \(c\) that minimises \(\mathrm E[(Y-c)^2\mid x]\). Add and subtract the conditional mean inside the square.
For fixed \(x\) and constant \(c\), expand \((Y-m)+(m-c)\). Aim for: \(\mathrm E[(Y-c)^2\mid x]=\mathrm{Var}(Y\mid x)+(m-c)^2\).
Put \(c=g(x)\) and average over \(X\). Aim for: \(\mathrm E[(Y-g(X))^2]=\mathrm E[\mathrm{Var}(Y\mid X)]+\mathrm E[(m(X)-g(X))^2]\), minimised only by \(g=m\).
Fix \(x\) and a number \(c\). Write \(Y-c=(Y-m)+(m-c)\) with \(m=\mathrm E(Y\mid x)\). Squaring and taking the conditional expectation, the cross term is \(2(m-c)\mathrm E(Y-m\mid x)=0\), so \[ \mathrm E\big[(Y-c)^2\mid x\big]=\mathrm{Var}(Y\mid x)+(m-c)^2. \] This is smallest, and only, at \(c=m\). Now take \(c=g(x)\) and average over the distribution of \(X\) (the law of total expectation): \[ \mathrm E\big[(Y-g(X))^2\big]=\mathrm E\big[\mathrm{Var}(Y\mid X)\big]+\mathrm E\big[(\mathrm E(Y\mid X)-g(X))^2\big]\ \ge\ \mathrm E\big[\mathrm{Var}(Y\mid X)\big], \] with equality exactly when \(g(X)=\mathrm E(Y\mid X)\) with probability one. For Example 11.3.1 at \(x=\frac12\) the numbers \(c=\frac12,\frac{11}{20},\frac35\) give mean squared errors \(0.0833\), \(0.0775\) and \(0.0767\), all above the value \(0.0764=\mathrm{Var}(Y\mid\tfrac12)=\frac{11}{144}\) at \(c=\frac7{12}\) (the excess is exactly \((\frac7{12}-c)^2\)). In the simple linear model the regression curve is the line \(\beta_0+\beta_1x\), and \(\sigma^2\) is the unavoidable prediction error: no method, however clever, predicts \(Y\) with mean squared error below \(\sigma^2\) when the model is true. ∎
See also (companion courses): Filling the gap 13.1 proves this and the corresponding statement for the best linear predictor.
Pairs \((x_i,Y_i)\), \(i=1,\dots,n\), follow the simple linear model if the \(x_i\) are fixed numbers and (1) each \(Y_i\) is normal, (2) with the same standard deviation \(\sigma\), (3) with mean \(\mathrm E(Y_i)=\beta_0+\beta_1x_i\), and (4) \(Y_1,\dots,Y_n\) are independent. Equivalently \(Y_i=\beta_0+\beta_1x_i+\varepsilon_i\) with \(\varepsilon_1,\dots,\varepsilon_n\) iid \(\mathrm N(0,\sigma^2)\). There are three parameters, \(\beta_0\), \(\beta_1\) and \(\sigma^2\).
Because the model gives \(Y\) a probability law, the parameters can be estimated by maximum likelihood (the book remarks that maximum likelihood estimators are "preferable" because they are random variables with distributions that give tests and intervals; more precisely, for this model they coincide with the least squares estimates, and what the model adds is the probability law of \(Y\) from which their sampling distributions follow). The assumptions can be partly checked by the residual plots of Section 11.2: a bend means the means are not collinear (assumption 3), a funnel means the spread is not constant (2), and a pattern of runs in a time-ordered plot suggests dependence (4); normality (1) is checked with a normal quantile plot of the residuals. The book writes the sample as \((x_i,Y_i)\) to emphasise that the \(Y_i\) are random while the \(x_i\) are not.
For data from the simple linear model the maximum likelihood estimators are \[ \hat\beta_1=\frac{n\sum x_iY_i-\sum x_i\sum Y_i}{n\sum x_i^2-(\sum x_i)^2}=\frac{S_{xY}}{S_{xx}},\qquad\hat\beta_0=\bar Y-\hat\beta_1\bar x,\qquad\hat\sigma^2=\frac1n\sum_{i=1}^n(Y_i-\hat Y_i)^2,\] with \(\hat Y_i=\hat\beta_0+\hat\beta_1x_i\).
The book differentiates \(-2\ln L\) three times and solves. That locates the only stationary point. Claim: when the \(x_i\) are not all equal and \(\mathrm{SSE}>0\), the log-likelihood has a unique global maximum at the least squares line and \(\hat\sigma^2=\mathrm{SSE}/n\); the maximised log-likelihood is \(-\frac n2[\ln(2\pi\,\mathrm{SSE}/n)+1]\).
For each fixed \(\sigma^2\) the log-likelihood depends on \((\beta_0,\beta_1)\) only through \(L(\beta_0,\beta_1)\). Which pair maximises it, whatever \(\sigma^2\) is, and what is left to maximise?
Write \(\ell=-\frac n2\ln(2\pi\sigma^2)-L/(2\sigma^2)\) and argue that the maximum over \((\beta_0,\beta_1)\) is at the least squares pair for every \(\sigma^2\).
Differentiate the remaining function of \(\sigma^2\) and study the sign. Aim for: the derivative is positive below \(\mathrm{SSE}/n\) and negative above, so \(\hat\sigma^2=\mathrm{SSE}/n\) is the global maximum.
Compute \(\mathrm E\hat\sigma^2\) from the chi-squared law and explain why dividing by \(n-2\) gives an unbiased estimator.
The log-likelihood is \(\ell(\beta_0,\beta_1,\sigma^2)=-\frac n2\ln(2\pi\sigma^2)-\frac1{2\sigma^2}L(\beta_0,\beta_1)\) with \(L=\sum(y_i-\beta_0-\beta_1x_i)^2\). Step 1. For every fixed \(\sigma^2>0\), \(\ell\) is a decreasing function of \(L\), so it is largest where \(L\) is smallest, and by Filling the gap 11.1 that is at the unique least squares pair \((\hat\beta_0,\hat\beta_1)\), whatever \(\sigma^2\) is. So the first two likelihood equations have the least squares solution, and it is a global maximiser in \((\beta_0,\beta_1)\) for each \(\sigma^2\). Step 2. Substituting, the problem reduces to maximising \(\ell(\sigma^2)=-\frac n2\ln\sigma^2-\frac{\mathrm{SSE}}{2\sigma^2}\) (plus a constant) over \(\sigma^2>0\). Its derivative is \(\frac{1}{2\sigma^4}(\mathrm{SSE}-n\sigma^2)\), positive for \(\sigma^2<\mathrm{SSE}/n\) and negative beyond: \(\ell\) increases and then decreases, so \(\sigma^2=\mathrm{SSE}/n\) is the unique global maximiser. The maximised value is \(-\frac n2\ln(2\pi\,\mathrm{SSE}/n)-\frac n2\). (If \(\mathrm{SSE}=0\) the points are exactly on a line and the likelihood is unbounded as \(\sigma^2\to0\); for continuous data this has probability zero when \(n\ge3\).) Together the two steps prove that \((\hat\beta_0,\hat\beta_1,\mathrm{SSE}/n)\) is the unique maximum likelihood estimate.
Bias. By Theorem 11.3.3(b) below, \(n\hat\sigma^2/\sigma^2\sim\chi^2_{n-2}\), so \(\mathrm E\hat\sigma^2=\frac{n-2}n\sigma^2\): the maximum likelihood estimator is biased downwards, because two parameters were fitted to the same data (the residuals are shorter than the true errors). Dividing by \(n-2\) instead of \(n\) removes the bias (Corollary 11.3.1); the cost is a variance slightly larger than that of \(\hat\sigma^2\), the same trade-off as for \(S^2\) in Chapter 7. ∎
See also (companion courses): Filling the gap 13.3 (the maximisation in full, and when the factorisation of the likelihood is legitimate).
Under the simple linear model: (a) \(\hat\beta_0\) and \(\hat\beta_1\) are normal; (b) \(\mathrm E\hat\beta_0=\beta_0\) and \(\mathrm E\hat\beta_1=\beta_1\); (c) \(\mathrm{Var}(\hat\beta_1)=\dfrac{\sigma^2}{\sum(x_i-\bar x)^2}\); (d) \(\mathrm{Var}(\hat\beta_0)=\dfrac{\sigma^2\sum x_i^2}{n\sum(x_i-\bar x)^2}\), which equals \(\sigma^2\Big[\dfrac1n+\dfrac{\bar x^2}{\sum(x_i-\bar x)^2}\Big]\).
The book proves (a) to (c) for \(\hat\beta_1\), using the two expressions (11.3.1) and (11.3.2), \(\hat\beta_1=\sum(x_i-\bar x)Y_i\big/\sum(x_i-\bar x)^2\), and says the results for \(\hat\beta_0\) "follow similarly". The proof for \(\hat\beta_0\) is not quite the same: \(\hat\beta_0\) involves \(\bar Y\) and \(\hat\beta_1\) together, which are not obviously independent.
Claim: \(\mathrm{Cov}(\bar Y,\hat\beta_1)=0\), the vector \((\hat\beta_0,\hat\beta_1)\) is bivariate normal with the means and variances of Theorem 11.3.2, and \(\mathrm{Cov}(\hat\beta_0,\hat\beta_1)=-\sigma^2\bar x/S_{xx}\), so \(\mathrm{Corr}(\hat\beta_0,\hat\beta_1)=-\bar x/\sqrt{\sum x_i^2/n}\).
Write \(\hat\beta_0\) as a linear combination of the \(Y_i\) and find its covariance with \(\bar Y\) and \(\hat\beta_1\). Which of these is zero, and why does that make the variance of \(\hat\beta_0\) easy?
Show \(\hat\beta_0=\sum d_iY_i\) with \(d_i=\frac1n-\bar xc_i\) and get its mean. Aim for: \(\mathrm E\hat\beta_0=\beta_0\).
Compute \(\mathrm{Cov}(\bar Y,\hat\beta_1)\). Aim for: zero, hence independence.
Add the variances and use \(\sum x_i^2=S_{xx}+n\bar x^2\). Aim for: both forms of \(\mathrm{Var}(\hat\beta_0)\), and \(\mathrm{Cov}(\hat\beta_0,\hat\beta_1)=-\sigma^2\bar x/S_{xx}\).
Put \(c_i=(x_i-\bar x)/S_{xx}\), so that \(\hat\beta_1=\sum c_iY_i\) with \(\sum c_i=0\), \(\sum c_ix_i=1\) and \(\sum c_i^2=1/S_{xx}\) (the book's \(\sum(x_i-\bar x)^2=\sum x_i^2-n\bar x^2\) is used to see the last two). Then \[ \hat\beta_0=\bar Y-\hat\beta_1\bar x=\sum_i d_iY_i,\qquad d_i=\frac1n-\bar xc_i, \] a linear combination of the independent normal variables \(Y_i\), hence normal (Theorem 4.3.3), and jointly normal with \(\hat\beta_1\) (any linear combination of \(\hat\beta_0,\hat\beta_1\) is again a linear combination of the \(Y_i\)). Mean: \(\mathrm E\hat\beta_0=\mathrm E\bar Y-\bar x\,\mathrm E\hat\beta_1=(\beta_0+\beta_1\bar x)-\bar x\beta_1=\beta_0\). Independence of \(\bar Y\) and \(\hat\beta_1\): \(\mathrm{Cov}(\bar Y,\hat\beta_1)=\sum_i\frac1nc_i\,\mathrm{Var}(Y_i)=\frac{\sigma^2}n\sum c_i=0\), and jointly normal uncorrelated variables are independent. Variance: \(\mathrm{Var}(\hat\beta_0)=\mathrm{Var}(\bar Y)+\bar x^2\mathrm{Var}(\hat\beta_1)=\sigma^2\big(\frac1n+\frac{\bar x^2}{S_{xx}}\big)\), and since \(\sum x_i^2=S_{xx}+n\bar x^2\), \(\frac1n+\frac{\bar x^2}{S_{xx}}=\frac{S_{xx}+n\bar x^2}{nS_{xx}}=\frac{\sum x_i^2}{nS_{xx}}\), which is part (d) in both forms. Covariance: \(\mathrm{Cov}(\hat\beta_0,\hat\beta_1)=\mathrm{Cov}(\bar Y,\hat\beta_1)-\bar x\,\mathrm{Var}(\hat\beta_1)=-\sigma^2\bar x/S_{xx}\), and dividing by \(\sqrt{\mathrm{Var}(\hat\beta_0)\mathrm{Var}(\hat\beta_1)}=\sigma^2\sqrt{\sum x_i^2/n}/S_{xx}\) gives the correlation \(-\bar x/\sqrt{\sum x_i^2/n}\).
Consequences. The two estimates are uncorrelated (so, being jointly normal, independent) exactly when \(\bar x=0\); when \(\bar x\) is large compared with the spread of the \(x_i\) they are almost perfectly negatively correlated: a line that is too steep must have too low an intercept to pass through the middle of the data. For the design \(x=101,\dots,112\) the correlation is \(-0.9995\), while for \(x=1,\dots,12\) it is \(-0.88\) (the demo). Centring the predictor (using \(x_i-\bar x\)) makes the estimates independent and is the reason \(\mathrm{Var}(\hat\beta_0)\) is smallest, \(\sigma^2/n\), when \(\bar x=0\). Question 11.3.10 (\(\mathrm E\bar Y=\beta_0+\beta_1\bar x\)) is the first step above. ∎
fig_x11_3.pp. 548–549 The unbiased estimator of \(\sigma^2\) is \(S^2=\frac n{n-2}\hat\sigma^2=\frac1{n-2}\sum(Y_i-\hat\beta_0-\hat\beta_1x_i)^2\) (Corollary 11.3.1 below); software reports \(s\) rather than \(\hat\sigma\), and so do these notes. The residual sum of squares has three algebraically equal computing forms (11.3.3), (11.3.4), (11.3.5). The first is used in Appendix 11.A.1.
Let \(\mathrm{SST}=\sum(y_i-\bar y)^2=S_{yy}\), \(\mathrm{SSR}=\sum(\hat y_i-\bar y)^2\) and \(\mathrm{SSE}=\sum(y_i-\hat y_i)^2\). Claim: (i) \(\mathrm{SST}=\mathrm{SSE}+\mathrm{SSR}\); (ii) \(\mathrm{SSR}=\hat\beta_1^2S_{xx}=S_{xy}^2/S_{xx}\), hence \(\mathrm{SSE}=S_{yy}-\hat\beta_1^2S_{xx}\) (11.3.3) \(=S_{yy}-S_{xy}^2/S_{xx}\) (11.3.4); (iii) \(\mathrm{SSE}=\sum y_i^2-\hat\beta_0\sum y_i-\hat\beta_1\sum x_iy_i\) (11.3.5).
Split \(y_i-\bar y\) into the part the line explains and the residual. Why is the cross term zero?
Expand \(\sum(y_i-\bar y)^2\) with the split. Aim for: \(\mathrm{SST}=\mathrm{SSE}+\mathrm{SSR}\).
Evaluate \(\mathrm{SSR}\) with the line through \((\bar x,\bar y)\). Aim for: \(\mathrm{SSR}=\hat\beta_1^2S_{xx}=S_{xy}^2/S_{xx}\), giving (11.3.3) and (11.3.4).
For (11.3.5) write \(\sum e_i^2=\sum e_i(y_i-\hat\beta_0-\hat\beta_1x_i)\) and use the normal equations. Why is (11.3.5) numerically risky?
(i) Write \(y_i-\bar y=(y_i-\hat y_i)+(\hat y_i-\bar y)\). Squaring and summing, the cross term is \(2\sum e_i(\hat y_i-\bar y)=2\sum e_i\hat y_i-2\bar y\sum e_i=0\) by Filling the gap 11.2. Hence (i). (ii) \(\hat y_i-\bar y=\hat\beta_1(x_i-\bar x)\) (the line passes through \((\bar x,\bar y)\)), so \(\mathrm{SSR}=\hat\beta_1^2S_{xx}\) and \(\mathrm{SSE}=\mathrm{SST}-\mathrm{SSR}\); \(\hat\beta_1=S_{xy}/S_{xx}\) gives \(S_{xy}^2/S_{xx}\). (11.3.4) is the same statement with \(S_{xy}=\sum x_iy_i-\frac1n\sum x_i\sum y_i\) and \(S_{xx}=\sum x_i^2-\frac1n(\sum x_i)^2\), \(S_{yy}=\sum y_i^2-\frac1n(\sum y_i)^2\). (iii) Expand \(\sum e_i^2=\sum e_i(y_i-\hat\beta_0-\hat\beta_1x_i)=\sum e_iy_i-\hat\beta_0\sum e_i-\hat\beta_1\sum x_ie_i=\sum e_iy_i\) (normal equations), and \(\sum e_iy_i=\sum y_i^2-\hat\beta_0\sum y_i-\hat\beta_1\sum x_iy_i\).
A numerical warning. Formula (11.3.5) subtracts two large, nearly equal sums, and loses digits to rounding. In Case Study 11.3.2 (Camry prices) \(\sum y_i^2=1\,382\,678\,777\) while the result is \(\mathrm{SSE}=942\,645\): about three of the leading digits cancel, so a hand computation with the coefficients rounded to \(8188.67\) and \(748.41\) gives \(s^2=117\,583.5\) (\(s=342.90\)) while the exact value is \(117\,830.6\) (\(s=343.26\)): rounding the coefficients in the sixth significant digit moves \(\mathrm{SSE}\) by about \(2000\). (The book's printed \(117\,727.98\), \(s=343.11\), follows from neither, so it also contains an arithmetic slip.) Computing \(\sum e_i^2\) from the residuals, or using (11.3.3), is numerically safe. ∎
Under the simple linear model: (a) \(\hat\beta_1\), \(\bar Y\) and \(\hat\sigma^2\) are mutually independent; (b) \(n\hat\sigma^2/\sigma^2\) has a chi-squared distribution with \(n-2\) degrees of freedom. Corollary 11.3.1: \(S^2=\frac n{n-2}\hat\sigma^2\) is unbiased for \(\sigma^2\). Corollary 11.3.2: \(\hat Y=\hat\beta_0+\hat\beta_1x\) and \(\hat\sigma^2\) are independent.
This is the heart of the chapter: it is for the regression model what the normal-sample theorem (Theorem 7.3.2) is for a single normal sample. The book proves it in Appendix 11.A.1 by an orthogonal change of variables and Fisher's lemma, compressing several steps into one line each. Here is the whole argument.
Claim: with \(W_i=Y_i-\beta_0-\beta_1x_i\) and a suitable orthogonal matrix \(M\), the variables \(Z=MW\) are iid \(\mathrm N(0,\sigma^2)\) with \(Z_1=\sqrt{S_{xx}}(\hat\beta_1-\beta_1)\), \(Z_2=\sqrt n(\bar Y-\beta_0-\beta_1\bar x)\) and \(\mathrm{SSE}=Z_3^2+\dots+Z_n^2\). Theorem 11.3.3 and both corollaries follow.
Standardise the errors \(W_i=Y_i-\beta_0-\beta_1x_i\) and rotate them by an orthogonal matrix whose first two rows are the directions of \(x-\bar x\) and of the constant vector. What do the first two rotated coordinates become?
Build \(M\) and show \(Z_1=\sqrt{S_{xx}}(\hat\beta_1-\beta_1)\), \(Z_2=\sqrt n\,\bar W\). Aim for: \(Z_1,\dots,Z_n\) iid \(\mathrm N(0,\sigma^2)\) with \(\sum Z_i^2=\sum W_i^2\).
Write the residual as \((W_i-\bar W)-(\hat\beta_1-\beta_1)(x_i-\bar x)\) and square and sum. Aim for: \(\mathrm{SSE}=\sum(W_i-\bar W)^2-(\hat\beta_1-\beta_1)^2S_{xx}\).
Rewrite in terms of the \(Z_i\). Aim for: \(\mathrm{SSE}=Z_3^2+\dots+Z_n^2\), hence \(\chi^2_{n-2}\) and independence of \(\hat\beta_1\), \(\bar Y\), \(\hat\sigma^2\).
Derive the corollaries: the mean of a \(\chi^2_{n-2}\) gives \(\mathrm E S^2=\sigma^2\), and \(\hat Y=\bar Y+\hat\beta_1(x-\bar x)\) is a function of \(Z_1,Z_2\) only.
The errors. Under the model \(W_i=Y_i-\beta_0-\beta_1x_i=\varepsilon_i\) are iid \(\mathrm N(0,\sigma^2)\); they involve the unknown parameters, but they are only a device for the proof. Write \(\bar W=\bar Y-\beta_0-\beta_1\bar x\).
The orthogonal matrix. Let \(u_1=(x_i-\bar x)_i/\sqrt{S_{xx}}\) and \(u_2=(1/\sqrt n)_i\). Both are unit vectors and \(u_1^{\mathsf T}u_2=\sum(x_i-\bar x)/\sqrt{nS_{xx}}=0\), so they are orthonormal. Extend them to an orthonormal basis \(u_1,\dots,u_n\) of \(\mathbb R^n\) (Gram–Schmidt) and let \(M\) have rows \(u_1^{\mathsf T},\dots,u_n^{\mathsf T}\), so \(M^{\mathsf T}M=I\). Put \(Z=MW\). Fisher's lemma (Filling the gap 7.4): the density of \(W\) is \((2\pi\sigma^2)^{-n/2}\exp\{-|w|^2/2\sigma^2\}\), which depends on \(w\) only through \(|w|^2\); the map \(w\mapsto Mw\) preserves \(|w|^2\) and has Jacobian \(|\det M|=1\), so \(Z\) has the same density: \(Z_1,\dots,Z_n\) are iid \(\mathrm N(0,\sigma^2)\), and \(\sum Z_i^2=\sum W_i^2\).
Two coordinates. By the definition of the first two rows, \(Z_2=\sqrt n\,\bar W\) and \(Z_1=\sum(x_i-\bar x)W_i/\sqrt{S_{xx}}\). Since \(\sum(x_i-\bar x)(\beta_0+\beta_1x_i)=\beta_1S_{xx}\), we have \(\sum(x_i-\bar x)W_i=\sum(x_i-\bar x)Y_i-\beta_1S_{xx}=S_{xx}(\hat\beta_1-\beta_1)\), so \(Z_1=\sqrt{S_{xx}}(\hat\beta_1-\beta_1)\) (equation 11.A.1.1 of the book).
The residual sum of squares. \(Y_i-\bar Y=(W_i-\bar W)+\beta_1(x_i-\bar x)\), so the \(i\)th residual is \(Y_i-\bar Y-\hat\beta_1(x_i-\bar x)=(W_i-\bar W)-(\hat\beta_1-\beta_1)(x_i-\bar x)\). Squaring and summing, \[ \mathrm{SSE}=\sum(W_i-\bar W)^2-2(\hat\beta_1-\beta_1)\sum(x_i-\bar x)W_i+(\hat\beta_1-\beta_1)^2S_{xx}=\sum(W_i-\bar W)^2-(\hat\beta_1-\beta_1)^2S_{xx}, \] using \(\sum(x_i-\bar x)(W_i-\bar W)=\sum(x_i-\bar x)W_i=S_{xx}(\hat\beta_1-\beta_1)\). Now \(\sum(W_i-\bar W)^2=\sum W_i^2-n\bar W^2=\sum Z_i^2-Z_2^2\) and \((\hat\beta_1-\beta_1)^2S_{xx}=Z_1^2\), so \[ \mathrm{SSE}=\sum_{i=1}^nZ_i^2-Z_1^2-Z_2^2=\sum_{i=3}^nZ_i^2. \] This is the book's identity \(n\hat\sigma^2=\sum_{i=3}^nZ_i^2\).
Conclusions. (b): \(n\hat\sigma^2/\sigma^2=\sum_{i=3}^n(Z_i/\sigma)^2\) is a sum of \(n-2\) squares of independent standard normal variables, hence \(\chi^2_{n-2}\) (Theorem 7.3.1). (a): \(\hat\sigma^2\) is a function of \((Z_3,\dots,Z_n)\), \(\hat\beta_1\) of \(Z_1\) and \(\bar Y\) of \(Z_2\) (\(\bar Y=\beta_0+\beta_1\bar x+Z_2/\sqrt n\)), and these are disjoint sets of independent variables, so the three are mutually independent. Corollary 11.3.1: \(\mathrm E\,S^2=\frac{\sigma^2}{n-2}\mathrm E\big[\frac{n\hat\sigma^2}{\sigma^2}\big]=\frac{\sigma^2}{n-2}(n-2)=\sigma^2\) (a \(\chi^2_k\) variable has mean \(k\)). Corollary 11.3.2: \(\hat Y=\bar Y+\hat\beta_1(x-\bar x)\) is a function of \((\bar Y,\hat\beta_1)\), hence independent of \(\hat\sigma^2\); the same holds for \(\hat\beta_0=\bar Y-\hat\beta_1\bar x\).
Geometry. Writing \(e=y-\hat y\), the proof says that the residual vector, whose squared length is \(\mathrm{SSE}\), is the projection of the errors onto the \((n-2)\)-dimensional space orthogonal to the constant vector and to \(x\): each of the two fitted parameters uses up one dimension of the errors, which is where \(n-2\) comes from. ∎
See also (companion courses): the same argument for any number of predictors is in the graduate course (Section 13.5); the one-sample case is Filling the gap 7.4.
Under the simple linear model, \[ T_{n-2}=\frac{\hat\beta_1-\beta_1}{S\Big/\sqrt{\sum(x_i-\bar x)^2}}\] has a Student \(t\) distribution with \(n-2\) degrees of freedom.
The book's proof: \(Z=(\hat\beta_1-\beta_1)\sqrt{S_{xx}}/\sigma\) is standard normal (Theorem 11.3.2), \((n-2)S^2/\sigma^2\) is \(\chi^2_{n-2}\) and independent of \(Z\) (Theorem 11.3.3), so \(Z\big/\sqrt{\frac{(n-2)S^2/\sigma^2}{n-2}}\) is the stated ratio (Definition 7.3.3). The unknown \(\sigma\) cancels, which is why the ratio is a pivot.
Let \(t=\dfrac{\hat\beta_1-\beta_1'}{s/\sqrt{S_{xx}}}\). To test \(H_0\colon\beta_1=\beta_1'\) at level \(\alpha\): against \(H_1\colon\beta_1>\beta_1'\) reject if \(t\ge t_{\alpha,n-2}\); against \(H_1\colon\beta_1<\beta_1'\) reject if \(t\le-t_{\alpha,n-2}\); against \(H_1\colon\beta_1\ne\beta_1'\) reject if \(t\le-t_{\alpha/2,n-2}\) or \(t\ge t_{\alpha/2,n-2}\). These tests are generalized likelihood ratio tests.
The book omits the likelihood ratio proof ("along the lines of Appendix 7.A.4"). The test of \(\beta_1=0\) is the common special case: if it is rejected, the mean of \(Y\) changes with \(x\) (as far as a line can tell); if not, the data are compatible with no dependence.
Claim: the generalized likelihood ratio for \(H_0\colon\beta_1=\beta_1'\) is \(\lambda=\big[1+t^2/(n-2)\big]^{-n/2}\), a decreasing function of \(|t|\), so the likelihood ratio test is the two-sided \(t\) test of Theorem 11.3.5; and \(t^2=\mathrm{SSR}'/S^2\) is a ratio of mean squares, \(F_{1,n-2}\) under \(H_0\) when \(\beta_1'=0\).
Under both \(H_0\) and the unrestricted model the maximised likelihood has the form \((2\pi e\hat\sigma^2)^{-n/2}\). By how much does the sum of squares grow when you force the slope to be \(\beta_1'\)?
Put \(v_i=y_i-\beta_1'x_i\) and compute the restricted sum of squares. Aim for: \(\mathrm{SSE}+S_{xx}(\hat\beta_1-\beta_1')^2\).
Form \(\lambda=(\hat\sigma^2_\Omega/\hat\sigma^2_\omega)^{n/2}\) and express it with \(t^2\). Aim for: \(\lambda=[1+t^2/(n-2)]^{-n/2}\).
Argue that \(\lambda\le\lambda^*\) means \(|t|\ge c\) and fix \(c\) from the null law. Then set \(\beta_1'=0\) and identify \(t^2\) with \(\mathrm{SSR}/S^2\).
Over \(\Omega=\{(\beta_0,\beta_1,\sigma^2)\}\) the maximised likelihood is \((2\pi e\hat\sigma^2_\Omega)^{-n/2}\) with \(\hat\sigma^2_\Omega=\mathrm{SSE}/n\) (Filling the gap 11.6). Over \(\omega=\{\beta_1=\beta_1'\}\) put \(v_i=y_i-\beta_1'x_i\): then \(v_i\sim\mathrm N(\beta_0,\sigma^2)\) is a one-sample normal problem, the maximum over \(\beta_0\) is at \(\bar v\) and the maximised likelihood is \((2\pi e\hat\sigma^2_\omega)^{-n/2}\) with \[ n\hat\sigma^2_\omega=\sum(v_i-\bar v)^2=\sum\big[(y_i-\bar y)-\beta_1'(x_i-\bar x)\big]^2=S_{yy}-2\beta_1'S_{xy}+\beta_1'^2S_{xx}=\mathrm{SSE}+S_{xx}(\hat\beta_1-\beta_1')^2, \] where the last step uses \(S_{yy}=\mathrm{SSE}+\hat\beta_1^2S_{xx}\) and \(S_{xy}=\hat\beta_1S_{xx}\) (Filling the gap 11.8). The ratio is \[ \lambda=\Big(\frac{\hat\sigma^2_\Omega}{\hat\sigma^2_\omega}\Big)^{n/2}=\Big[\frac{\mathrm{SSE}}{\mathrm{SSE}+S_{xx}(\hat\beta_1-\beta_1')^2}\Big]^{n/2}=\Big[1+\frac{t^2}{n-2}\Big]^{-n/2},\qquad t^2=\frac{S_{xx}(\hat\beta_1-\beta_1')^2}{\mathrm{SSE}/(n-2)}. \] \(\lambda\) decreases as \(|t|\) increases, so \(\lambda\le\lambda^*\) is the same event as \(|t|\ge c\), and \(c\) is fixed by the level: under \(H_0\) the statistic is exactly \(t_{n-2}\) (Theorem 11.3.4), so \(c=t_{\alpha/2,n-2}\). For the one-sided alternative \(H_1\colon\beta_1>\beta_1'\) take \(\Omega=\{\beta_1\ge\beta_1'\}\): when \(\hat\beta_1\ge\beta_1'\) the constrained maximum is the unconstrained one and \(\lambda\) is the expression above, and when \(\hat\beta_1<\beta_1'\) the likelihood is largest on the boundary, so \(\lambda=1\); small \(\lambda\) therefore means large positive \(t\), and the test rejects when \(t\ge t_{\alpha,n-2}\). It is the one-sided argument of Filling the gap 9.3.
The \(F\) form. With \(\beta_1'=0\), \(S_{xx}\hat\beta_1^2=\mathrm{SSR}\) (Filling the gap 11.8), so \(t^2=\mathrm{SSR}/[\mathrm{SSE}/(n-2)]=\mathrm{SSR}/S^2\), the ratio of the variation explained by the line (one degree of freedom) to the residual mean square. A \(t_{n-2}\) variable squared is \(F_{1,n-2}\) (Chapter 7), so the \(t\) test of \(\beta_1=0\) is the \(F\) test of the line against the horizontal line; this is the simplest analysis of variance table, and it is the form that generalises to several predictors (Chapter 12). ∎
A \(100(1-\alpha)\%\) confidence interval for \(\beta_1\) is \[ \Big(\hat\beta_1-t_{\alpha/2,n-2}\frac{s}{\sqrt{S_{xx}}},\ \hat\beta_1+t_{\alpha/2,n-2}\frac{s}{\sqrt{S_{xx}}}\Big).\]
Proof (the book's): \(\mathrm P(-t_{\alpha/2,n-2}\le T_{n-2}\le t_{\alpha/2,n-2})=1-\alpha\) with \(T_{n-2}\) from Theorem 11.3.4; isolate \(\beta_1\). The interval contains the values \(\beta_1'\) that the two-sided test of Theorem 11.3.5 accepts (duality: Filling the gap 6.3).
Table 11.3.1 gives annual cigarette consumption per adult \(x\) and the death rate from coronary heart disease per 100,000 (ages 35 to 64) \(y\) for 21 countries, from the United States (3900, 256.9) to Norway (1090, 136.3). The sums are \(\sum x=45\,110\), \(\sum y=3042.2\), \(\sum x^2=109\,957\,100\), \(\sum y^2=529\,321.58\), \(\sum xy=7\,319\,602\). Then \(\hat\beta_1=0.0601\), \(\hat\beta_0=15.77\), \(S_{xx}=109\,957\,100-45\,110^2/21\), that is \(13\,056\,523.81\) (\(\sqrt{S_{xx}}=3613.38\)), \(s^2=2181.66\), \(s=46.71\). To test \(H_0\colon\beta_1=0\) against \(H_1\colon\beta_1>0\) at \(\alpha=0.05\): \[ t=\frac{0.0601-0}{46.71/3613.38}=4.65\ \ge\ t_{.05,19}=1.7291, \] so \(H_0\) is rejected (one-sided \(P=0.00009\)): national heart disease mortality rises with smoking. Each additional 1000 cigarettes per adult per year goes with about \(60\) more deaths per 100,000; the 95% interval for \(\beta_1\) is \((0.033,\ 0.087)\), that is \(33\) to \(87\) per 1000 cigarettes. The line explains \(r^2=53\%\) of the variation in mortality; the residual standard deviation is \(47\), a large share of the typical rate, so the countries scatter widely around the line (Figure 11.3.4). The book writes "\(H_0\colon\beta_1>0\)" for the alternative; this is a misprint for \(H_1\). This is an association between national averages, not evidence about what happens to an individual smoker (Section 11.6).
Table 11.3.2 lists the suggested retail price in 2016 of ten model years of the Camry, \(x\) = years after 2005. The line is \(\hat y=8188.67+748.41\,x\) (Figure 11.3.3): each model year newer costs about \(\$748\) more. With \(S_{xx}=82.5\) (\(\sqrt{S_{xx}}=9.083\)), \(s=343.26\), \(t_{.025,8}=2.3060\), the 95% interval for \(\beta_1\) is \(748.41\pm2.3060\cdot343.26/9.083\), that is \((661.3,\ 835.6)\) dollars per year (the book gets \((661.30,835.52)\) from a slightly inexact \(s=343.11\); see Filling the gap 11.8). About the data. A line fitted to ten years does not predict the 2015 model, priced at \(\$20\,879\) (the line gives \(\$15\,673\), and even the upper end of the interval for the slope gives \(\$16\,544\)): the retail value of a one-year-old car is not governed by the same law as the older cars.
fig_11_3_3.See also (companion courses): Section 3.1.2 of the applied course (the standard errors and the \(t\) test of the coefficients, with the Advertising data); Theorem 13.9 and Filling the gap 13.5 for the large-sample version that does not need normal errors.
pp. 554–555 The book states the intercept pivot (11.3.6), "inverts" it, and gives the \(\chi^2\) interval for \(\sigma^2\) and its test. The box shows where they come from.
Claim: \(T=\dfrac{\hat\beta_0-\beta_0}{S\sqrt{\sum x_i^2}\big/\sqrt{nS_{xx}}}\sim t_{n-2}\), giving the interval \(\hat\beta_0\pm t_{\alpha/2,n-2}S\sqrt{\sum x_i^2}/\sqrt{nS_{xx}}\) (which is the interval for \(\mathrm E(Y\mid x)\) of Theorem 11.3.7 at \(x=0\)); and \(\big(\frac{(n-2)s^2}{\chi^2_{1-\alpha/2,n-2}},\frac{(n-2)s^2}{\chi^2_{\alpha/2,n-2}}\big)\) is a \(100(1-\alpha)\%\) interval for \(\sigma^2\).
The intercept estimator is normal and independent of \(S^2\); the variance estimator is chi-squared. What does the same ratio-of-independent-pieces argument that worked for the slope give here?
Standardise \(\hat\beta_0\), divide by the root of \(\chi^2_{n-2}/(n-2)\), cancel \(\sigma\), and invert. Aim for: an interval \(\hat\beta_0\pm t\,s\sqrt{\sum x_i^2}/\sqrt{nS_{xx}}\).
Start from \(\mathrm P(\chi^2_{\alpha/2,n-2}\le(n-2)S^2/\sigma^2\le\chi^2_{1-\alpha/2,n-2})=1-\alpha\) and solve for \(\sigma^2\). Aim for: reversed inequalities, so the larger quantile gives the lower limit.
Check that the intercept interval is the interval for \(\mathrm E(Y\mid0)\) of Theorem 11.3.7, and say when it is an extrapolation.
Intercept. By Filling the gap 11.7, \(\hat\beta_0\sim\mathrm N\big(\beta_0,\sigma^2\sum x_i^2/(nS_{xx})\big)\), so \(Z=(\hat\beta_0-\beta_0)\sqrt{nS_{xx}}\big/(\sigma\sqrt{\sum x_i^2})\) is standard normal. By Filling the gap 11.9, \(\hat\beta_0\) is a function of \((\bar Y,\hat\beta_1)\) and so independent of \(S^2\), and \((n-2)S^2/\sigma^2\sim\chi^2_{n-2}\). Hence \(T=Z\big/\sqrt{[(n-2)S^2/\sigma^2]/(n-2)}\), in which \(\sigma\) cancels, is \(t_{n-2}\) (Definition 7.3.3), and inverting \(\mathrm P(|T|\le t_{\alpha/2,n-2})=1-\alpha\) gives the interval. At \(x=0\) the factor \(\frac1n+\frac{(0-\bar x)^2}{S_{xx}}=\frac{\sum x_i^2}{nS_{xx}}\) of Theorem 11.3.7 is the same as above, so the two intervals coincide. The intercept is the mean of \(Y\) at \(x=0\); if \(0\) is far outside the range of the \(x_i\) (the cigarette data start at \(1090\)) it is an extrapolation, and the interval, though valid, answers a question the data say little about. Question 11.3.11 (known \(\sigma\)) replaces \(S\) by \(\sigma\) and \(t\) by \(z\).
Variance. By Theorem 11.3.3(b), \((n-2)S^2/\sigma^2\sim\chi^2_{n-2}\), so \(\mathrm P\big(\chi^2_{\alpha/2,n-2}\le(n-2)S^2/\sigma^2\le\chi^2_{1-\alpha/2,n-2}\big)=1-\alpha\) with \(\chi^2_{p,\nu}\) the \(p\)-quantile; solving for \(\sigma^2\) reverses the inequalities and gives the stated interval, exactly as in Theorem 7.5.1 with \(n-1\) replaced by \(n-2\). The interval is not symmetric about \(s^2\) because the \(\chi^2\) law is skewed. To test \(H_0\colon\sigma^2=\sigma_0^2\) use \(\chi^2=(n-2)s^2/\sigma_0^2\), which is \(\chi^2_{n-2}\) under \(H_0\) (Theorem 7.5.2 with the new degrees of freedom): large values support \(\sigma^2>\sigma_0^2\), small ones \(\sigma^2<\sigma_0^2\). For the cigarette data (\(n=21\), \(s^2=2181.66\)) the 90% interval for \(\sigma^2\) is \((1375,\ 4097)\), so \(\sigma\) is between \(37\) and \(64\) (Question 11.3.14). ∎
pp. 556–558 A health official may want to know the typical CHD mortality in a country smoking \(x=4200\) cigarettes per adult. The natural estimator of \(\mathrm E(Y\mid x)=\beta_0+\beta_1x\) is the height of the fitted line, \(\hat Y=\hat\beta_0+\hat\beta_1x\), unbiased by Theorem 11.3.2 (\(\mathrm E\hat Y=\mathrm E\hat\beta_0+x\mathrm E\hat\beta_1=\beta_0+\beta_1x\)).
A \(100(1-\alpha)\%\) confidence interval for \(\mathrm E(Y\mid x)=\beta_0+\beta_1x\) is \((\hat y-w,\ \hat y+w)\) with \(\hat y=\hat\beta_0+\hat\beta_1x\) and \[ w=t_{\alpha/2,n-2}\cdot s\sqrt{\frac1n+\frac{(x-\bar x)^2}{\sum(x_i-\bar x)^2}}.\]
Claim: \(\mathrm{Var}(\hat Y)=\sigma^2\Big[\frac1n+\frac{(x-\bar x)^2}{S_{xx}}\Big]\), which equals \(\dfrac{\sigma^2\sum(x_i-x)^2}{nS_{xx}}\), and \(\big(\hat Y-(\beta_0+\beta_1x)\big)\big/\big(S\sqrt{\tfrac1n+\tfrac{(x-\bar x)^2}{S_{xx}}}\big)\sim t_{n-2}\).
Write \(\hat Y\) as \(\bar Y+\hat\beta_1(x-\bar x)\). Which two independent pieces does it contain, and what is each one's variance?
Compute \(\mathrm{Var}(\hat Y)\). Aim for: \(\sigma^2[\frac1n+\frac{(x-\bar x)^2}{S_{xx}}]\), and the form of Question 11.3.23.
Standardise, divide by the root of \(\chi^2_{n-2}/(n-2)\), cancel \(\sigma\). Aim for: a \(t_{n-2}\) pivot.
Invert it and describe how the half-width behaves in \(x\). Where is it smallest, and why does it grow far from \(\bar x\)?
Since \(\hat\beta_0=\bar Y-\hat\beta_1\bar x\), \(\hat Y=\bar Y+\hat\beta_1(x-\bar x)\). The variance of a sum is the sum of the variances when the terms are uncorrelated, and \(\bar Y\) and \(\hat\beta_1\) are independent (Filling the gap 11.7: this is the book's "(why?)"). Hence \(\mathrm{Var}(\hat Y)=\mathrm{Var}(\bar Y)+(x-\bar x)^2\mathrm{Var}(\hat\beta_1)=\sigma^2/n+(x-\bar x)^2\sigma^2/S_{xx}\). The second form (Question 11.3.23): \(\sum(x_i-x)^2=\sum(x_i-\bar x)^2+n(x-\bar x)^2=S_{xx}+n(x-\bar x)^2\) (the sum of squares about any point is the sum about the mean plus \(n\) times the squared distance), and dividing by \(nS_{xx}\) gives \(\frac1n+\frac{(x-\bar x)^2}{S_{xx}}\).
\(\hat Y\) is a linear combination of the \(Y_i\), hence normal, so \(Z=\big(\hat Y-(\beta_0+\beta_1x)\big)/\big(\sigma\sqrt{\frac1n+\frac{(x-\bar x)^2}{S_{xx}}}\big)\sim\mathrm N(0,1)\). By Corollary 11.3.2, \(\hat Y\) is independent of \(S^2\), and \((n-2)S^2/\sigma^2\sim\chi^2_{n-2}\), so the ratio \(Z\big/\sqrt{[(n-2)S^2/\sigma^2]/(n-2)}\), in which \(\sigma\) cancels, is \(t_{n-2}\) (Definition 7.3.3). Inverting \(\mathrm P(|T|\le t_{\alpha/2,n-2})=1-\alpha\) for \(\beta_0+\beta_1x\) gives Theorem 11.3.7.
Shape. The half-width \(w\) is smallest at \(x=\bar x\), where it is \(t\,s/\sqrt n\) (the error of estimating the height of the line at the centre of the data is the error of a sample mean), and grows like \(|x-\bar x|\) far from \(\bar x\) because the error in the slope is multiplied by the distance: the confidence band of Figure 11.3.4 is a hyperbola. For the cigarette data (\(\bar x=2148\)) the half-width at \(x=4200\) is \(59.5\), at \(x=\bar x\) it is \(2.093\cdot46.7/\sqrt{21}=21.3\). Extrapolating far beyond the data is therefore doubly unsafe: the interval is wider and it takes the model's linearity for granted where there are no data to support it. ∎
With \(n=21\), \(t_{.025,19}=2.0930\), \(\bar x=2148.095\), \(S_{xx}=13\,056\,523.81\), \(s=46.71\), \(\hat\beta_0=15.771\) and \(\hat\beta_1=0.06010\), the point estimate is \(\hat y=268.18\) and \[ w=2.0930(46.71)\sqrt{\frac1{21}+\frac{(4200-2148.095)^2}{13\,056\,523.81}}=59.47, \] so the 95% interval for \(\mathrm E(Y\mid4200)\) is \((208.71,\ 327.65)\) (the book gets \((208.71,327.66)\) from slightly rounded inputs). A country smoking this much is expected to have between about 209 and 328 CHD deaths per 100,000, on average.
fig_11_3_4.The book draws the interval of Theorem 11.3.7 at every \(x\) and calls the curve connecting the endpoints a "95% confidence band". Each interval separately has coverage 95%, but the probability that all of them cover at once is smaller. Claim (Working and Hotelling, 1929; not in the book): with probability \(1-\alpha\), simultaneously for all \(x\), \[ \big|\hat Y(x)-(\beta_0+\beta_1x)\big|\le\sqrt{2F_{\alpha;2,n-2}}\;S\sqrt{\frac1n+\frac{(x-\bar x)^2}{S_{xx}}},\] with \(F_{\alpha;2,n-2}\) the upper \(\alpha\) point of \(F_{2,n-2}\).
The pointwise band controls the error of the line at one \(x\). Which single random quantity controls the error of the whole line at once, and what is its law?
Write the error at \(x\) as \(a^{\mathsf T}\delta\) with \(a=(1,x)^{\mathsf T}\), \(\delta\) the vector of coefficient errors, and its variance as \(\sigma^2a^{\mathsf T}Va\).
Apply Cauchy–Schwarz. Aim for: \(\sup_x(a^{\mathsf T}\delta)^2/(a^{\mathsf T}Va)\le\delta^{\mathsf T}V^{-1}\delta\).
Find the law of \(\delta^{\mathsf T}V^{-1}\delta/(2S^2)\) and read off the constant. Aim for: \(\sqrt{2F_{\alpha;2,n-2}}\) in place of \(t_{\alpha/2,n-2}\).
Let \(\delta=(\hat\beta_0-\beta_0,\hat\beta_1-\beta_1)^{\mathsf T}\); by Filling the gaps 11.7 and 11.9, \(\delta\sim\mathrm N(0,\sigma^2V)\) with \(V\) the \(2\times2\) matrix of variances and covariances in units of \(\sigma^2\), positive definite when the \(x_i\) are not all equal, and \(\delta\) is independent of \(S^2\). For \(a=(1,x)^{\mathsf T}\), \(\hat Y(x)-(\beta_0+\beta_1x)=a^{\mathsf T}\delta\) and \(a^{\mathsf T}Va=\frac1n+\frac{(x-\bar x)^2}{S_{xx}}\) (Filling the gap 11.12). The Cauchy–Schwarz inequality in the inner product \(\langle u,v\rangle=u^{\mathsf T}V^{-1}v\) gives \((a^{\mathsf T}\delta)^2=\langle Va,\delta\rangle^2\le\langle Va,Va\rangle\langle\delta,\delta\rangle=(a^{\mathsf T}Va)(\delta^{\mathsf T}V^{-1}\delta)\), with equality for the \(a\) proportional to \(V^{-1}\delta\) (as \(x\) varies over \(\mathbb R\) the vectors \((1,x)\) are all directions except one, so the supremum over \(x\) is approached). Hence \[ \sup_x\frac{(a^{\mathsf T}\delta)^2}{a^{\mathsf T}Va}\le\delta^{\mathsf T}V^{-1}\delta, \] and the event "for all \(x\), \(|a^{\mathsf T}\delta|\le c\,S\sqrt{a^{\mathsf T}Va}\)" has probability at least \(\mathrm P(\delta^{\mathsf T}V^{-1}\delta\le c^2S^2)\), with equality in the supremum case. Now \(V^{-1/2}\delta/\sigma\) is a vector of two independent standard normals, so \(\delta^{\mathsf T}V^{-1}\delta/\sigma^2\sim\chi^2_2\), independent of \((n-2)S^2/\sigma^2\sim\chi^2_{n-2}\); therefore \(\delta^{\mathsf T}V^{-1}\delta/(2S^2)\sim F_{2,n-2}\). Taking \(c^2=2F_{\alpha;2,n-2}\) the probability is \(1-\alpha\). Price. The factor \(\sqrt{2F_{\alpha;2,n-2}}\) replaces \(t_{\alpha/2,n-2}\): for \(n=21\) and \(\alpha=0.05\) it is \(2.654\) instead of \(2.093\), a band 27% wider, and for large \(n\) it tends to \(\sqrt{\chi^2_{.95,2}}=2.448\) instead of 1.96. In a simulation of 100\,000 data sets with \(n=8\) the pointwise 95% band contained the true line at every \(x\) from \(-50\) to \(60\) only 87% of the time, the Working–Hotelling band 95%. Use the pointwise band to answer "what is the mean at this \(x\)?", and the wider band to describe where the whole regression line may lie. ∎
pp. 558–559 A health official may also want to predict the mortality that one particular country will experience, not the average over all countries with the same consumption. For a future observation \((x,Y)\) with \(Y\) independent of the \(n\) data, a prediction interval is a range that contains \(Y\) with a stated probability.
A \(100(1-\alpha)\%\) prediction interval for \(Y\) at \(x\) is \((\hat y-w,\ \hat y+w)\), where \[ w=t_{\alpha/2,n-2}\cdot s\sqrt{1+\frac1n+\frac{(x-\bar x)^2}{\sum(x_i-\bar x)^2}}\ \text{ and }\ \hat y=\hat\beta_0+\hat\beta_1x.\]
The book says "following exactly the same steps" as for Theorem 11.3.7. Claim: \(\mathrm P\big(|\hat Y-Y|\le w\big)=1-\alpha\) with \(w\) as above, where the probability is over both the data and the new observation. As \(n\to\infty\) the confidence interval for the mean shrinks to zero width but the prediction interval tends to \(\pm z_{\alpha/2}\sigma\).
The new observation is the line plus a fresh error. How does the extra error change the variance of \(\hat Y-Y\), and why can it never be averaged away?
Show \(\hat Y-Y\) is normal with mean \(0\) and variance \(\sigma^2[1+\frac1n+\frac{(x-\bar x)^2}{S_{xx}}]\), and independent of \(S^2\).
Divide by \(S\) times the root and invert. Aim for: Theorem 11.3.8.
Let \(n\to\infty\) in both half-widths. Aim for: the confidence interval shrinks to a point, the prediction interval tends to \(\pm z_{\alpha/2}\sigma\).
Let \(Y=\beta_0+\beta_1x+\varepsilon\) be the new observation with \(\varepsilon\sim\mathrm N(0,\sigma^2)\) independent of \(\varepsilon_1,\dots,\varepsilon_n\). Then \(\hat Y-Y=[\hat Y-(\beta_0+\beta_1x)]-\varepsilon\) is a difference of two independent normal variables (the first is a function of the data only), so it is normal with mean \(0\) and variance \(\sigma^2\big[\frac1n+\frac{(x-\bar x)^2}{S_{xx}}\big]+\sigma^2\) (Filling the gap 11.12). It is also independent of \(S^2\): \(\hat Y\) by Corollary 11.3.2 and \(\varepsilon\) because it is independent of the data. Hence \((\hat Y-Y)\big/\big(S\sqrt{1+\frac1n+\frac{(x-\bar x)^2}{S_{xx}}}\big)\sim t_{n-2}\) by Definition 7.3.3, and inverting gives the interval for \(Y\).
Interpretation. The 95% is an average over repeated pairs (data set, new observation). It is not the probability that a particular interval, computed from the data in hand, contains the next \(Y\): given the data, that probability is a normal probability \(\mathrm P(|\varepsilon-(\hat Y-\beta_0-\beta_1x)|\le w)\), which depends on how far \(\hat Y\) happens to be from the truth. The two intervals compared. The only change from Theorem 11.3.7 is the extra \(1\) under the root, the variance of the new \(\varepsilon\). It cannot be removed by more data: as \(n\to\infty\) with the \(x_i\) spread out, \(S\to\sigma\), \(\frac1n+\frac{(x-\bar x)^2}{S_{xx}}\to0\) and \(t_{\alpha/2,n-2}\to z_{\alpha/2}\), so the prediction interval tends to \(\hat y\pm z_{\alpha/2}\sigma\) while the confidence interval shrinks to a point. For the cigarette data at \(x=4200\) the half-widths are \(114.4\) and \(59.5\), the prediction interval being \(92\%\) wider (Example 11.3.3), and at \(x=\bar x\) they are \(100.1\) and \(21.3\), so near the middle of the data the prediction interval is almost five times wider. Normality matters. The confidence interval for a mean is approximately right for non-normal errors in large samples (central limit theorem), but the prediction interval inherits the shape of the error distribution: if the errors are skewed or heavy-tailed the interval has the wrong coverage however large \(n\) is (the graduate course, Filling the gap 13.6). ∎
At \(x=4200\), \(\hat y=268.18\) again, and \[ w=2.0930(46.71)\sqrt{1+\frac1{21}+\frac{(4200-2148.095)^2}{13\,056\,523.81}}=114.43, \] so the 95% prediction interval is \((153.75,\ 382.61)\) (book: \((153.76,382.61)\)): 92% wider than the interval for the mean. Roughly, a country with this consumption could have almost any rate between 154 and 383, which is as much as a conclusion as the scatter in Figure 11.3.4 allows. For public health planning the interval for the average is relevant when one asks about a policy applied to many countries and the prediction interval when one asks about a single country (Question 11.3.18).
pp. 560–562 Comparing two regression lines is the regression analogue of comparing two means (Chapter 9): is the rate at which \(y\) changes with \(x\) the same under two conditions? If the two data sets are independent, a two-sample \(t\) test applies.
Let \((x_i,Y_i)\), \(i=1,\dots,n\) and \((x_j^*,Y_j^*)\), \(j=1,\dots,m\) be independent sets of points, each satisfying the simple linear model with the same \(\sigma^2\) and slopes \(\beta_1,\beta_1^*\). (a) With \[ S=\sqrt{\dfrac{\sum_i[Y_i-(\hat\beta_0+\hat\beta_1x_i)]^2+\sum_j[Y_j^*-(\hat\beta_0^*+\hat\beta_1^*x_j^*)]^2}{n+m-4}}, \] \[ T=\frac{\hat\beta_1-\hat\beta_1^*-(\beta_1-\beta_1^*)}{S\sqrt{\frac1{\sum(x_i-\bar x)^2}+\frac1{\sum(x^*_j-\bar x^*)^2}}}\] has a Student \(t\) distribution with \(n+m-4\) degrees of freedom. (b) To test \(H_0\colon\beta_1=\beta_1^*\) against \(H_1\colon\beta_1\ne\beta_1^*\) at level \(\alpha\), reject if \(t\le-t_{\alpha/2,n+m-4}\) or \(t\ge t_{\alpha/2,n+m-4}\) (one-sided tests use \(t_{\alpha,n+m-4}\)).
Claim: \(T\sim t_{n+m-4}\) when the two variances are equal, and the likelihood ratio test of \(H_0\colon\beta_1=\beta_1^*\) is the two-sided \(t\) test.
Two independent regressions with a common \(\sigma^2\): how do the two residual sums of squares combine, and how do the two slopes combine into one \(t\) ratio?
Combine \(\hat\beta_1-\hat\beta_1^*\) and the pooled \(S^2\). Aim for: \(T\sim t_{n+m-4}\); explain the \(4\).
Minimise the sum of squares under a common slope \(b\) (centre each sample). Aim for: \(\tilde b=(S_{xy}+S_{xy}^*)/(S_{xx}+S_{xx}^*)\).
Show the excess over \(\mathrm{SSE}+\mathrm{SSE}^*\) is \((\hat\beta_1-\hat\beta_1^*)^2/(1/S_{xx}+1/S_{xx}^*)\) and write \(\lambda\) with \(t^2\). Aim for: \(\lambda=[1+t^2/(n+m-4)]^{-(n+m)/2}\).
The pivot. By Theorem 11.3.2, \(\hat\beta_1\sim\mathrm N(\beta_1,\sigma^2/S_{xx})\) and \(\hat\beta_1^*\sim\mathrm N(\beta_1^*,\sigma^2/S_{xx}^*)\), independent because the two data sets are, so \(\hat\beta_1-\hat\beta_1^*\sim\mathrm N\big(\beta_1-\beta_1^*,\sigma^2(\frac1{S_{xx}}+\frac1{S^*_{xx}})\big)\) and the standardised difference \(Z\) is \(\mathrm N(0,1)\). With \(\mathrm{SSE}\), \(\mathrm{SSE}^*\) the residual sums of squares of the two fits, \(\mathrm{SSE}/\sigma^2\sim\chi^2_{n-2}\) and \(\mathrm{SSE}^*/\sigma^2\sim\chi^2_{m-2}\) (Theorem 11.3.3), independent of each other, so \((\mathrm{SSE}+\mathrm{SSE}^*)/\sigma^2\sim\chi^2_{n+m-4}\) (sum of independent chi-squared variables, Theorem 4.6.4) and \(S^2=(\mathrm{SSE}+\mathrm{SSE}^*)/(n+m-4)\) is its mean square. Each \(\hat\beta_1\) is independent of its own \(\mathrm{SSE}\) (Theorem 11.3.3(a)) and of the other sample's, so \(Z\) is independent of \(S^2\) and \(T=Z\big/\sqrt{[(n+m-4)S^2/\sigma^2]/(n+m-4)}\sim t_{n+m-4}\). The degrees of freedom are \(n+m\) minus the four fitted parameters (two intercepts and two slopes) that the pooled variance uses up.
The likelihood ratio. The maximum over all parameters (two lines, one \(\sigma^2\)) is \((2\pi e\hat\sigma^2_\Omega)^{-(n+m)/2}\), \(\hat\sigma^2_\Omega=(\mathrm{SSE}+\mathrm{SSE}^*)/(n+m)\). Under \(H_0\) (a common slope \(b\), two intercepts) the sum of squares, after centring each sample at its own means, is \(\sum_i[(y_i-\bar y)-b(x_i-\bar x)]^2+\sum_j[(y^*_j-\bar y^*)-b(x^*_j-\bar x^*)]^2=S_{yy}+S^*_{yy}-2b(S_{xy}+S^*_{xy})+b^2(S_{xx}+S^*_{xx})\), minimised at \(\tilde b=(S_{xy}+S^*_{xy})/(S_{xx}+S^*_{xx})\) with minimum \(S_{yy}+S^*_{yy}-(S_{xy}+S^*_{xy})^2/(S_{xx}+S^*_{xx})\). Using \(\mathrm{SSE}=S_{yy}-S_{xy}^2/S_{xx}\) for each sample, the excess of the restricted over the unrestricted sum of squares is \[ \frac{S_{xy}^2}{S_{xx}}+\frac{S_{xy}^{*2}}{S^*_{xx}}-\frac{(S_{xy}+S^*_{xy})^2}{S_{xx}+S^*_{xx}}=S_{xx}\hat\beta_1^2+S^*_{xx}\hat\beta_1^{*2}-\frac{(S_{xx}\hat\beta_1+S^*_{xx}\hat\beta^*_1)^2}{S_{xx}+S^*_{xx}}=\frac{S_{xx}S^*_{xx}}{S_{xx}+S^*_{xx}}(\hat\beta_1-\hat\beta_1^*)^2=\frac{(\hat\beta_1-\hat\beta^*_1)^2}{\frac1{S_{xx}}+\frac1{S^*_{xx}}}. \] (The middle step is the identity \(pu^2+qv^2-\frac{(pu+qv)^2}{p+q}=\frac{pq}{p+q}(u-v)^2\).) Hence \(\lambda=\big[\frac{\mathrm{SSE}+\mathrm{SSE}^*}{\mathrm{SSE}+\mathrm{SSE}^*+(\hat\beta_1-\hat\beta_1^*)^2/(1/S_{xx}+1/S^*_{xx})}\big]^{(n+m)/2}=\big[1+\frac{t^2}{n+m-4}\big]^{-(n+m)/2}\), decreasing in \(|t|\), so the likelihood ratio test rejects for large \(|t|\), and the level fixes the cut-off at \(t_{\alpha/2,n+m-4}\). This is the same computation as the pooled two-sample test of Filling the gap 9.2.
Caveats. The pooled \(S\) assumes equal error variances in the two samples; if they differ a Welch-type correction is needed (Chapter 9), and the interpretation of "the slopes differ" also depends on the \(x\) ranges being comparable. Equal slopes with different intercepts is a different question (a shift, not a different rate). ∎
Two populations of Drosophila serrata, one cross-bred (Strain A) and one in-bred (Strain B), were kept in sealed containers with little food and space, and counted every hundred days (Table 11.3.3, six counts each at \(x=0,100,\dots,500\)). Growth is roughly linear in both (Figure 11.3.5): \(\hat y=145.3+0.742x\) for A and \(\hat y^*=131.3+0.452x^*\) for B. Is the larger slope of A significant? Test \(H_0\colon\beta_1=\beta_1^*\) against \(H_1\colon\beta_1>\beta_1^*\) at \(\alpha=0.05\), with \(\sum(x_i-\bar x)^2=175\,000\) for each strain, residual sums of squares \(5512.14\) and \(3960.14\), so \(s=\sqrt{(5512.14+3960.14)/8}=34.41\): \[ t=\frac{0.742-0.452}{34.41\sqrt{\frac1{175\,000}+\frac1{175\,000}}}=2.49\ \ge\ t_{.05,8}=1.8595 \] (the book prints \(2.50\), but its own inputs, which are exact here (the slopes are exactly \(0.742\) and \(0.452\)), give \(t=2.493\)). Reject: one-sided \(P=0.019\). The data support the view that the genetically mixed population grows faster. Note that both samples have \(n=6\) and the same \(x\) values, so the estimates of the slopes are equally precise; the test says nothing about the intercepts.
fig_11_3_5.p. 563 Section 11.2 treated the \((x_i,y_i)\) as plain numbers, and Section 11.3 treated the \(x_i\) as fixed and the \(Y_i\) as random. Here both coordinates are random variables: measurements \((X_i,Y_i)\) are called correlation data (for example, the height of a parent and of a child, both measured on randomly chosen families), while \((x_i,Y_i)\) are regression data. The covariance \(\mathrm{Cov}(X,Y)=\mathrm E(XY)-\mathrm EX\,\mathrm EY\) (Section 3.9) measures how \(X\) and \(Y\) vary together, but it carries the units of both variables. Dividing by the standard deviations removes the units and puts the result between \(-1\) and \(1\).
For random variables \(X\) and \(Y\) with positive finite variances, the correlation coefficient is \[ \rho(X,Y)=\frac{\mathrm{Cov}(X,Y)}{\sigma_X\sigma_Y}=\mathrm{Cov}(X^*,Y^*),\qquad X^*=\frac{X-\mu_X}{\sigma_X},\ Y^*=\frac{Y-\mu_Y}{\sigma_Y}.\]
For any two random variables \(X\) and \(Y\): (a) \(|\rho(X,Y)|\le1\); (b) \(|\rho(X,Y)|=1\) if and only if \(Y=aX+b\) for some constants \(a\ne0\) and \(b\) (except possibly on a set of probability zero).
The book proves (a), proves "only if" in (b) in a few words ("it readily follows that \(Y\) is a linear function of \(X\)") and leaves the converse as an exercise. All three need a few lines.
Claim: \(\rho=+1\) iff \(Y=aX+b\) with \(a>0\) and \(\rho=-1\) iff \(Y=aX+b\) with \(a<0\) (almost surely); \(\rho=0\) does not imply independence, nor even the absence of a (nonlinear) relationship.
Variances are never negative. Apply that to the standardised sum and difference of \(X\) and \(Y\), and then ask when a variance can be exactly zero.
Show \(|\rho|\le1\); if \(\rho=1\), \(\mathrm{Var}(X^*-Y^*)=0\). Aim for: \(Y\) is a line in \(X\) with slope \(\pm\sigma_Y/\sigma_X\).
Compute \(\rho\) for \(Y=aX+b\). Aim for: \(\rho=\mathrm{sign}(a)\); what if \(a=0\)?
Find a pair with \(\rho=0\) that is a function of one another, using a symmetric \(X\) and \(Y=X^2\).
Part (a). \(X^*\) and \(Y^*\) have mean \(0\) and variance \(1\), so \(0\le\mathrm{Var}(X^*\pm Y^*)=1\pm2\rho+1=2(1\pm\rho)\), which forces \(1+\rho\ge0\) and \(1-\rho\ge0\), that is \(|\rho|\le1\).
Only if. If \(\rho=1\) then \(\mathrm{Var}(X^*-Y^*)=0\). A random variable with zero variance equals its mean with probability one (Chebyshev's inequality, Theorem 5.7.1: \(\mathrm P(|W-\mathrm EW|\ge\epsilon)\le0\) for every \(\epsilon>0\)); and \(\mathrm E(X^*-Y^*)=0\), so \(X^*=Y^*\) with probability one, that is \(Y=\mu_Y+\frac{\sigma_Y}{\sigma_X}(X-\mu_X)\), a line of slope \(\sigma_Y/\sigma_X>0\). If \(\rho=-1\), \(\mathrm{Var}(X^*+Y^*)=0\), \(Y^*=-X^*\) and the slope is \(-\sigma_Y/\sigma_X<0\).
If (the exercise). Let \(Y=aX+b\) with \(a\ne0\). Then \(\mathrm{Cov}(X,Y)=a\sigma_X^2\) and \(\sigma_Y=|a|\sigma_X\), so \(\rho=a\sigma_X^2/(|a|\sigma_X^2)=\mathrm{sign}(a)\). (If \(a=0\), \(Y\) is constant, \(\sigma_Y=0\) and \(\rho\) is not defined.) The same two paragraphs prove the sample version: \(|r|\le1\), with equality exactly when all points \((x_i,y_i)\) lie on a line (apply them to the empirical distribution that puts mass \(1/n\) on each point).
Zero correlation. If \(X\) has a density symmetric about \(0\) and a finite third moment (for example \(X\sim\mathrm{Uniform}(-1,1)\) or \(\mathrm N(0,1)\)) and \(Y=X^2\), then \(\mathrm{Cov}(X,Y)=\mathrm EX^3-\mathrm EX\,\mathrm EX^2=0\), so \(\rho=0\), although \(Y\) is a function of \(X\). Correlation measures only linear association; independence implies \(\rho=0\), not conversely. (Only inside the bivariate normal family do they coincide, Filling the gap 11.19.) ∎
p. 565 Given \(n\) measurements \((X_i,Y_i)\) of unknown correlation, the natural estimate replaces each moment in \(\rho=\frac{\mathrm E(XY)-\mathrm EX\mathrm EY}{\sqrt{\mathrm{Var}X\,\mathrm{Var}Y}}\) by its sample version, giving the sample correlation coefficient (Pearson's product-moment correlation) \[ R=\frac{\frac1n\sum X_iY_i-\bar X\bar Y}{\sqrt{\frac1n\sum(X_i-\bar X)^2}\sqrt{\frac1n\sum(Y_i-\bar Y)^2}}=\frac{n\sum X_iY_i-\sum X_i\sum Y_i}{\sqrt{n\sum X_i^2-(\sum X_i)^2}\ \sqrt{n\sum Y_i^2-(\sum Y_i)^2}}.\tag{11.4.1, 11.4.2}\] Equivalently \(R=S_{xy}/\sqrt{S_{xx}S_{yy}}\). It is the maximum likelihood estimator of \(\rho\) for bivariate normal data (Theorem 11.5.2).
Claim: (i) the two forms of \(R\) are equal; (ii) \(r=\hat\beta_1\sqrt{S_{xx}/S_{yy}}\); (iii) \(r^2=\dfrac{\mathrm{SST}-\mathrm{SSE}}{\mathrm{SST}}=\dfrac{\mathrm{SSR}}{\mathrm{SST}}\); (iv) \(r^2\) is also the square of the correlation between \(y\) and the fitted values, and \(\hat\beta_1^{(y\text{ on }x)}\cdot\hat\beta_1^{(x\text{ on }y)}=r^2\).
Rewrite the correlation as the slope times a ratio of standard deviations, and the residual sum of squares as \(S_{yy}\) times something in \(r\).
Show the two forms of \(R\) agree and that \(r=\hat\beta_1\sqrt{S_{xx}/S_{yy}}\).
Substitute into the decomposition. Aim for: \(\mathrm{SSE}=S_{yy}(1-r^2)\), so \(r^2=\mathrm{SSR}/\mathrm{SST}\).
Show \(r^2=\mathrm{corr}(y,\hat y)^2\) and that the two regression slopes multiply to \(r^2\).
(i) (Question 11.4.8) \(\frac1n\sum(X_i-\bar X)^2=\frac1n\sum X_i^2-\bar X^2=\frac{n\sum X_i^2-(\sum X_i)^2}{n^2}\), and likewise for \(Y\); the numerator is \(\frac1n\sum X_iY_i-\bar X\bar Y=\frac{n\sum X_iY_i-\sum X_i\sum Y_i}{n^2}\). The common factor \(1/n^2\) cancels between numerator and denominator (each of the two square roots carries a factor \(1/n\)), giving the second form. (ii) (Question 11.4.9) \(r=\dfrac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}=\dfrac{S_{xy}}{S_{xx}}\sqrt{\dfrac{S_{xx}}{S_{yy}}}=\hat\beta_1\sqrt{S_{xx}/S_{yy}}=\hat\beta_1\,s_x/s_y\): \(r\) is the slope after measuring \(x\) and \(y\) in units of their own standard deviations; it has the sign of the slope. (iii) By (11.3.3) of Filling the gap 11.8, \(\mathrm{SSE}=S_{yy}-\hat\beta_1^2S_{xx}=S_{yy}(1-r^2)\) by (ii), so \(r^2=1-\mathrm{SSE}/S_{yy}=(S_{yy}-\mathrm{SSE})/S_{yy}\). The numerator is the part of the total variation \(S_{yy}\) of the \(y_i\) that the line accounts for (the "explained" sum of squares) and \(\mathrm{SSE}\) the part it leaves. So \(r^2\) is the proportion of the variation in \(y\) that the straight line with \(x\) accounts for (equation 11.4.3); the coefficient of determination. (iv) The fitted values \(\hat y_i-\bar y=\hat\beta_1(x_i-\bar x)\) have \(\sum(y_i-\bar y)(\hat y_i-\bar y)=\hat\beta_1S_{xy}\) and \(\sum(\hat y_i-\bar y)^2=\hat\beta_1^2S_{xx}\), so \(\mathrm{corr}(y,\hat y)^2=\hat\beta_1^2S_{xy}^2/(S_{yy}\hat\beta_1^2S_{xx})=r^2\). Regressing \(x\) on \(y\) has slope \(S_{xy}/S_{yy}\), and \((S_{xy}/S_{xx})(S_{xy}/S_{yy})=r^2\). Thus the two regression lines coincide only when \(r^2=1\), and the slope of one is not the reciprocal of the slope of the other unless the fit is perfect.
Reading \(r^2\). "36% of the variation in \(Y\) is explained by the linear regression with \(X\)" when \(r=0.6\) is a statement about sums of squares in this sample and for this line; it says nothing about causation (Section 11.6), and a curved relationship can have a high \(r^2\) (Case Study 11.2.2). The number depends on the range of the \(x_i\) as well as on the strength of the relationship (Filling the gap 11.23). ∎
Average SAT scores are often used to rank states, schools and districts, although the test was not designed to measure the quality of education, and one factor besides instruction is the participation rate, the percentage of eligible students who take it (Table 11.4.1; 50 states and the District of Columbia). Figure 11.4.1 shows a strong decline of the average score as participation rises: North Dakota (2% participation) scores 1816, Maryland (78%) 1468. The sums are \(\sum x=2099\), \(\sum y=81\,108\), \(\sum x^2=147\,507\), \(\sum y^2=129\,989\,648\), \(\sum xy=3\,112\,824\) and \[ r=\frac{51(3\,112\,824)-(2099)(81\,108)}{\sqrt{51(147\,507)-2099^2}\sqrt{51(129\,989\,648)-81\,108^2}}=-0.912,\qquad r^2=0.831. \] So about 83% of the variation in average score from state to state is linearly accounted for by the participation rate (the book gets \(0.832\) by squaring the rounded \(-0.912\)). The least squares line is \(\hat y=1742.1-3.687\,x\): every 10 points of extra participation goes with a fall of about 37 points in the average score, with residual standard deviation \(58.7\). About the data. Comparing raw state averages is largely meaningless: states in which only the top students take the test (small \(x\)) have high averages for that reason alone. A fairer comparison looks at the residuals \(y-\hat y\): a state with a large positive residual does better than its participation rate predicts.
fig_11_4_1.pp. 570–576 The normal law dominates one-variable inference, so the most frequently met joint density of two variables is a bivariate version of it. The book builds the density by asking for it to have standard normal marginals, and then adds location and scale. It starts from independent standard normal variables, whose joint density is \(\frac1{2\pi}e^{-\frac12(x^2+y^2)}\) (11.5.1), and replaces the exponent by a more general quadratic \(-\frac c2(x^2-2vxy+y^2)\), so the candidate density is \(Ke^{-\frac c2(x^2-2vxy+y^2)}\) (11.5.2). Completing the square, \(x^2-2vxy+y^2=(1-v^2)x^2+(y-vx)^2\), shows that the exponent is negative (the density can be normalised) only if \(|v|<1\). Integrating over \(y\) and then \(x\) gives the normalising constant \(K\), and the choice \(c=1/(1-v^2)\) produces standard normal marginals, hence (11.5.3)
\[ f_{X,Y}(x,y)=\frac1{2\pi\sqrt{1-v^2}}\exp\Big\{-\frac{x^2-2vxy+y^2}{2(1-v^2)}\Big\}=\frac{1}{2\pi\sqrt{1-v^2}}\,e^{-x^2/2}\,e^{-\frac{(y-vx)^2}{2(1-v^2)}}.\]
The printed (11.5.3) has \(e^{-x^2}\) in the last form; it should be \(e^{-x^2/2}\) (see Notes on the book). The next box does the construction in full, including the step the book marks "(why?)".
Claim: (a) \(\iint e^{-\frac c2(x^2-2vxy+y^2)}\mathrm dx\,\mathrm dy=\dfrac{2\pi}{c\sqrt{1-v^2}}\) for \(c>0\), \(|v|<1\), and the integral diverges if \(|v|\ge1\); (b) requiring standard normal marginals forces \(c=1/(1-v^2)\); (c) then \(X\sim\mathrm N(0,1)\), \(Y\mid X=x\sim\mathrm N(vx,1-v^2)\), \(Y\sim\mathrm N(0,1)\) and \(\mathrm E(XY)=v\); (d) the five-parameter density of Definition 11.5.1 follows by a change of scale.
Complete the square in \(x^2-2vxy+y^2\) so that the \(y\)-integral is that of a normal density with mean shifted to \(vx\). What does the result say about the constants \(K\) and \(c\)?
Integrate over \(y\), then \(x\). Aim for: \(\iint=2\pi/(c\sqrt{1-v^2})\) when \(|v|<1\), divergent otherwise.
Find the marginal of \(X\) for a general \(c\) and require variance \(1\). Aim for: \(c=1/(1-v^2)\) and the corrected form with \(e^{-x^2/2}\).
Divide by \(f_X\) to get \(Y\mid X=x\sim\mathrm N(vx,1-v^2)\) and evaluate \(\mathrm E(XY)\) (the step the book marks with a question mark). Aim for: \(v\).
Rescale to \(\mu_X,\sigma_X,\mu_Y,\sigma_Y\) with the Jacobian \(1/(\sigma_X\sigma_Y)\).
(a) With \(x^2-2vxy+y^2=(1-v^2)x^2+(y-vx)^2\), integrate first over \(y\): \(\int e^{-\frac c2(y-vx)^2}\mathrm dy=\sqrt{2\pi/c}\), whatever \(x\) is (the integral of a normal density, with the mean shifted to \(vx\)). Then \(\int e^{-\frac c2(1-v^2)x^2}\mathrm dx=\sqrt{2\pi/(c(1-v^2))}\), and the product is \(2\pi/(c\sqrt{1-v^2})\) as stated, so \(K=c\sqrt{1-v^2}/(2\pi)\). If \(|v|\ge1\) the quadratic form \(x^2-2vxy+y^2\) is not positive definite (for \(v=\pm1\) it vanishes along the line \(y=\pm x\), and for \(|v|>1\) it is negative along the lines \(y=(v\pm\sqrt{v^2-1})x\) and in between), the exponent does not tend to \(-\infty\) in every direction, and the integral diverges. (The boundary cases \(\rho=\pm1\) are the degenerate pairs with \(Y=\pm X\), Theorem 11.4.1, which have no density in the plane.)
(b) Integrating the density \(Ke^{-\frac c2(1-v^2)x^2}e^{-\frac c2(y-vx)^2}\) over \(y\) gives the marginal \(f_X(x)=K\sqrt{2\pi/c}\,e^{-\frac c2(1-v^2)x^2}\), a normal density with variance \(1/[c(1-v^2)]\). For this to be \(1\) we need \(c=1/(1-v^2)\); the book's "\(c\) can be any positive value" is true only if the marginal variance is allowed to differ from \(1\). With this \(c\), \(K=\frac1{2\pi\sqrt{1-v^2}}\) and the density is the displayed (11.5.3).
(c) Integrating over \(y\), \(f_X(x)=\frac{1}{2\pi\sqrt{1-v^2}}e^{-x^2/2}\sqrt{2\pi(1-v^2)}=\frac1{\sqrt{2\pi}}e^{-x^2/2}\). Because \(f_{X,Y}\) is symmetric in \(x\) and \(y\), \(Y\) is standard normal too. Dividing, \(f_{Y|x}(y)=\frac{f_{X,Y}(x,y)}{f_X(x)}=\frac1{\sqrt{2\pi(1-v^2)}}e^{-\frac{(y-vx)^2}{2(1-v^2)}}\): given \(X=x\), \(Y\) is normal with mean \(vx\) and variance \(1-v^2\). The "(why?)" of the book: \(\mathrm E(XY)=\int x\phi(x)\Big[\int yf_{Y|x}(y)\,\mathrm dy\Big]\mathrm dx=\int x\phi(x)(vx)\,\mathrm dx=v\int x^2\phi(x)\,\mathrm dx=v\), since the inner integral is the mean of \(f_{Y|x}\), namely \(vx\), and \(\int x^2\phi=\mathrm{Var}X=1\). With zero means and unit variances, \(\rho=\mathrm E(XY)=v\).
(d) Put \(X=\mu_X+\sigma_XX^*\), \(Y=\mu_Y+\sigma_YY^*\) with \((X^*,Y^*)\) standard with correlation \(\rho\). The map has Jacobian \(\sigma_X\sigma_Y\), so \(f_{X,Y}(x,y)=\frac1{\sigma_X\sigma_Y}f^*\big(\frac{x-\mu_X}{\sigma_X},\frac{y-\mu_Y}{\sigma_Y}\big)\), which is the density of Definition 11.5.1; the correlation is unchanged by changes of location and scale with positive scale factors (Question 11.4.5). ∎
Random variables \(X\) and \(Y\) have the bivariate normal distribution with parameters \(\mu_X,\sigma_X^2,\mu_Y,\sigma_Y^2,\rho\) (with \(\sigma_X,\sigma_Y>0\), \(|\rho|<1\)) if their joint density is \[ f_{X,Y}(x,y)=\frac{1}{2\pi\sigma_X\sigma_Y\sqrt{1-\rho^2}}\exp\Big\{-\frac1{2(1-\rho^2)}\Big[\frac{(x-\mu_X)^2}{\sigma_X^2}-2\rho\frac{(x-\mu_X)(y-\mu_Y)}{\sigma_X\sigma_Y}+\frac{(y-\mu_Y)^2}{\sigma_Y^2}\Big]\Big\}. \]
Comment (the book). For the bivariate normal density, \(\rho=0\) implies independence: the density then factors into the two normal marginals. This is false for general pairs (Filling the gap 11.16), and it can even fail for two normal variables that are not jointly bivariate normal (Filling the gap 11.19).
If \(X\) and \(Y\) have the bivariate normal density of Definition 11.5.1, then (a) \(X\sim\mathrm N(\mu_X,\sigma_X^2)\) and \(Y\sim\mathrm N(\mu_Y,\sigma_Y^2)\); (b) \(\rho\) is the correlation coefficient of \(X\) and \(Y\); (c) \(\mathrm E(Y\mid x)=\mu_Y+\rho\dfrac{\sigma_Y}{\sigma_X}(x-\mu_X)\); (d) \(\mathrm{Var}(Y\mid x)=(1-\rho^2)\sigma_Y^2\).
The book proves (c) and (d) for \(\mu_X=\mu_Y=0\), \(\sigma_X=\sigma_Y=1\) "the extension is straightforward". Galton, studying the heights of parents (\(X\)) and children (\(Y\)), conjectured from tables that the marginals are normal, that \(\mathrm E(Y\mid x)\) is linear and that \(\mathrm{Var}(Y\mid x)\) is constant; the theorem shows he was right on all three counts.
Claim: for general parameters, given \(X=x\), \(Y\sim\mathrm N\big(\mu_Y+\rho\frac{\sigma_Y}{\sigma_X}(x-\mu_X),(1-\rho^2)\sigma_Y^2\big)\). Hence the simple linear model of Section 11.3 holds conditionally on the \(x\)'s with \(\beta_1=\rho\sigma_Y/\sigma_X\), \(\beta_0=\mu_Y-\beta_1\mu_X\), \(\sigma^2=(1-\rho^2)\sigma_Y^2\); the regression of \(X\) on \(y\) is a different line; and a pair with normal marginals and \(\rho=0\) need not be independent.
Factor the density as \(f_X(x)\) times a normal density in \(y\) whose mean depends on \(x\) linearly. What are that mean and variance in the original units?
Write \(z_x,z_y\) and factor the density. Aim for: \(Y\mid x\sim\mathrm N\big(\mu_Y+\rho\frac{\sigma_Y}{\sigma_X}(x-\mu_X),(1-\rho^2)\sigma_Y^2\big)\).
Identify \(\beta_0,\beta_1,\sigma^2\) of the simple linear model and say why Section 11.3 applies conditionally on the \(x_i\).
Take \(\mu_X=\mu_Y\), \(\sigma_X=\sigma_Y\) to see regression towards the mean, and explain why the variance of \(Y\) does not shrink.
Build a counterexample to the claim that \(\rho=0\) implies independence, with normal marginals, using \(Y=SX\), \(S=\pm1\).
Write \(z_x=(x-\mu_X)/\sigma_X\), \(z_y=(y-\mu_Y)/\sigma_Y\). By the algebra of Filling the gap 11.18, \(z_x^2-2\rho z_xz_y+z_y^2=(1-\rho^2)z_x^2+(z_y-\rho z_x)^2\), so \[ f_{X,Y}(x,y)=\frac{1}{\sigma_X\sqrt{2\pi}}e^{-z_x^2/2}\cdot\frac{1}{\sigma_Y\sqrt{2\pi(1-\rho^2)}}\exp\Big\{-\frac{(z_y-\rho z_x)^2}{2(1-\rho^2)}\Big\}. \] The first factor is the \(\mathrm N(\mu_X,\sigma_X^2)\) density, and integrating the second over \(y\) gives \(1\) (it is a normal density in \(y\)): this is (a) for \(X\) (and for \(Y\) by symmetry). The ratio \(f_{X,Y}/f_X\) is the second factor: since \(z_y-\rho z_x=\frac{y-\mu_Y-\rho\sigma_Yz_x}{\sigma_Y}\), it is the normal density with mean \(\mu_Y+\rho\sigma_Yz_x=\mu_Y+\rho\frac{\sigma_Y}{\sigma_X}(x-\mu_X)\) and variance \((1-\rho^2)\sigma_Y^2\): this is (c) and (d). (b): \(\mathrm{E}(Z_XZ_Y)=\mathrm E\big[Z_X\,\mathrm E(Z_Y\mid Z_X)\big]=\mathrm E[Z_X\cdot\rho Z_X]=\rho\) for the standardised variables, which is the correlation.
The link with Section 11.3. The conditional mean is \(\beta_0+\beta_1x\) with the stated \(\beta_0,\beta_1\), the conditional variance does not depend on \(x\), and the conditional law is normal. So if the \(X_i\) are drawn at random and we condition on them, \((x_i,Y_i)\) is exactly the simple linear model, and every result of Section 11.3 (which holds for each fixed choice of the \(x_i\), with a \(t\) law that does not depend on them) holds for correlation data too. The slope of the regression of \(Y\) on \(x\) is \(\rho\sigma_Y/\sigma_X\) and the residual variance fraction is \(1-\rho^2\): \(\rho^2\) is the proportion of the variance of \(Y\) explained by \(X\) (the population version of \(r^2\), equation 11.4.3).
Regression towards the mean. Take \(\mu_X=\mu_Y=\mu\), \(\sigma_X=\sigma_Y=\sigma\): then \(\mathrm E(Y\mid x)-\mu=\rho(x-\mu)\). With \(0<\rho<1\) a parent who is \(2\sigma\) above average has children whose expected height is only \(2\rho\sigma\) above (for \(\rho=0.5\), one \(\sigma\)): children of tall parents are, on average, taller than average but closer to the mean than their parents; Galton called this "regression to mediocrity" and it gave regression its name. It is not a causal effect and does not mean the population is becoming less variable: \(\mathrm{Var}(Y)=\rho^2\sigma^2+(1-\rho^2)\sigma^2=\sigma^2\) (explained plus unexplained), the same as \(\mathrm{Var}(X)\), because the spread lost by the conditional means is regained by the scatter around them. And it is symmetric: by the same argument with \(X\) and \(Y\) exchanged, parents of tall children are on average closer to the mean than their children. The two regression lines, \(y=\mu+\rho(x-\mu)\) and \(x=\mu+\rho(y-\mu)\), differ, and in the \((x,y)\) plane the second has slope \(1/\rho\) (Figure x11.2; the product of the slopes of the two regressions is \(\rho^2\), as in Filling the gap 11.17).
Zero correlation without independence. Let \(X\sim\mathrm N(0,1)\) and \(S\) be \(\pm1\) with probability \(\frac12\) each, independent of \(X\), and \(Y=SX\). Then \(Y\sim\mathrm N(0,1)\) (given \(S\), \(Y=\pm X\) is standard normal), \(\mathrm{Cov}(X,Y)=\mathrm E(S)\mathrm E(X^2)=0\), but \(|Y|=|X|\), so \(X\) and \(Y\) are strongly dependent. They are not bivariate normal: the density of Definition 11.5.1 with \(\rho=0\) factorises, but this pair lives on the two lines \(y=\pm x\). So "\(\rho=0\) implies independence" requires joint normality, not only normal marginals. ∎
fig_x11_2.See also (companion courses): Filling the gap 14.8 and 14.9 prove the same conditional laws for the multivariate normal in matrix form.
For a random sample \((X_1,Y_1),\dots,(X_n,Y_n)\) from the bivariate normal density with all five parameters unknown, the maximum likelihood estimators of \(\mu_X,\mu_Y,\sigma_X^2,\sigma_Y^2,\rho\) are \(\bar X\), \(\bar Y\), \(\frac1n\sum(X_i-\bar X)^2\), \(\frac1n\sum(Y_i-\bar Y)^2\) and \(R\).
The book gives no proof ("details are left as an exercise"): setting the five partial derivatives of \(\ln L\) to zero gives a coupled system. There is a much shorter route that reuses Theorem 11.3.1.
Claim: the likelihood of a bivariate normal sample is maximised, uniquely, at \(\hat\mu_X=\bar x\), \(\hat\mu_Y=\bar y\), \(\hat\sigma_X^2=S_{xx}/n\), \(\hat\sigma_Y^2=S_{yy}/n\), \(\hat\rho=r\), provided the \(x_i\) are not all equal, the \(y_i\) are not all equal and \(|r|<1\).
Split the bivariate normal density into the density of \(X\) times the conditional density of \(Y\) given \(X\). Which parameters appear where, and is the new parametrisation one-to-one?
Write the new parameters \((\mu_X,\sigma_X^2,\beta_0,\beta_1,\tau^2)\) and the inverse map. Aim for: \(\sigma_Y^2=\tau^2+\beta_1^2\sigma_X^2\), \(\rho=\beta_1\sigma_X/\sigma_Y\).
Maximise the two parts of the log-likelihood separately.
Transform back. Aim for: \(\hat\sigma_Y^2=S_{yy}/n\) (use \(\mathrm{SSE}+\hat\beta_1^2S_{xx}=S_{yy}\)) and \(\hat\rho=r\).
Factorise. By Theorem 11.5.1, \(f_{X,Y}(x,y)=f_X(x)f_{Y|x}(y)\) with \(f_X\) the \(\mathrm N(\mu_X,\sigma_X^2)\) density and \(f_{Y|x}\) the \(\mathrm N(\beta_0+\beta_1x,\tau^2)\) density, where \(\beta_1=\rho\sigma_Y/\sigma_X\), \(\beta_0=\mu_Y-\beta_1\mu_X\), \(\tau^2=(1-\rho^2)\sigma_Y^2\). The map \((\mu_X,\sigma_X^2,\mu_Y,\sigma_Y^2,\rho)\mapsto(\mu_X,\sigma_X^2,\beta_0,\beta_1,\tau^2)\) is a bijection of \(\mathbb R\times(0,\infty)\times\mathbb R\times(0,\infty)\times(-1,1)\) onto \(\mathbb R\times(0,\infty)\times\mathbb R\times\mathbb R\times(0,\infty)\): the inverse is \(\mu_Y=\beta_0+\beta_1\mu_X\), \(\sigma_Y^2=\tau^2+\beta_1^2\sigma_X^2\), \(\rho=\beta_1\sigma_X/\sigma_Y\), and \(|\rho|<1\) because \(\rho^2=\beta_1^2\sigma_X^2/(\tau^2+\beta_1^2\sigma_X^2)<1\).
Separate. The log-likelihood is \(\sum\ln f_X(x_i)+\sum\ln f_{Y|x_i}(y_i)=\ell_1(\mu_X,\sigma_X^2)+\ell_2(\beta_0,\beta_1,\tau^2)\): the first term involves only the \(x_i\) and the first pair, the second is the log-likelihood of the simple linear model. They are maximised separately. \(\ell_1\) is the normal log-likelihood: \(\hat\mu_X=\bar x\), \(\hat\sigma_X^2=\frac1n\sum(x_i-\bar x)^2\) (Chapter 5). \(\ell_2\) is maximised by Theorem 11.3.1: \(\hat\beta_1=S_{xy}/S_{xx}\), \(\hat\beta_0=\bar y-\hat\beta_1\bar x\), \(\hat\tau^2=\mathrm{SSE}/n\) (the maximum is global by Filling the gap 11.6).
Transform back. The likelihood is the same function whichever parametrisation labels the densities, so a point that maximises it in one set of parameters, mapped by a bijection, maximises it in the other (invariance of maximum likelihood, Section 5.2); substitute: \(\hat\mu_Y=\hat\beta_0+\hat\beta_1\hat\mu_X=\bar y\); \(\hat\sigma_Y^2=\hat\tau^2+\hat\beta_1^2\hat\sigma_X^2=\frac{\mathrm{SSE}+\hat\beta_1^2S_{xx}}n=\frac{S_{yy}}n=\frac1n\sum(y_i-\bar y)^2\) by Filling the gap 11.8; and \(\hat\rho=\hat\beta_1\hat\sigma_X/\hat\sigma_Y=\hat\beta_1\sqrt{S_{xx}/S_{yy}}=r\) by Filling the gap 11.17. This is Theorem 11.5.2. In particular the maximum likelihood estimators of the variances divide by \(n\), not \(n-1\), and are biased (Chapter 5). ∎
Let \((X_1,Y_1),\dots,(X_n,Y_n)\) be a random sample from a bivariate normal distribution with sample correlation \(R\). If \(\rho=0\), the statistic \[ T_{n-2}=\frac{\sqrt{n-2}\,R}{\sqrt{1-R^2}} \] has a Student \(t\) distribution with \(n-2\) degrees of freedom. So \(H_0\colon\rho=0\) (equivalently, \(X\) and \(Y\) independent) is rejected against \(\rho\ne0\) at level \(\alpha\) when \(|t|\ge t_{\alpha/2,n-2}\).
The book gives no proof (it cites a reference). The proof is two lines once the pieces of Section 11.3 are in place.
Claim: \(\dfrac{\sqrt{n-2}\,R}{\sqrt{1-R^2}}\) equals the slope statistic \(\hat\beta_1\sqrt{S_{xx}}/S\) of Theorem 11.3.4 with \(\beta_1'=0\); and if \(\rho=0\) then conditionally on the \(X_i\) (not all equal) it has the \(t_{n-2}\) law, so it has that law unconditionally.
Show the statistic is the slope statistic \(\hat\beta_1\sqrt{S_{xx}}/S\) in disguise, then ask what \(Y\) looks like given the \(X_i\) when \(\rho=0\).
Do the algebra. Aim for: \(\hat\beta_1\sqrt{S_{xx}}/S=\sqrt{n-2}\,r/\sqrt{1-r^2}\).
Condition on \(X_1=x_1,\dots,X_n=x_n\). Aim for: the \(Y_i\) are iid normal, the simple linear model with \(\beta_1=0\), so \(T\sim t_{n-2}\) for every \(x\).
Conclude the unconditional law and list what the argument did and did not need (normality of \(Y\), not of \(X\)).
Algebra. By Filling the gap 11.17, \(\hat\beta_1\sqrt{S_{xx}}=r\sqrt{S_{yy}}\) and \(S^2=\mathrm{SSE}/(n-2)=S_{yy}(1-r^2)/(n-2)\). So \(\dfrac{\hat\beta_1\sqrt{S_{xx}}}{S}=\dfrac{r\sqrt{S_{yy}}\sqrt{n-2}}{\sqrt{S_{yy}(1-r^2)}}=\dfrac{\sqrt{n-2}\,r}{\sqrt{1-r^2}}\).
Distribution. If \(\rho=0\) the joint density factorises, so \(X\) and \(Y\) are independent and \(Y\sim\mathrm N(\mu_Y,\sigma_Y^2)\) whatever the value of \(X\). Condition on \(X_1=x_1,\dots,X_n=x_n\), an event of probability zero but with a well-defined conditional law, not all \(x_i\) equal (which has probability one). Then \(Y_1,\dots,Y_n\) are independent \(\mathrm N(\mu_Y,\sigma_Y^2)\): this is the simple linear model with \(\beta_0=\mu_Y\), \(\beta_1=0\), \(\sigma^2=\sigma_Y^2\). By Theorem 11.3.4 the slope statistic has the \(t_{n-2}\) law conditionally on every configuration of the \(x_i\). A conditional law that is the same for every value of the conditioning variable is also the unconditional law (average over the distribution of \(X_1,\dots,X_n\)), which proves the theorem. ∎
Consequences. (1) The test of \(\rho=0\) and the test of \(\beta_1=0\) give the same statistic and the same \(P\)-value in every data set, and \(t^2=(n-2)r^2/(1-r^2)\) is the \(F_{1,n-2}\) ratio of Filling the gap 11.10. (2) The null distribution depends on the normality of \(Y\) (given \(X\)) and not of \(X\): the test is exact whatever the distribution of \(X\) is, provided \(X\) and \(Y\) are independent and \(Y\) is normal. (3) Under \(H_1\) the law of \(R\) depends on \(\rho\) and is complicated, which is why Fisher's transformation is used for power and intervals (Filling the gap 11.22). (4) This is a test of linear association only (Filling the gap 11.16).
Table 11.5.1 lists the mean temperature \(x\) on twenty successive days in April and the average daily butterfat content \(y\) (percent) in the milk of ten cows. Does the temperature have a non-zero correlation with the butterfat? With \(\sum x=1082\), \(\sum y=93.5\), \(\sum x^2=60\,304\), \(\sum y^2=437.6406\), \(\sum xy=5044.5\), \(n=20\): \[ r=\frac{20(5044.5)-(1082)(93.5)}{\sqrt{20(60\,304)-1082^2}\sqrt{20(437.6406)-93.5^2}}=-0.453,\qquad t=\frac{\sqrt{18}(-0.453)}{\sqrt{1-0.453^2}}=-2.157. \] The critical values for a two-sided test at \(\alpha=0.05\) are \(\pm t_{.025,18}=\pm2.1009\), so \(H_0\) is rejected (\(P=0.045\)): temperature and butterfat are not independent. Colder days go with richer milk. At \(\alpha=0.01\) the critical value is \(2.8784\) and \(H_0\) is not rejected (Question 11.5.7): the evidence is modest. The slope of the line of butterfat on temperature is \(-0.0078\) percentage points per degree.
The book quotes Fisher: \(\frac12\ln\frac{1+R}{1-R}\) is asymptotically normal with mean \(\frac12\ln\frac{1+\rho}{1-\rho}\) and variance about \(1/(n-3)\). Claim: this follows from the delta method applied to \(R\), whose asymptotic variance \((1-\rho^2)^2/n\) depends on the unknown \(\rho\); the transformation removes that dependence; and it gives the interval \(\big(\tanh(z_r-c),\ \tanh(z_r+c)\big)\), \(z_r=\operatorname{artanh}r\), \(c=z_{\alpha/2}/\sqrt{n-3}\).
The asymptotic variance of \(R\) depends on \(\rho\). Which function \(g\) has \(g'(\rho)(1-\rho^2)=1\), so that the delta method removes the dependence?
Solve \(g'(\rho)=1/(1-\rho^2)\). Aim for: \(g=\operatorname{artanh}\), and \(\sqrt n(g(R)-g(\rho))\to\mathrm N(0,1)\).
Invert \(|\operatorname{artanh}R-\operatorname{artanh}\rho|\le z/\sqrt{n-3}\) with \(\tanh\) and compute the interval for Example 11.5.1.
Use the normal approximation to \(\operatorname{artanh}R\) to approximate the power of the test of \(\rho=0\).
Variance stabilisation. For bivariate normal data \(\sqrt n(R-\rho)\) is asymptotically \(\mathrm N(0,(1-\rho^2)^2)\) (the graduate course, Filling the gap 14.5, proves this by the delta method from the joint asymptotic normality of the sample moments). The asymptotic variance depends on \(\rho\), so an interval \(r\pm z\,(1-r^2)/\sqrt n\) is poor for small \(n\) and near \(\pm1\). Look for \(g\) with \(g'(\rho)\,(1-\rho^2)=1\): \(g'(\rho)=\frac1{1-\rho^2}=\frac12\big[\frac1{1+\rho}+\frac1{1-\rho}\big]\), so \(g(\rho)=\frac12\ln\frac{1+\rho}{1-\rho}=\operatorname{artanh}\rho\). By the delta method \(\sqrt n\big(g(R)-g(\rho)\big)\) is asymptotically \(\mathrm N\big(0,g'(\rho)^2(1-\rho^2)^2\big)=\mathrm N(0,1)\): the variance no longer depends on \(\rho\). Replacing \(n\) by \(n-3\) improves the approximation at moderate \(n\) (Filling the gap 14.7; the mean is \(g(\rho)+\frac{\rho}{2(n-1)}\) to the next order).
The interval. From \(\mathrm P\big(|\operatorname{artanh}R-\operatorname{artanh}\rho|\le z_{\alpha/2}/\sqrt{n-3}\big)\approx1-\alpha\), apply \(\tanh\) (increasing, so the inequalities are preserved) to get \(\rho\in(\tanh(z_r-c),\tanh(z_r+c))\). The endpoints always lie in \((-1,1)\), and the interval is asymmetric about \(r\), as it should be for a bounded parameter. For Example 11.5.1 (\(r=-0.453\), \(n=20\)): \(\operatorname{artanh}(-0.453)=-0.488\), \(c=1.96/\sqrt{17}=0.475\), and the 95% interval for \(\rho\) is \((\tanh(-0.963),\tanh(-0.013))=(-0.746,\ -0.013)\): just excluding \(0\), consistent with the \(t\) test's \(P=0.045\) (a 95% interval and a 5% test agree for the same reasons as in Filling the gap 6.3, although the two methods are not exactly dual). Power. Since \(\operatorname{artanh}R\) is approximately \(\mathrm N(\operatorname{artanh}\rho,1/(n-3))\), the power of the test of \(\rho=0\) against a given \(\rho\) is approximately \(\Phi\big(\operatorname{artanh}|\rho|\sqrt{n-3}-z_{\alpha/2}\big)\), which is the computation the book says is "much more difficult" with \(\sqrt{n-2}R/\sqrt{1-R^2}\). For \(\rho=0.5\) and \(n=20\) it is \(\Phi(0.549\cdot4.123-1.96)=\Phi(0.30)=0.62\). ∎
pp. 576–577 Of all the numbers that statisticians compute, the correlation coefficient is among the most misread. The book names two errors. The first is to infer causation from a large \(r\). Even \(r=\pm1\) does not say that \(X\) causes \(Y\) or \(Y\) causes \(X\): the relationship may be produced by a third, unmeasured variable. Bernard Shaw's observation that tall hats and umbrellas are associated with health and long life because both go with wealth, the \(-0.98\) correlation between the annual British birth rate and the annual American output of pig iron between 1875 and 1920, the correlation between the salaries of Massachusetts ministers and the price of rum in Havana, and between children's achievement and their distance from the Canadian border, are all of this kind. The second error is to forget that \(r\) measures only the strength of a linear relationship: for a curved relationship it is meaningless, and even a value near \(\pm1\) does not guarantee a line (Case Study 11.2.2: \(r=0.98\), curved residuals). The lesson of the book: always plot the data before computing, let alone interpreting, a correlation.
The next box turns each warning into a precise statement and adds two the book does not make: \(r\) depends on the range of \(x\) sampled, and a single point can create or destroy a correlation.
Claim: (a) in the linear model with independent errors, \(\rho^2=\beta_1^2\sigma_x^2/(\beta_1^2\sigma_x^2+\sigma^2)\), so \(\rho\) depends on the spread \(\sigma_x\) of the predictor, not only on the relationship; (b) a perfect nonlinear relationship can have \(\rho\) anywhere from \(0\) to nearly \(1\); (c) one point can move \(r\) from near zero to near \(1\); (d) a common cause produces a correlation between variables neither of which affects the other.
For each warning construct a small explicit example whose correlation you can compute: change the spread of \(x\), use a curve, add one far point, add a common cause.
Compute \(\rho^2\) in the linear model. Aim for: \(\beta_1^2\sigma_x^2/(\beta_1^2\sigma_x^2+\sigma^2)\), so it depends on \(\sigma_x\).
Find \(\rho\) for \(Y=X^2\) with \(X\) uniform on \((-1,1)\) and on \((0,1)\). Aim for: \(0\) and \(\sqrt{15}/4\).
Add a point \((M,M)\) to a cluster with zero sample correlation. Aim for: \(r=M^2(1-1/n)/(A+M^2(1-1/n))\to1\).
Take \(X=Z+U\), \(Y=Z+V\). Aim for: \(\rho=\frac12\) for unit variances while \(X\) has no effect on \(Y\).
(a) Let \(Y=\beta_0+\beta_1X+\varepsilon\) with \(\mathrm{Var}(X)=\sigma_x^2\) and \(\varepsilon\) independent of \(X\) with variance \(\sigma^2\). Then \(\mathrm{Cov}(X,Y)=\beta_1\sigma_x^2\) and \(\mathrm{Var}(Y)=\beta_1^2\sigma_x^2+\sigma^2\), so \(\rho^2=\dfrac{\beta_1^2\sigma_x^4}{\sigma_x^2(\beta_1^2\sigma_x^2+\sigma^2)}=\dfrac{\beta_1^2\sigma_x^2}{\beta_1^2\sigma_x^2+\sigma^2}\). The same line and the same noise give a large \(\rho\) when \(x\) varies a lot and a small one when it varies little: for \(\beta_1=0.8\), \(\sigma=2\), \(x\) uniform on \((0,10)\) (\(\sigma_x^2=8.33\)) \(\rho=0.76\); restricted to \(4<x<6\) (\(\sigma_x^2=\frac13\)) \(\rho=0.23\) (Figure x11.1d: \(0.73\) and \(0.31\) in a sample). The slope and \(\sigma\) are unchanged by choosing the range of \(x\); \(r\) is not a property of the relationship alone. A low \(r\) in a narrow range does not mean the variables are unrelated.
(b) For \(X\sim\mathrm{Uniform}(-1,1)\) and \(Y=X^2\), \(\rho=0\) (Filling the gap 11.16); for \(X\sim\mathrm{Uniform}(0,1)\) and the same \(Y=X^2\), \(\mathrm{Cov}=\mathrm EX^3-\mathrm EX\,\mathrm EX^2=\frac14-\frac12\cdot\frac13=\frac1{12}\), \(\mathrm{Var}X=\frac1{12}\), \(\mathrm{Var}X^2=\frac15-\frac19=\frac4{45}\), and \(\rho=\frac{1/12}{\sqrt{(1/12)(4/45)}}=\frac{\sqrt{15}}4=0.968\), although \(Y\) is an exact curve of \(X\) (Question 11.4.6 finds the same limit for \(X\) uniform on \(1,\dots,n\)). A monotone convex or concave relationship over a moderate range is well approximated by a line, so \(r\) is close to 1: this is the situation of Case Study 11.2.2 (\(r=0.98\)).
(c) Take \(n-1\) points with \(\sum x_i=\sum y_i=0\), \(\sum x_i^2=\sum y_i^2=A\) and \(\sum x_iy_i=0\) (sample correlation exactly \(0\)) and add one point \((M,M)\). The totals are \(\sum x=M\), \(\sum x^2=A+M^2\), \(\sum xy=M^2\), so \(S_{xx}=S_{yy}=A+M^2(1-\frac1n)\) and \(S_{xy}=M^2(1-\frac1n)\), hence \(r=\dfrac{M^2(1-1/n)}{A+M^2(1-1/n)}\to1\) as \(M\to\infty\). In Figure x11.1(c) thirty points with essentially no correlation (\(r=0.22\) without) become \(r=0.84\) with one point at \((9,9)\). The converse also holds: a lone point that goes against the trend can destroy a strong correlation. Always look.
(d) Let \(Z\), \(U\) and \(V\) be independent with variances \(\sigma_z^2,\sigma_u^2,\sigma_v^2\), and let \(X=Z+U\) and \(Y=Z+V\) (a common cause \(Z\), plus independent noise). Then \(\mathrm{Cov}(X,Y)=\sigma_z^2\) and \(\rho=\dfrac{\sigma_z^2}{\sqrt{(\sigma_z^2+\sigma_u^2)(\sigma_z^2+\sigma_v^2)}}\), which is \(\frac12\) when all three variances are \(1\). The regression of \(Y\) on \(x\) has slope \(\rho\sigma_Y/\sigma_X=\frac12\), and yet changing \(X\) by intervention (setting it to a value of our choosing, not letting \(Z\) determine it) would leave \(Y=Z+V\) unchanged: the slope reflects the information \(x\) carries about \(Z\), not an effect of \(x\) on \(y\). Conditioning is not intervening (the graduate course's demo), and adjusting for the common cause can even reverse the sign of an association (Simpson's paradox, adjusting for a confounder). ∎
fig_x11_1.See also (companion courses): Section 3.3.3 of the applied course (residual plots, outliers and high-leverage points, collinearity); the graduate course's Simpson's paradox and confounder adjustment demos for the causal reading of correlation.
The last form of (11.5.3) reads \(\frac1{2\pi\sqrt{1-v^2}}e^{-x^2}\cdot e^{-\frac12\frac1{1-v^2}(y-vx)^2}\). The first exponent should be \(-x^2/2\): from \(x^2-2vxy+y^2=(1-v^2)x^2+(y-vx)^2\) one gets \[ -\frac{1}{2(1-v^2)}\big[(1-v^2)x^2+(y-vx)^2\big]=-\frac{x^2}2-\frac{(y-vx)^2}{2(1-v^2)}, \] and the next line of the book, which integrates to the standard normal marginal, indeed uses \(e^{-x^2/2}\). Also, the sentence "the constant \(c\) can be any positive value" is true only if the marginals are allowed to have a variance other than 1: requiring standard normal marginals forces \(c=1/(1-v^2)\) (Filling the gap 11.18).
The test is written "\(H_0\colon\beta_1=0\) versus \(H_0\colon\beta_1>0\)": the second is \(H_1\). The same page's \(\sum(x_i-\bar x)^2=109\,957\,100-\frac1{21}(45\,100)^2\) should read \(45\,110^2\) (the printed result \(13\,056\,523.81\) is correct for \(45\,110\)), and \(\hat\beta_0\) is printed as \(15.771\) on that page and as \(15.7661\) in Example 11.3.2 (the exact value is \(15.7711\)).
The book usually rounds the coefficients before using them; two entries (the Camry \(s^2\) and the \(t\) of Example 11.3.4) are arithmetic slips that do not follow even from the book's own printed inputs. Recomputing each from the printed data gives slightly different numbers; none changes a conclusion.
| Quantity | book | unrounded |
|---|---|---|
| CS 11.2.2: slope; line at \(x=45\) | 12.9; 543 | 12.865; 540.9 |
| CS 11.2.4: prediction for 2003 | 107,432,032 | 107,432,079 (b = 0.343); 106.9 million (b = 0.3428) |
| CS 11.2.5: \(\log a\); prediction at 2500 | 1.08028; 11,400 | 1.0790; 11,406 |
| CS 11.2.6: \(\sum\ln\frac{1-y}{y}\), \(\sum x\ln\frac{1-y}{y}\), \(a\) | −15.91, −10.2096, 2.595 | −15.895, −10.2049, 2.596 |
| CS 11.3.1: \(s^2\), \(s\) | 2181.588, 46.707 | 2181.661, 46.708 |
| Ex. 11.3.2, 11.3.3: half-widths | 59.4714; 114.4725 | 59.473; 114.431 |
| CS 11.3.2: \(s^2\); interval for \(\beta_1\) | 117,727.98; (661.30, 835.52) | 117,830.6; (661.26, 835.56) |
| Ex. 11.3.4: \(t\) | 2.50 | 2.493 |
| CS 11.4.1: \(r^2\) | 0.832 | 0.831 |
The Camry value of \(s^2\) is the instructive one: formula (11.3.5) subtracts nearly equal sums of order \(10^9\) and loses about three digits, so even the book's rounded coefficients give \(117\,583.5\), and the printed \(117\,727.98\) matches neither that nor the exact value (Filling the gap 11.8).
11.3.5: the printed \(0.9164\) uses \(\Phi(1.73)=0.9582\) from the table; the exact value of \(2\Phi(1.5/\sqrt{0.75})-1\) is \(0.9167\). 11.5.1: the printed \(0.1891\) and \(0.2127\) use two-decimal \(z\) values; the exact probabilities are \(0.1869\) and \(0.2117\) (Question 11.5.1). 11.2.3: the book says a straight line "appears to fit"; the residuals it lists (\(-0.81\), \(0.01\), \(0.09\), \(0.03\), \(-0.09\), \(0.14\), \(0.55\), \(1.69\), \(-1.61\)) are small relative to the range of \(y\) (59), but the last two are large and of opposite sign, a mild concave bend that a quadratic term removes in part (residual standard deviation \(0.96\) falls to \(0.75\)); see Question 11.2.3.
For the simple linear model the maximum likelihood and least squares estimates of \(\beta_0\) and \(\beta_1\) are the same numbers (Theorem 11.3.1). What the model adds is the probability law of \(Y\), which turns the estimates into random variables with the distributions of Theorem 11.3.2 and so gives tests and intervals. Least squares remains a sensible criterion without any normality assumption (it is best linear unbiased, the Gauss–Markov theorem of the graduate course, Filling the gap 13.4), but the \(t\) and \(\chi^2\) laws need normal errors (or, approximately, large samples).
Thirteen of the book's questions, restated in my own words, and one problem of my own for Section 11.6 (the book has no questions there), covering every section of the chapter, with complete solutions (hidden). Numbers were cross-checked with the book's answers to the odd-numbered questions, which they match except where noted in Notes on the book.
Question 11.2.3 (solubility of sodium nitrate). The number of parts of sodium nitrate that dissolve in 100 parts of water at temperature \(x\) (degrees Celsius) is \(y\): \((0,66.7)\), \((4,71.0)\), \((10,76.3)\), \((15,80.6)\), \((21,85.7)\), \((29,92.9)\), \((36,99.4)\), \((51,113.6)\), \((68,125.1)\). The sums are \(\sum x=234\), \(\sum y=811.3\), \(\sum x^2=10\,144\), \(\sum xy=24\,628.6\). Find the least squares line and the residuals, draw the residual plot and say whether a straight line is appropriate. (Data: Question 11.2.3 of Larsen and Marx 2018.)
Fit the line from the sums, compute the nine residuals, and look at their signs in order of \(x\) rather than just their size.
Compute \(S_{xx}\), \(S_{xy}\) from the sums. Aim for: \(b\approx0.871\), \(a\approx67.5\).
Compute the residuals. Aim for: small in the middle, \(+1.69\) at \(x=51\), \(-1.61\) at \(x=68\).
Judge the plot against \(s\) and the range of \(y\); say what you would trust the line for.
With \(n=9\): \(S_{xx}=10\,144-234^2/9=4060\), \(S_{xy}=24\,628.6-234(811.3)/9=3534.8\), so \[ b=\frac{3534.8}{4060}=0.8706,\qquad a=\frac{811.3-0.8706(234)}9=67.508,\qquad\hat y=67.508+0.8706\,x. \] The residuals \(y_i-\hat y_i\) are, in order of \(x\): \(-0.81,\ 0.01,\ 0.09,\ 0.03,\ -0.09,\ 0.14,\ 0.55,\ 1.69,\ -1.61\) (they sum to zero, Filling the gap 11.2), and \(s=0.959\), \(r=0.9990\). The plot. The residual is \(-0.81\) at \(x=0\), then within \(\pm0.15\) for the next five temperatures, then \(+0.55\) and \(+1.69\) at \(x=36,51\), and \(-1.61\) at \(68\). That is a small bend: the points rise a little faster than the line over the middle and more slowly beyond 51 (concave). Relative to the range of \(y\) (59 units) and \(s=0.96\) the line is an excellent description, which is why the book says a line fits; but the pattern is not purely random, and a quadratic fit \(66.7+0.960x-0.00136x^2\) reduces the residual standard deviation from \(0.96\) to \(0.75\) (with \(9-3=6\) degrees of freedom). Conclusion. For interpolation within 0 to 68 degrees the line is adequate; for predicting solubility at higher temperatures one would not trust it, for the same reason as in Case Study 11.2.2: the residual plot is the better guide. With only nine points two large residuals at one end are suggestive, not conclusive.
Question 11.2.14 (a line through the origin). When theory says the relationship must pass through the origin, the model is \(y=bx\). Show that the least squares slope is \(b=\sum x_iy_i/\sum x_i^2\). Then compute it for the calcium oxide data of Case Study 11.2.3 (recovered against present) and compare it with the unrestricted fit.
With one parameter the sum of squares \(L(b)\) is a quadratic in \(b\). Where is its minimum?
Expand \(\sum(y_i-bx_i)^2\) and find the vertex. Aim for: \(b=\sum x_iy_i/\sum x_i^2\).
Evaluate on the calcium oxide data. Aim for: \(b\approx0.987\); compare with the unrestricted slope \(0.9948\).
Check whether \(\sum e_i=0\) still holds, and what that does to the usual \(r^2\).
Minimise \(L(b)=\sum(y_i-bx_i)^2\). It is a quadratic in \(b\) with positive leading coefficient \(\sum x_i^2\) (positive unless all \(x_i=0\)): \(L(b)=\sum y_i^2-2b\sum x_iy_i+b^2\sum x_i^2=\sum x_i^2\big(b-\frac{\sum x_iy_i}{\sum x_i^2}\big)^2+\sum y_i^2-\frac{(\sum x_iy_i)^2}{\sum x_i^2}\). So the unique minimiser is \(b=\sum x_iy_i/\sum x_i^2\) (equivalently \(L'(b)=-2\sum x_i(y_i-bx_i)=0\) and \(L''=2\sum x_i^2>0\)).
For the ten calcium oxide samples \(\sum x_iy_i=6884.65\) and \(\sum x_i^2=6974.25\), so \(b=0.98715\): the procedure recovers about 98.7% of the calcium oxide. The unrestricted line \(\hat y=-0.2281+0.9948\,x\) has a slope \(0.9948\) and an intercept very near \(0\), and the two lines nearly coincide at large \(x\); the restricted fit forces a smaller slope to compensate. Two caveats. (i) The residuals of a through-the-origin fit do not sum to zero (only \(\sum x_ie_i=0\) holds), so the residual plot and the identities \(\mathrm{SST}=\mathrm{SSE}+\mathrm{SSR}\) of Filling the gap 11.8 need care: the "\(r^2\)" printed by software for such a fit uses \(\sum y_i^2\) in place of \(\sum(y_i-\bar y)^2\) and is not comparable with the usual one. (ii) Forcing the origin is justified only by an a priori reason, not by the fit looking close to it; the usual practice is to fit the intercept and test \(H_0\colon\beta_0=0\) (equation 11.3.6). Question 11.2.16 is the same argument with the slope or the intercept known instead.
Question 11.2.22 (used Toyota Corollas). The suggested 2009 retail price \(y\) of a four-door manual Corolla of age \(x\) years is 14,680, 12,150, 11,215, 10,180, 9,230, 8,455, 7,730, 6,825, 6,135, 5,620 dollars for \(x=1,\dots,10\). (a) Fit \(y=ae^{bx}\) by least squares. (b) Predict the price at age 11. (c) A new Corolla cost \(\$16\,200\). Is that consistent with the belief that a new car loses much of its value the moment it is bought? (Data: Question 11.2.22 of Larsen and Marx 2018.)
Prices fall by a roughly constant percentage each year. Which transformation makes that a straight line, and what does its slope mean in percent?
Regress \(\ln y\) on \(x\). Aim for: \(b\approx-0.102\), \(a\approx15\,475\), a loss of about \(9.7\%\) a year.
Evaluate at \(x=11\). Aim for: about \(\$5040\); exponentiate an interval on the log scale for a prediction range.
Compare the curve at \(x=0\) with \(\$16\,200\), and the first-year drop with later yearly drops.
(a) Regress \(\ln y\) on \(x\) (equation 11.2.2). \(\sum x=55\), \(\sum x^2=385\), \(\sum\ln y=90.862\), \(\sum x\ln y=491.332\), so \(b=\dfrac{10(491.332)-55(90.862)}{10(385)-55^2}=-0.10195\) and \(\ln a=\dfrac{90.862+0.10195(55)}{10}=9.6469\), \(a=e^{9.6469}=15\,474.5\): \[ \hat y=15\,474.5\,e^{-0.10195\,x}. \] Interpretation: each year multiplies the price by \(e^{-0.10195}=0.903\), a loss of \(9.7\%\) a year. The 95% interval for \(b\) (Theorem 11.3.6 on the log scale) is \((-0.1082,-0.0957)\), so between \(9.1\%\) and \(10.3\%\). The residuals on the log scale are \(0.049,-0.038,-0.016,-0.011,-0.007,0.007,0.020,-0.003,-0.008,0.007\) (\(s=0.0246\)): small, except for the first year, which sits 5% above the curve.
(b) At \(x=11\): \(15\,474.5\,e^{-1.1214}=\$5042\). A 95% prediction interval, obtained by exponentiating the interval for \(\ln y\) (Theorem 11.3.8; Filling the gap 11.4), is \((\$4707,\ \$5400)\). It is one year beyond the data, so only a mild extrapolation.
(c) The curve at \(x=0\) is \(\$15\,475\) (95% interval \(\$14\,886\) to \(\$16\,086\) for the median curve), so the new-car price of \(\$16\,200\) is about 4.7% above the extrapolated curve: some extra loss between purchase and the pattern of later years is suggested, but it is small and the interval for the curve at \(0\) only just excludes \(16\,200\). The first-year drop in the data, from \(16\,200\) to \(14\,680\), is \(9.4\%\), about the same as the \(9.7\%\) that every later year costs. So the data support steady geometric depreciation from the first year on, and do not by themselves show a drop at the moment of purchase larger than a typical year's. (Retail suggested prices are not the amount a buyer would get on resale, which is what the belief is about.)
Question 11.2.29 (three more linearisations). Show that the transformations given for models (d), (e), (f) of Table 11.2.9 make them linear: (d) \(y=\frac1{a+bx}\): \(1/y\) is linear in \(x\); (e) \(y=\frac{x}{a+bx}\): \(1/y\) is linear in \(1/x\); (f) \(y=1-e^{-x^b/a}\): \(\ln\ln\frac1{1-y}\) is linear in \(\ln x\). Give the slope and intercept in each case.
In each model, isolate the combination of \(y\) (and \(x\)) that is linear, using reciprocals and logarithms.
Take the reciprocal of \(y=1/(a+bx)\). Aim for: \(1/y=a+bx\).
Split \(\frac{a+bx}{x}\). Aim for: \(1/y=b+a/x\), slope \(a\) and intercept \(b\).
Subtract from 1, take reciprocals, then logarithms twice. Aim for: \(\ln\ln\frac1{1-y}=b\ln x-\ln a\).
(d) Taking reciprocals, \(1/y=a+bx\): a line in \(x\) with intercept \(a\) and slope \(b\). This requires \(y\ne0\).
(e) \(1/y=\dfrac{a+bx}{x}=b+a\cdot\dfrac1x\): a line in \(1/x\) with intercept \(b\) and slope \(a\) (note the swap). This is the Michaelis–Menten form, \(x>0\).
(f) For \(x>0\), \(a>0\) and \(0<y<1\): \(1-y=e^{-x^b/a}\), so \(\dfrac1{1-y}=e^{x^b/a}\), \(\ln\dfrac1{1-y}=\dfrac{x^b}a>0\) and, taking logarithms again, \(\ln\ln\dfrac1{1-y}=b\ln x-\ln a\): a line in \(\ln x\) with slope \(b\) and intercept \(-\ln a\). (This is the Weibull distribution function, \(F(x)=1-e^{-x^b/a}\); the plot of \(\ln\ln\frac1{1-F}\) against \(\ln x\) is the Weibull plot.) In all three cases, fitting the straight line by Theorem 11.2.1 to the transformed data and transforming the coefficients back (\(a=e^{-\text{intercept}}\) in (f)) estimates the model; and as in Filling the gap 11.4 the criterion is least squares on the transformed scale, which weights the points differently from least squares on the \(y\) scale (in (d) and (e) points with small \(y\) dominate).
Question 11.3.1 (mosquito flight). The mean distance flown to exhaustion (in thousands of metres) by forty females of Culex tarsalis of age \(x\) weeks was \(12.6,\ 11.6,\ 6.8,\ 9.2\) for \(x=1,2,3,4\). Fit a line and test that the slope is zero against a two-sided alternative at \(\alpha=0.05\). (Data: Question 11.3.1 of Larsen and Marx 2018.)
Four points give only two degrees of freedom. What does that do to the critical value of the \(t\) test?
Fit the line. Aim for: \(\hat y=13.8-1.5x\).
Compute the residuals, \(\mathrm{SSE}\), \(s\), and \(t=\hat\beta_1\sqrt{S_{xx}}/s\). Aim for: \(t\approx-1.59\).
Compare with \(t_{.025,2}=4.3027\) and interpret a non-significant result with four points.
\(\bar x=2.5\), \(\bar y=10.05\), \(S_{xx}=5\), \(S_{xy}=(-1.5)(2.55)+(-0.5)(1.55)+(0.5)(-3.25)+(1.5)(-0.85)=-7.5\), so \(\hat\beta_1=-1.5\), \(\hat\beta_0=10.05+1.5(2.5)=13.8\): \(\hat y=13.8-1.5\,x\). The fitted values are \(12.3,10.8,9.3,7.8\), the residuals \(0.3,0.8,-2.5,1.4\) and \(\mathrm{SSE}=8.94\), \(s^2=8.94/2=4.47\), \(s=2.114\). Then \[ t=\frac{-1.5-0}{2.114/\sqrt5}=\frac{-1.5}{0.9457}=-1.586. \] With \(n-2=2\) degrees of freedom \(t_{.025,2}=4.3027\), so \(|t|<4.3027\) and \(H_0\colon\beta_1=0\) is not rejected (\(P=0.25\)). The 95% interval for the slope is \(-1.5\pm4.3027(0.9457)=(-5.57,\ 2.57)\). The data are compatible with a decline of up to 5.6 thousand metres per week and with a rise of 2.6: with four points and two degrees of freedom the test has almost no power (the critical value is \(4.30\) instead of \(1.96\)). This is a failure to reject, not evidence of no relationship. Note that the straight-line model is a poor description of the middle ages too (the residual at \(x=3\) is \(-2.5\)), which four points cannot test.
Question 11.3.4 (where to put the \(x\) values) and Question 11.3.5. An experimenter will take \(2n\) observations from a linear model, with the \(x_i\) restricted to \([0,5]\), and wants the most precise estimate of the slope. Where should the \(x_i\) be placed? For part (b), \(n=9\) measurements are taken at \(x=1,2,\dots,9\) with \(\sigma^2=45\): find the probability that \(\hat\beta_1\) is within \(1.5\) of \(\beta_1\).
The variance of \(\hat\beta_1\) is \(\sigma^2/S_{xx}\). So which placement of the \(x_i\) in \([0,5]\) makes \(S_{xx}\) as large as possible?
Show \(S_{xx}\) is convex in each \(x_j\), so all \(x_j\in\{0,5\}\); with \(k\) at \(5\), \(S_{xx}=25k(2n-k)/(2n)\). Aim for: best at \(k=n\).
For \(x=1,\dots,9\) compute \(S_{xx}\) and the standard deviation of \(\hat\beta_1\). Aim for: \(0.866\).
Evaluate \(2\Phi(1.5/\mathrm{sd})-1\). Aim for: about \(0.917\).
(a) \(\mathrm{Var}(\hat\beta_1)=\sigma^2/S_{xx}\) (Theorem 11.3.2), so the slope is most precisely estimated when \(S_{xx}=\sum(x_i-\bar x)^2\) is largest. Fix all but one of the \(x_i\): \(S_{xx}\) is a convex quadratic function of the free \(x_j\) (its second derivative is \(2(1-\frac1{2n})>0\)), so over \([0,5]\) it is largest at an endpoint \(0\) or \(5\), whatever the others are. Hence at the optimum every \(x_i\in\{0,5\}\). With \(k\) points at \(5\) and \(2n-k\) at \(0\), \(\bar x=5k/(2n)\) and \[ S_{xx}=\frac{25\,k(2n-k)}{2n},\] which is largest at \(k=n\), where \(S_{xx}=12.5\,n\) and \(\mathrm{Var}(\hat\beta_1)=\sigma^2/(12.5n)\). So put half the observations at each end of the interval. (For comparison, \(2n\) points spread evenly over \([0,5]\) have \(S_{xx}\approx\frac{25}{12}\cdot2n=4.2n\) and a variance \(3\) times larger: Figure x11.3.) A practical warning: a design with only two \(x\) values makes the straight-line assumption (3) untestable, since nothing distinguishes a line from any curve through the two mean points; in practice some points are placed in the middle and the slope precision is traded for the ability to detect curvature.
(b) \(S_{xx}=\sum_{i=1}^9(i-5)^2=60\), \(\mathrm{Var}(\hat\beta_1)=45/60=0.75\), \(\mathrm{sd}=0.866\), and \(\hat\beta_1\) is normal with mean \(\beta_1\) (Theorem 11.3.2), so \[ \mathrm P(|\hat\beta_1-\beta_1|\le1.5)=2\Phi\Big(\frac{1.5}{0.866}\Big)-1=2\Phi(1.732)-1=0.9167. \] (The book's \(0.9164\) uses \(\Phi(1.73)=0.9582\).)
Question 11.3.14 (the variance in the cigarette data). Construct a 90% confidence interval for \(\sigma^2\) in the cigarette consumption and CHD mortality data of Case Study 11.3.1 (\(n=21\), \(s^2=2181.66\)).
The statistic \((n-2)S^2/\sigma^2\) is chi-squared. With how many degrees of freedom, and which two quantiles bound it?
Find \(\chi^2_{.05,19}\) and \(\chi^2_{.95,19}\). Aim for: \(10.117\) and \(30.144\).
Divide \(19s^2\) by the upper and then the lower quantile. Aim for: \((1375,\ 4097)\).
By Theorem 11.3.3(b), \((n-2)S^2/\sigma^2\sim\chi^2_{19}\). The \(5\%\) and \(95\%\) points of \(\chi^2_{19}\) are \(10.117\) and \(30.144\), so the 90% interval is (Filling the gap 11.11) \[ \Big(\frac{19(2181.66)}{30.144},\ \frac{19(2181.66)}{10.117}\Big)=(1375.1,\ 4097.2). \] Taking square roots, \(\sigma\) is between \(37.1\) and \(64.0\) deaths per 100,000: the countries' mortality rates deviate from the line by 37 to 64 units, in standard deviation. The interval is far from symmetric about \(s^2\) (the point estimate lies at \(2181.66\), the endpoints are \(-806\) and \(+1916\) away) because of the skewness of \(\chi^2_{19}\). The degrees of freedom are \(n-2=19\), not \(n-1=20\): the interval of Chapter 7 for a single sample would be slightly narrower and is wrong here.
Question 11.3.16 (volume from weight). To calibrate a way of finding the volume \(y\) (cubic decimetres) of an irregular body from its weight \(x\) (kg), the weights and volumes of 18 children aged five to eight were measured: x = 17.1, 10.5, 13.8, 15.7, 11.9, 10.4, 15.0, 16.0, 17.8, 15.8, 15.1, 12.1, 18.4, 17.1, 16.7, 16.5, 15.1, 15.1; y = 16.7, 10.4, 13.5, 15.7, 11.6, 10.2, 14.5, 15.8, 17.6, 15.2, 14.8, 11.9, 18.3, 16.7, 16.6, 15.9, 15.1, 14.5. The fitted line is \(\hat y=-0.104+0.988x\) with \(s=0.202\). (a) Find a 95% confidence interval for \(\mathrm E(Y\mid14.0)\). (b) Find a 95% prediction interval for the volume of a child weighing 14.0 kg. (Data: Question 11.3.16 of Larsen and Marx 2018.)
Both intervals are centred at the fitted value; they differ by a single \(1\) under the square root. What is that \(1\)?
Compute \(\bar x\), \(S_{xx}\) and the fitted value at \(14.0\). Aim for: \(\bar x\approx15.0\), \(S_{xx}\approx96.4\), \(\hat y\approx13.73\).
Evaluate \(t_{.025,16}\,s\sqrt{\frac1n+\frac{(x-\bar x)^2}{S_{xx}}}\). Aim for: about \(0.11\).
Add \(1\) under the root. Aim for: about \(0.44\), four times wider.
Here \(n=18\), \(\bar x=15.006\), \(S_{xx}=96.389\), \(t_{.025,16}=2.1199\) and \(\hat y(14.0)=-0.104+0.988(14.0)=13.728\). The quantity under the root is \(\frac1{18}+\frac{(14.0-15.006)^2}{96.389}=0.05556+0.01049=0.06605\).
(a) \(w=2.1199(0.202)\sqrt{0.06605}=0.1100\), so the interval for the mean volume of children weighing 14 kg is \(13.728\pm0.110=(13.62,\ 13.84)\) cubic decimetres (Theorem 11.3.7).
(b) \(w=2.1199(0.202)\sqrt{1+0.06605}=0.4421\), so a single child of 14 kg is predicted to have a volume in \(13.728\pm0.442=(13.29,\ 14.17)\) (Theorem 11.3.8). The prediction interval is four times as wide as the interval for the mean: the mean is pinned down by 18 children, but one more child has her own scatter, \(s=0.2\), about the line. The \(x=14.0\) is close to the centre of the weights (\(\bar x=15.0\)), so both intervals are near their narrowest; at \(x=10.4\), the lightest child, the half-widths would be \(0.22\) and \(0.48\). For the calibration purpose (estimating a body's volume from its weight) the prediction interval is the relevant one: the error is about \(\pm0.4\) of a total of about \(14\).
Question 11.3.21 (salary and years of service). Attorneys for six male buyers claim sex discrimination because the least squares slope of salary (thousands of dollars) on years of service is \(0.606\) for the men but \(1.07\) for the eight female buyers (lines \(21.3+0.606x\) and \(23.2+1.07x^*\)). The residual sums of squares are \(5.983\) (men) and \(13.804\) (women), and \(\sum(x_i-\bar x)^2=31.33\) and \(46\). As the company's lawyer, how would you respond? (Data: Question 11.3.21 of Larsen and Marx 2018.)
Two slopes from two independent small samples: is their difference big compared with its standard error?
Pool the variances. Aim for: \(s\approx1.407\) on \(10\) degrees of freedom.
Compute \(t=(0.606-1.07)/\big(s\sqrt{1/31.33+1/46}\big)\). Aim for: \(-1.42\).
Decide against \(-t_{.05,10}=-1.8125\) and write what the lawyer would say, including what the test cannot show.
Test \(H_0\colon\beta_1=\beta_1^*\) with Theorem 11.3.9 (assuming equal error variances). The pooled standard deviation is \(s=\sqrt{\dfrac{5.983+13.804}{6+8-4}}=\sqrt{1.9787}=1.407\), and \[ t=\frac{0.606-1.07}{1.407\sqrt{\frac1{31.33}+\frac1{46}}}=\frac{-0.464}{1.407(0.2314)}=-1.42\] on \(10\) degrees of freedom. For the one-sided alternative that the men's slope is smaller (the plaintiffs' claim) the critical value is \(-t_{.05,10}=-1.8125\); \(t=-1.42\) is not below it, and the one-sided \(P=0.093\). Two-sided, \(|t|<t_{.025,10}=2.228\), \(P=0.19\). So the difference in slopes is within chance variation for samples of this size. As lawyer, I would say: (1) a difference between two estimated slopes, from six and eight people, is not evidence of different policies unless it exceeds what the sampling error of the slopes, about \(0.33\) here (\(1.407\times0.2314\)), would produce; the observed difference \(0.464\) is only about \(1.4\) standard errors. (2) The data do not exclude a real difference either: the test has little power, and the 95% interval for \(\beta_1^*-\beta_1\) is \(0.464\pm2.228(0.326)=(-0.26,\ 1.19)\) thousand dollars per year. (3) The comparison of slopes ignores the intercepts, and a company could differ in starting salary (\(\$21.3\)k against \(\$23.2\)k here) rather than in raises; and the lines are fitted over different ranges of years of service. The statistics do not support the claim of a different rate of increase, but a study this small cannot establish that there is none.
Question 11.4.6 (a perfect curve with a high correlation). Let \(X\) take the values \(1,2,\dots,n\) with probability \(1/n\) each and \(Y=X^2\). Find \(\rho(X,Y)\) and its limit as \(n\to\infty\).
Everything reduces to the power sums \(\sum k,\sum k^2,\sum k^3,\sum k^4\). Which combinations give \(\mathrm{Cov}(X,X^2)\), \(\mathrm{Var}X\), \(\mathrm{Var}X^2\)?
Compute \(\mathrm{Cov}(X,X^2)\) and \(\mathrm{Var}X\). Aim for: \((n+1)^2(n-1)/12\) and \((n^2-1)/12\).
Compute \(\mathrm{Var}X^2\) and factor it. Aim for: \((n+1)(2n+1)(n-1)(8n+11)/180\).
Assemble \(\rho\) and let \(n\to\infty\). Aim for: \(\sqrt{15}/4\approx0.968\).
Use the power sums \(\sum k=\frac{n(n+1)}2\), \(\sum k^2=\frac{n(n+1)(2n+1)}6\), \(\sum k^3=\frac{n^2(n+1)^2}4\), \(\sum k^4=\frac{n(n+1)(2n+1)(3n^2+3n-1)}{30}\). Then \(\mathrm EX=\frac{n+1}2\), \(\mathrm EX^2=\frac{(n+1)(2n+1)}6\), \(\mathrm EX^3=\frac{n(n+1)^2}4\), \(\mathrm EX^4=\frac{(n+1)(2n+1)(3n^2+3n-1)}{30}\), and \[ \mathrm{Cov}(X,X^2)=\mathrm EX^3-\mathrm EX\,\mathrm EX^2=\frac{n(n+1)^2}4-\frac{(n+1)^2(2n+1)}{12}=\frac{(n+1)^2(n-1)}{12},\qquad\mathrm{Var}X=\frac{n^2-1}{12},\] \[ \mathrm{Var}X^2=\mathrm EX^4-(\mathrm EX^2)^2=\frac{(n+1)(2n+1)(n-1)(8n+11)}{180}\] (after simplifying \(8n^2+3n-11=(8n+11)(n-1)\)). Therefore \[ \rho(X,Y)=\frac{(n+1)^2(n-1)/12}{\sqrt{\frac{n^2-1}{12}\cdot\frac{(n+1)(2n+1)(n-1)(8n+11)}{180}}}=\sqrt{15}\,\frac{n+1}{\sqrt{(2n+1)(8n+11)}}. \] Check: \(n=2\) gives \(1\) (two points always lie on a line), \(n=3\) gives \(0.9897\), \(n=10\) gives \(0.9746\), \(n=100\) gives \(0.9689\). As \(n\to\infty\), \(\frac{n+1}{\sqrt{(2n+1)(8n+11)}}\to\frac1{\sqrt{16}}=\frac14\), so \(\rho\to\sqrt{15}/4=0.9682\), the correlation of \(X\) and \(X^2\) for \(X\) uniform on \((0,1)\) (Filling the gap 11.23). The moral is Section 11.6's: \(Y\) is an exact function of \(X\), yet \(\rho\) is not 1 (a curve is not a line), and it is very high (0.97), so a high \(r\) does not show a relationship is linear.
Question 11.4.13 (stress and the seriousness of illness). Seventeen conditions were compared on a seriousness-of-illness rating scale \(y\) (SIRS) and on the average stress score \(x\) of a Schedule of Recent Experience (SRE) completed by patients with each condition. The sums are \(\sum x=7973\), \(\sum y=8517\), \(\sum x^2=4\,611\,291\), \(\sum y^2=5\,421\,917\), \(\sum xy=4\,759\,470\). How much of the variation in SIRS is attributable to the linear regression with SRE? (Data: Question 11.4.13 of Larsen and Marx 2018.)
The fraction of variation explained by the line is a single number. Which one?
Evaluate \(r\) from the five sums. Aim for: about \(0.762\).
Square it and state in words what it does and does not say. Aim for: \(r^2\approx0.581\).
The fraction is \(r^2\) (equation 11.4.3). With \(n=17\), \[ r=\frac{17(4\,759\,470)-(7973)(8517)}{\sqrt{17(4\,611\,291)-7973^2}\sqrt{17(5\,421\,917)-8517^2}}=\frac{13\,004\,949}{\sqrt{14\,823\,218}\sqrt{19\,633\,300}}=\frac{13\,004\,949}{(3850.1)(4431.0)}=0.762. \] So \(r^2=0.581\): about \(58.1\%\) of the variation in the seriousness of illness ratings among the seventeen conditions is accounted for by the linear regression on the stress score, and \(41.9\%\) is not. This is a statement about the sums of squares, and about conditions averaged over patients: it does not say that stress makes illnesses more serious (the more serious illnesses may themselves create stressful life events, and the unit is a condition, not a person); and with seventeen points the proportion explained is itself uncertain (the test of \(\rho=0\) gives \(t=4.56\) on 15 degrees of freedom, \(P=0.0004\)).
Question 11.5.1 (a bivariate normal pair). \(X\) and \(Y\) have a bivariate normal density with \(\mu_X=3\), \(\mu_Y=6\), \(\sigma_X^2=4\), \(\sigma_Y^2=10\), \(\rho=\frac12\). Find \(\mathrm P(5<Y<6\frac12)\) and \(\mathrm P(5<Y<6\frac12\mid X=2)\).
The first probability uses the marginal of \(Y\). The second needs the conditional law of \(Y\) given \(X=2\): what are its mean and variance?
Standardise with \(\mu_Y=6\), \(\sigma_Y=\sqrt{10}\). Aim for: about \(0.187\).
Find \(\mu_Y+\rho\frac{\sigma_Y}{\sigma_X}(2-\mu_X)\) and \((1-\rho^2)\sigma_Y^2\). Aim for: \(5.209\) and \(7.5\).
Standardise with those values. Aim for: about \(0.212\); explain why it differs from (a).
Marginal. \(Y\sim\mathrm N(6,10)\) (Theorem 11.5.1(a)), \(\sigma_Y=3.1623\): \[ \mathrm P(5<Y<6.5)=\Phi\Big(\frac{0.5}{3.1623}\Big)-\Phi\Big(\frac{-1}{3.1623}\Big)=\Phi(0.158)-\Phi(-0.316)=0.5628-0.3760=0.1869. \] Conditional. By Theorem 11.5.1(c), (d), given \(X=2\), \(Y\) is normal with mean \(6+\frac12\cdot\frac{3.1623}{2}(2-3)=6-0.7906=5.2094\) and variance \((1-\frac14)(10)=7.5\), standard deviation \(2.7386\): \[ \mathrm P(5<Y<6.5\mid X=2)=\Phi\Big(\frac{6.5-5.2094}{2.7386}\Big)-\Phi\Big(\frac{5-5.2094}{2.7386}\Big)=\Phi(0.471)-\Phi(-0.076)=0.6813-0.4695=0.2117. \] (The book's \(0.1891\) and \(0.2127\) are the same calculation with \(z\) rounded to two decimals, \(\Phi(0.16)-\Phi(-0.32)\) and \(\Phi(0.47)-\Phi(-0.08)\).) Knowing \(X=2\) (below its mean) shifts the distribution of \(Y\) down by \(0.79\), since \(\rho>0\), and narrows it (standard deviation \(2.74\) instead of \(3.16\)), so the interval \((5,6.5)\) around the lower region gets slightly more probability.
Question 11.5.8 (weight and cholesterol). In a heart disease study the weight \(x\) (pounds) and blood cholesterol \(y\) (mg/dl) of fourteen men with no history of coronary incidents were recorded; the sums are \(\sum x=2458\), \(\sum y=4097\), \(\sum x^2=444\,118\), \(\sum y^2=1\,262\,559\), \(\sum xy=710\,499\). At \(\alpha=0.05\), can one conclude that the two variables are not independent? (Data: Question 11.5.8 of Larsen and Marx 2018.)
Independence of a bivariate normal pair means \(\rho=0\). Which statistic tests it, and with how many degrees of freedom?
Compute \(r\). Aim for: about \(-0.312\).
Compute \(t=\sqrt{n-2}\,r/\sqrt{1-r^2}\) and compare with \(t_{.025,12}=2.1788\). Aim for: \(t\approx-1.14\).
Say what the failure to reject means with \(n=14\) (what correlation could it detect?).
Assuming a bivariate normal law, independence is \(H_0\colon\rho=0\) against \(H_1\colon\rho\ne0\) (Theorem 11.5.3 and the Comment after Definition 11.5.1). With \(n=14\), \[ r=\frac{14(710\,499)-(2458)(4097)}{\sqrt{14(444\,118)-2458^2}\sqrt{14(1\,262\,559)-4097^2}}=\frac{-123\,440}{(419.39)(943.62)}=-0.312, \] \[ t=\frac{\sqrt{12}(-0.312)}{\sqrt{1-0.312^2}}=\frac{-1.0805}{0.9501}=-1.137. \] The critical values are \(\pm t_{.025,12}=\pm2.1788\), so \(H_0\) is not rejected (\(P=0.28\)): the data do not contradict independence. Equivalently, the slope of cholesterol on weight, \(\hat\beta_1=-0.70\) mg/dl per pound, has the same \(t=-1.137\). With 14 men the test only detects \(|r|\ge t/\sqrt{t^2+12}=0.532\), so independence is not established either; Fisher's 95% interval for \(\rho\) is wide, \((-0.72,\ 0.26)\). The sample contains one heavy man (262 pounds) and cholesterol values from 135 to 403, so the normality of the pair is doubtful: always plot first (Section 11.6).
Problem 11.6.1 (own: selecting on the predictor). A test score \(X\sim\mathrm N(0,1)\) predicts later performance \(Y=0.6X+0.8\varepsilon\) with \(\varepsilon\sim\mathrm N(0,1)\) independent of \(X\), so that \(\rho(X,Y)=0.6\) in the whole population. A university admits only applicants with \(X>0\). (a) What is the correlation between \(X\) and \(Y\) among the admitted? (b) What are the slope and residual variance of the regression of \(Y\) on \(X\) among them? (c) What would the university conclude about the test if it looked only at its students?
Selecting on \(X\) changes the distribution of \(X\) but not the relation of \(Y\) to \(X\). Which of slope, residual variance and correlation therefore stay the same?
Find \(\sigma_x^2\) for \(X\mid X>0\) and insert it in the formula for \(\rho^2\). Aim for: \(\sigma_x^2=0.3634\), \(\rho\approx0.41\).
State the slope and residual variance among the admitted. Aim for: \(0.6\) and \(0.64\), unchanged.
Say what the university would wrongly conclude if it read \(r\) alone.
(a) Selecting on \(X\) changes the law of \(X\) but not the conditional law of \(Y\) given \(X\): among the admitted, \(Y=0.6X+0.8\varepsilon\) still holds, with \(\varepsilon\) independent of \(X\). The truncated \(X\) (half-normal) has \(\mathrm E(X\mid X>0)=\sqrt{2/\pi}=0.798\) and \(\mathrm E(X^2\mid X>0)=1\), so \(\sigma_x^2=1-\frac2\pi=0.3634\). By Filling the gap 11.23(a), \[ \rho^2=\frac{\beta_1^2\sigma_x^2}{\beta_1^2\sigma_x^2+\sigma^2}=\frac{0.36(0.3634)}{0.36(0.3634)+0.64}=\frac{0.1308}{0.7708}=0.1697,\qquad\rho=0.412. \] (b) The slope is still \(\beta_1=0.6\) and the residual variance \(\sigma^2=0.64\): the relationship between score and performance is exactly the same. (c) The university would see a correlation of about \(0.41\) instead of \(0.60\) and might wrongly decide that the test is a weak predictor, even though each extra score point raises the expected performance by the same \(0.6\) in the admitted group as in the whole population. The slope is the quantity that is unaffected by selection on \(x\); the correlation (and \(r^2=0.17\) rather than \(0.36\)) is not. Selecting on \(Y\) instead would also change the slope (it would be biased towards zero): the first is a range restriction, the second a selection effect, and the conclusion in both is not to read \(r\) alone.
Each demonstration runs in the browser and links back to these notes. The ▶ Demo boxes above open them already set to the case under discussion.
| Demonstration | What you can see | Sections and results |
|---|---|---|
| Least squares, residuals and what r hides | Five of the chapter's data sets (connecting rods, Social Security, calcium oxide, Moore's law, SAT scores). Two sliders for your own line, with the squares whose total area is \(L\), your \(L\) against the least squares minimum, the residual plot, \(r\) and \(r^2\); switches for dropping Chemist B, for the log scale and for the reverse regression. Presets: 1 (rods), 2 (Social Security), 3 (calcium oxide), 4 (Moore's law), 5 (SAT, two regressions). | 11.2, Filling the gap 11.1, 11.2, 11.4, Case Study 11.4.1, 11.23 |
| The sampling distribution of the least squares estimates | Seeded data sets from the simple linear model with a chosen \(n\), \(\sigma\), true slope and placement of the \(x\) values (even, clustered, two ends, far from zero); histograms of \(\hat\beta_1\) and of the slope pivot against the normal and \(t_{n-2}\) curves, the scatter of \((\hat\beta_0,\hat\beta_1)\), and coverage of the intervals for \(\beta_1\), \(\mathrm E(Y\mid x_0)\) and a new \(Y\). Presets: 1 (baseline), 2 (clustered), 3 (two ends), 4 (far from zero), 5 (\(n=4\): \(t\) against \(z\)). | Theorem 11.3.2, 11.7, 11.3.4, 11.3.6, 11.3.7, 11.3.8, Question 11.3.4 |
Related graduate and applied-course demonstrations: Confidence interval or prediction interval? (Section 11.3, Filling the gap 11.14), Least squares with confidence and prediction bands (11.12, 11.13), Conditioning a normal vector (Section 11.5, 11.19), How good is Fisher's interval? (11.22), and for the causal reading of a correlation Simpson's paradox, adjusting for a confounder and intervention versus conditioning (Section 11.6, 11.23).