Advanced Statistics 201-337 • CEGEP, Montreal

Corrected exercises: correlation and linear regression (201-337)

Here are ten corrected exercises on correlation and linear regression for the Advanced Statistics course 201-337 at CEGEP, preceded by a list of calculations. This is the chapter you will meet everywhere afterwards: in economics, in biology, in public health, in any report claiming that one thing explains another. It is also the chapter where students go wrong most often, because the calculator fits a line and computes a coefficient on any scatter plot, even an absurd one. The set covers the scatter plot, the linear correlation coefficient rr, the least-squares line, the coefficient of determination r2r^{2}, prediction and extrapolation, outliers and leverage points, residual analysis and the standard error of the estimate, linearizing an exponential or power model, the significance test for the correlation coefficient, and the distinction between correlation and causation.

Exercise 0.1 opens the set with ten direct linear regression calculations, as in textbook drill lists: the working sums SxyS_{xy}, SxxS_{xx} and SyyS_{yy} obtained from the raw sums, the correlation coefficient r=SxySxxSyyr=\frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}} and the coefficient of determination r2r^{2}, the slope and the intercept of the least-squares line, a predicted value and a residual, each with one value to find and checked as you type it.

By the end, you can describe a scatter plot before computing anything (exercise 1), write and interpret the least-squares line (exercise 2), judge a prediction and refuse an extrapolation (exercise 3), measure the effect of a single outlier or leverage point on rr and on the slope (exercise 4), read a U-shaped residual plot (exercise 7), straighten out bacterial growth by regressing ln⁡N\ln N on tt (exercise 8), and test H0:ρ=0H_{0}:\rho=0 with the tt statistic on n−2n-2 degrees of freedom, where the same r=0.50r=0.50 is significant for 30 individuals and not for 10 (exercise 9). Exercise 6 carries out a complete regression of rent on floor area for apartments.

Exercise 5 deals with the point that truly matters: a correlation coefficient of 0.95 between ice cream sales and the number of drownings establishes strictly nothing, because a third variable, temperature, explains both. Being able to state that objection is what separates a trained reader from a gullible one, and exercise 10 practises it on five claims from the press, from chocolate and Nobel prizes to the dose of a drug.

11 corrected exercises • 110 points • 150 minutes

This chapter is part of 201-337, every chapter with its set and sheet Before you start Revision sheet: the traps and the method for this chapter

Self-checking set Type your answers and check them question by question: the page tells you right or wrong before you open the solution. With an account, every answer right on the first try earns points, and your right answers stay filled in when you come back.

Course recap

  • • Always study the SCATTER PLOT before computing: shape, linearity, outliers. A coefficient computed on a nonlinear scatter plot means nothing.
  • • Working sums: Sxy=∑xy−(∑x)(∑y)nS_{xy}=\sum xy-\dfrac{\left(\sum x\right)\left(\sum y\right)}{n}, Sxx=∑x2−(∑x)2nS_{xx}=\sum x^{2}-\dfrac{\left(\sum x\right)^{2}}{n} and Syy=∑y2−(∑y)2nS_{yy}=\sum y^{2}-\dfrac{\left(\sum y\right)^{2}}{n}.
  • • Linear correlation coefficient: r=SxySxxSyyr=\dfrac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}, always between −1-1 and 11. The SIGN gives the direction, the ABSOLUTE VALUE the strength.
  • • Least-squares line y=a+bxy=a+bx: slope b=SxySxxb=\dfrac{S_{xy}}{S_{xx}}, then a=y‾−bx‾a=\overline{y}-b\overline{x}. It ALWAYS passes through the mean point (x‾,y‾)\left(\overline{x}, \overline{y}\right).
  • • “Least squares” means that the line minimizes the sum of the squares of the VERTICAL deviations between the points and the line. These deviations are called residuals, and their sum is zero.
  • • Coefficient of DETERMINATION r2r^{2}: the proportion of the variation in yy explained by the linear relationship with xx. It is expressed as a percentage.
  • • EXTRAPOLATING, that is, predicting outside the range of the observed xx values, is never justified by the model: nothing guarantees that the relationship continues.
  • • CORRELATION IS NOT CAUSATION. Three competing explanations for any correlation: xx causes yy, yy causes xx, or a third, CONFOUNDING variable causes both. Chance on a small sample is a fourth.
  • • The correlation coefficient is NOT robust: a single outlier can make r2r^{2} drop from 99% to 65%, and a LEVERAGE point, far away in xx, can halve the slope while leaving rr high. Never delete an inconvenient point: investigate, publish with and without it, or switch to a robust method.
  • • Residuals: ei=yi−yi^e_{i}=y_{i}-\hat{y_{i}}. Their sum is zero by construction and proves nothing. The residual PLOT must be a patternless cloud; a curvature signals a nonlinear relationship, a funnel a non-constant spread. Standard error of the estimate: se=∑ei2n−2s_{e}=\sqrt{\frac{\sum e_{i}^{2}}{n-2}}, and ∑ei2=Syy(1−r2)\sum e_{i}^{2}=S_{yy}(1-r^{2}).
  • • Linearization: an EXPONENTIAL model y=aebxy=ae^{bx} is straightened by regressing ln⁡y\ln y on xx (semi-log); a POWER model y=axby=ax^{b} is straightened by regressing ln⁡y\ln y on ln⁡x\ln x (log-log), where the slope gives the exponent directly.
  • • Significance of rr: t=rn−21−r2t=\frac{r\sqrt{n-2}}{\sqrt{1-r^{2}}} on n−2n-2 degrees of freedom. The same r=0.50r=0.50 is not significant for 10 individuals and is significant for 30: significance measures how solid the EVIDENCE is, never the strength or the importance of the relationship.

Calculations: r, the slope and the intercept

Exercise 0.1: Computing r, the least-squares line and a prediction: ten direct calculations

For each line, compute the requested quantity from the sums or coefficients given, without drawing a scatter plot or interpreting. Give the exact value when it comes out evenly, otherwise round to the hundredth, and to the thousandth for rr and r2r^{2}.

Always the same order. First go from the raw sums to the working sums, Sxy=∑xy−∑x∑ynS_{xy}=\sum xy-\frac{\sum x\sum y}{n}, Sxx=∑x2−(∑x)2nS_{xx}=\sum x^{2}-\frac{(\sum x)^{2}}{n} and Syy=∑y2−(∑y)2nS_{yy}=\sum y^{2}-\frac{(\sum y)^{2}}{n}. From them you get r=SxySxxSyyr=\frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}, the slope b=SxySxxb=\frac{S_{xy}}{S_{xx}} and the intercept a=y‾−bx‾a=\overline{y}-b\overline{x}. Finally the line y^=a+bx\hat{y}=a+bx is used to predict, and the residual of a point is read as e=y−y^e=y-\hat{y}.

  • a) n=5n=5, ∑x=30\sum x=30, ∑y=85\sum y=85, ∑xy=564\sum xy=564: compute SxyS_{xy}.
  • b) n=8n=8, ∑x=52\sum x=52, ∑x2=380\sum x^{2}=380: compute SxxS_{xx}.
  • c) n=7n=7, ∑y=60\sum y=60, ∑y2=572\sum y^{2}=572: compute SyyS_{yy}.
  • d) Sxy=−84S_{xy}=-84, Sxx=60S_{xx}=60, Syy=150S_{yy}=150: compute the correlation coefficient rr.
  • e) r=−0.74r=-0.74: compute the coefficient of determination r2r^{2}.
  • f) Sxy=45S_{xy}=45, Sxx=18S_{xx}=18: compute the slope bb of the least-squares line.
  • g) b=−1.6b=-1.6, x‾=12\overline{x}=12, y‾=40\overline{y}=40: compute the intercept aa.
  • h) Line y^=14.2+3.5x\hat{y}=14.2+3.5x: compute the predicted value for x=7.4x=7.4.
  • i) Line y^=88−2.4x\hat{y}=88-2.4x: compute the residual of the point (15,49)(15, 49).
  • j) n=5n=5, ∑x=15\sum x=15, ∑y=55\sum y=55, ∑xy=186\sum xy=186, ∑x2=55\sum x^{2}=55: compute the slope bb, then the intercept aa.

Type your answers, the page tells you right or wrong 0/11

a)
b)
c)
d)
e)
f)
g)
h)
i)
j)
Show the solution

Answers

  • a) Sxy=564−510=54S_{xy}=564-510=54
  • b) Sxx=380−338=42S_{xx}=380-338=42
  • c) Syy=572−36007≈57.71S_{yy}=572-\frac{3600}{7}\approx 57.71
  • d) r=−849000≈−0.885r=\frac{-84}{\sqrt{9000}}\approx-0.885
  • e) r2=0.5476≈0.548r^{2}=0.5476\approx 0.548
  • f) b=4518=2.5b=\frac{45}{18}=2.5
  • g) a=40+19.2=59.2a=40+19.2=59.2
  • h) y^=14.2+25.9=40.1\hat{y}=14.2+25.9=40.1
  • i) e=49−52=−3e=49-52=-3
  • j) b=2110=2.1b=\frac{21}{10}=2.1; a=11−6.3=4.7a=11-6.3=4.7, that is, y^=4.7+2.1x\hat{y}=4.7+2.1x

Everything hinges on the working sums: an SS is always computed as “sum of the products, minus the product of the sums divided by nn”, and that is where students confuse ∑x2\sum x^{2}, the sum of the squares, with (∑x)2(\sum x)^{2}, the square of the sum. Once SxyS_{xy}, SxxS_{xx} and SyyS_{yy} are in hand, rr, bb and aa are nothing more than quotients.

a)

Sxy=564−30×855=564−25505=564−510=54S_{xy}=564-\frac{30\times 85}{5}=564-\frac{2550}{5}=564-510=54. The positive sign announces a positive slope.

b)

Sxx=380−5228=380−27048=380−338=42S_{xx}=380-\frac{52^{2}}{8}=380-\frac{2704}{8}=380-338=42. Pitfall: writing ∑x2n\frac{\sum x^{2}}{n} instead of (∑x)2n\frac{(\sum x)^{2}}{n}; it is the sum that gets squared.

c)

Syy=572−6027=572−36007=572−514.29=57.71S_{yy}=572-\frac{60^{2}}{7}=572-\frac{3600}{7}=572-514.29=57.71. Pitfall: rounding 36007\frac{3600}{7} to the nearest unit too early, which gives 5858; keep at least two decimals in the intermediate calculation.

d)

r=−8460×150=−849000=−8494.868≈−0.885r=\frac{-84}{\sqrt{60\times 150}}=\frac{-84}{\sqrt{9000}}=\frac{-84}{94.868}\approx-0.885. The sign of rr is always that of SxyS_{xy}, since the square root is positive. Pitfall: forgetting the square root, −849000\frac{-84}{9000}, which gives a tiny rr.

e)

r2=(−0.74)2=0.5476≈0.548r^{2}=(-0.74)^{2}=0.5476\approx 0.548. Pitfall: keying in −0.742-0.74^{2} without parentheses, which the calculator reads as −(0.742)=−0.5476-(0.74^{2})=-0.5476; a coefficient of determination is never negative.

f)

b=SxySxx=4518=2.5b=\frac{S_{xy}}{S_{xx}}=\frac{45}{18}=2.5. Pitfall: dividing by SyyS_{yy} or by SxxSyy\sqrt{S_{xx}S_{yy}}, which is the denominator of rr, not that of the slope.

g)

a=y‾−bx‾=40−(−1.6)(12)=40+19.2=59.2a=\overline{y}-b\overline{x}=40-(-1.6)(12)=40+19.2=59.2. Pitfall: losing the double minus sign and writing 40−19.2=20.840-19.2=20.8.

h)

y^=14.2+3.5×7.4=14.2+25.9=40.1\hat{y}=14.2+3.5\times 7.4=14.2+25.9=40.1.

i)

y^(15)=88−2.4×15=88−36=52\hat{y}(15)=88-2.4\times 15=88-36=52, so e=y−y^=49−52=−3e=y-\hat{y}=49-52=-3: the point lies below the line. Pitfall: computing y^−y=+3\hat{y}-y=+3, the residual the wrong way round.

j)

Sxy=186−15×555=186−165=21S_{xy}=186-\frac{15\times 55}{5}=186-165=21 and Sxx=55−1525=55−45=10S_{xx}=55-\frac{15^{2}}{5}=55-45=10, so b=2110=2.1b=\frac{21}{10}=2.1. The means are x‾=155=3\overline{x}=\frac{15}{5}=3 and y‾=555=11\overline{y}=\frac{55}{5}=11, so a=11−2.1×3=11−6.3=4.7a=11-2.1\times 3=11-6.3=4.7: the line is y^=4.7+2.1x\hat{y}=4.7+2.1x.

Check: SxxS_{xx} and SyyS_{yy} are always positive and rr always stays between −1-1 and 11; a value outside these bounds signals a sum copied wrongly or a misplaced square. The line always passes through the mean point: in j), 4.7+2.1×3=11=y‾4.7+2.1\times 3=11=\overline{y}.

Tick the exercises you have done or want to review: a free account, no password, keeps your ticks and your right answers from one visit to the next, tells you which chapter to tackle next and lets you ask for the exercise you are missing. Create your space, an email is enough.

Part A: scatter plot, correlation and the line (/50)

Exercise 1: The scatter plot and the correlation coefficient

Before any formula, look at the scatter plot. The correlation coefficient measures ONLY the strength of a LINEAR relationship, and it can be misleading if that assumption has not been checked.

A study relates the number of hours of study per week xx to the grade obtained yy for six students: (2,35)(2, 35), (4,48)(4, 48), (5,52)(5, 52), (7,68)(7, 68), (9,80)(9, 80), (11,95)(11, 95).

24681012102030405060708090100hours of studygrade
  • a) Describe the scatter plot: direction, form, apparent strength of the relationship.
  • b) Compute ∑x\sum x, ∑y\sum y, ∑xy\sum xy, ∑x2\sum x^{2} and ∑y2\sum y^{2}.
  • c) Compute SxyS_{xy}, SxxS_{xx} and SyyS_{yy}.
  • d) Compute the correlation coefficient and interpret it.
  • e) Does a correlation coefficient close to zero mean that there is no relationship at all between the two variables?

Type your answers, the page tells you right or wrong 0/13

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Increasing scatter plot, aligned, with no curvature and no outlier: the relationship looks linear and very strong.
  • b) ∑x=38\sum x=38, ∑y=378\sum y=378, ∑xy=2763\sum xy=2763, ∑x2=296\sum x^{2}=296, ∑y2=26 282\sum y^{2}=26\,282.
  • c) Sxy=369S_{xy}=369, Sxx=55.333S_{xx}=55.333, Syy=2468S_{yy}=2468.
  • d) r=369369.54=0.9985r=\dfrac{369}{369.54}=0.9985: an almost perfect positive linear relationship.
  • e) No: r≈0r\approx 0 only rules out a LINEAR relationship. A symmetric parabola gives r=0r=0 with yy completely determined by xx.
a)

The scatter plot is clearly INCREASING: the grades go up with the number of hours of study. The points lie very close to a line, with no visible curvature and no outlier: the relationship is linear and appears very strong. This preliminary reading is essential, because it is what justifies using the linear correlation coefficient.

b)

∑x=2+4+5+7+9+11=38\sum x=2+4+5+7+9+11=38. ∑y=35+48+52+68+80+95=378\sum y=35+48+52+68+80+95=378. ∑xy=70+192+260+476+720+1045=2763\sum xy=70+192+260+476+720+1045=2763. ∑x2=4+16+25+49+81+121=296\sum x^{2}=4+16+25+49+81+121=296. ∑y2=1225+2304+2704+4624+6400+9025=26 282\sum y^{2}=1225+2304+2704+4624+6400+9025=26\,282.

c)

Sxy=2763−38×3786=2763−2394=369S_{xy}=2763-\dfrac{38\times 378}{6}=2763-2394=369. Sxx=296−3826=296−240.667=55.333S_{xx}=296-\dfrac{38^{2}}{6}=296-240.667=55.333. Syy=26 282−37826=26 282−23 814=2468S_{yy}=26\,282-\dfrac{378^{2}}{6}=26\,282-23\,814=2468.

d)

r=SxySxxSyy=36955.333×2468=369369.54=0.9985r=\dfrac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}=\dfrac{369}{\sqrt{55.333\times 2468}}=\dfrac{369}{369.54}=0.9985. The correlation is POSITIVE, so the two variables move in the same direction, and its absolute value is extremely close to 1: the linear relationship is almost perfect. Such a coefficient is rare on real data; here it points to constructed data or to a very regular phenomenon.

e)

NO, and this is the classic trap. An rr close to zero only means that there is no LINEAR relationship. There may very well be a strong but curved relationship: on a scatter plot shaped like a symmetric parabola, for example y=x2y=x^{2} with xx values spread symmetrically around zero, the coefficient is exactly 0 even though yy is completely determined by xx. That is precisely why you DRAW the scatter plot before computing: the coefficient alone cannot tell “no relationship” apart from “a nonlinear relationship”.

Exercise 2: The least-squares line

Of all possible lines, only one minimizes the sum of the squares of the vertical deviations. Its two coefficients are computed from the same working sums.

Use the data of exercise 1 again: Sxy=369S_{xy}=369, Sxx=55.333S_{xx}=55.333, x‾=6.333\overline{x}=6.333 and y‾=63.0\overline{y}=63.0.

The graph below shows the data.

24681012102030405060708090100hours of studygrade
  • a) Compute the slope, then the intercept, and write the equation of the line.
  • b) Interpret the slope and the intercept in context, stating whether the intercept makes sense here.
  • c) Check that the line passes through the mean point.
  • d) What exactly does “least squares” mean? Why minimize the squares rather than the deviations themselves?
  • e) Compute the residual of the student who studied 5 hours and obtained 52. What does its sign mean?

Type your answers, the page tells you right or wrong 0/12

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) b=6.669b=6.669 and a=20.765a=20.765, so y=20.77+6.67xy=20.77+6.67x.
  • b) One more hour of study is worth 6.67 points on average. The intercept, 20.77, is an extrapolation at x=0x=0.
  • c) 20.765+6.669(6.333)=63.0=y‾20.765+6.669(6.333)=63.0=\overline{y}: the line passes through the mean point, by construction.
  • d) What is minimized is ∑(yi−y^i)2\sum(y_{i}-\hat{y}_{i})^{2}. The raw deviations cancel out for infinitely many lines.
  • e) y^(5)=54.11\hat{y}(5)=54.11 and e=−2.11e=-2.11: the student is below the line, and it is the largest residual of the six.
a)

b=SxySxx=36955.333=6.669b=\dfrac{S_{xy}}{S_{xx}}=\dfrac{369}{55.333}=6.669. Then a=y‾−bx‾=63.0−6.669×6.333=63.0−42.235=20.765a=\overline{y}-b\overline{x}=63.0-6.669\times 6.333=63.0-42.235=20.765. The equation is therefore y=20.77+6.67xy=20.77+6.67x.

b)

The SLOPE means that one extra hour of study per week is associated with an average increase of 6.67 points in the grade. The INTERCEPT, 20.77, would be the grade of a student who studies zero hours. Handle this number with care: x=0x=0 lies outside the observed range, which runs from 2 to 11 hours, so it is an extrapolation. It may be read as a plausible order of magnitude, but the model does not guarantee it.

c)

The mean point is (6.333,63.0)\left(6.333, 63.0\right). Substituting into the equation: 20.765+6.669×6.333=20.765+42.235=63.020.765+6.669\times 6.333=20.765+42.235=63.0. The line does pass through the mean point, and this is no coincidence: it follows directly from the formula a=y‾−bx‾a=\overline{y}-b\overline{x}, which is built to make it happen. It is a quick check to make systematically on every regression.

d)

“Least squares” means that the line chosen is the one that makes the sum ∑(yi−y^i)2\sum\left(y_{i}-\hat{y}_{i}\right)^{2} as SMALL as possible, where y^i\hat{y}_{i} is the predicted value. The raw deviations are not minimized because their sum is ZERO for infinitely many lines, the positive deviations cancelling the negative ones: the criterion would select nothing. Squaring prevents this cancelling, penalizes large deviations more than small ones, and leads to simple explicit formulas, which is not the case if you minimize the absolute values.

e)

The predicted value for x=5x=5 is y^=20.765+6.669×5=54.11\hat{y}=20.765+6.669\times 5=54.11. The residual is y−y^=52−54.11=−2.11y-\hat{y}=52-54.11=-2.11. Its NEGATIVE sign means that this student obtained a grade LOWER than the one the model predicted for that amount of study: the point lies below the line. It is in fact the largest residual in absolute value of the six, hence the worst-fitted point of the scatter plot.

24681012102030405060708090100mean pointe = −2.11ŷ = 20.77 + 6.67xhours of studygrade

Exercise 3: The coefficient of determination and prediction

The square of the correlation coefficient is read directly as a percentage: the share of the variation in yy that the model explains. It is the indicator quoted to judge the quality of a fit.

Keep r=0.9985r=0.9985 and the line y=20.77+6.67xy=20.77+6.67x, valid for xx between 2 and 11 hours.

The graph below shows the data.

24681012102030405060708090100hours of studygrade
  • a) Compute the coefficient of determination and state its interpretation.
  • b) What does the remaining 0.3% represent?
  • c) Predict the grade of a student who studies 8 hours a week.
  • d) Predict the grade of a student who studies 20 hours. Is this prediction legitimate?
  • e) What would the prediction be for 30 hours? What does this result reveal about the limits of the model?

Type your answers, the page tells you right or wrong 0/9

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) r2=0.9971r^{2}=0.9971: 99.7% of the variation in the grades is explained by study time.
  • b) The residual variation: aptitude, quality of studying, form on the day, luck of the questions, measurement errors.
  • c) y^(8)=74.1\hat{y}(8)=74.1. A legitimate interpolation, since 8 lies between 2 and 11.
  • d) y^(20)=154.1\hat{y}(20)=154.1, impossible: it is an extrapolation outside the observed range.
  • e) y^(30)=220.8\hat{y}(30)=220.8. The absurdity makes the error visible; the danger is an extrapolation that produces a plausible number.
a)

r2=0.99852=0.9971r^{2}=0.9985^{2}=0.9971, that is, 99.7%. Interpretation: 99.7% of the observed variation in the grades is EXPLAINED by the linear relationship with the number of hours of study. This is an exceptionally good fit.

b)

The remaining 0.3% is the RESIDUAL variation, that is, everything study time does not account for: individual aptitude, the quality of the studying and not just its length, how the student feels on exam day, the luck of the questions chosen, as well as measurement errors. No statistical model claims to explain 100% of a human phenomenon, and an r2r^{2} of 1.000 on real data would in fact be suspicious.

c)

y^=20.765+6.669×8=20.765+53.35=74.1\hat{y}=20.765+6.669\times 8=20.765+53.35=74.1. The prediction is about 74. It is LEGITIMATE because 8 hours lies inside the range of the observed data, between 2 and 11: this is an interpolation.

d)

y^=20.765+6.669×20=20.765+133.37=154.1\hat{y}=20.765+6.669\times 20=20.765+133.37=154.1. The prediction exceeds 100: it is IMPOSSIBLE, since the grade cannot go above 100. The prediction is therefore not legitimate, and for a fundamental reason: x=20x=20 is far beyond the observed range, so we are EXTRAPOLATING. Nothing in the data guarantees that the relationship stays linear beyond 11 hours; in reality it necessarily levels off.

e)

y^=20.765+6.669×30=220.8\hat{y}=20.765+6.669\times 30=220.8, more than twice the maximum possible. The absurdity of the result is actually good news here: it makes the error VISIBLE. The real danger of extrapolation is the case where it produces a plausible number that nothing flags as wrong. The rule is therefore never to predict outside the range of the observed xx values, and always to state that range of validity next to the equation. A linear model is only a LOCAL approximation of a relationship that, in reality, almost always saturates.

Exercise 4: Outliers and leverage points

Take the six students again, relating hours of study xx to grade yy: (2,35)(2, 35), (4,48)(4, 48), (5,52)(5, 52), (7,68)(7, 68), (9,80)(9, 80), (11,95)(11, 95), for which r≈0.9985r\approx 0.9985 and the line is y=20.77+6.669xy=20.77+6.669x. Add a seventh student to them, one at a time, and observe the damage.

The graph below shows the data.

24681012141618202220406080100(5, 90)(20, 100)hours of studygrade
  • a) A seventh student studied 5 hours and obtained 90. Recompute x‾\overline{x}, y‾\overline{y}, then SxyS_{xy}, SxxS_{xx}, SyyS_{yy} and the correlation coefficient.
  • b) Compute the new coefficient of determination and compare it with the old one. Comment on how large the effect of a single point out of seven is.
  • c) Replace this seventh student by another one, who studied 20 hours and obtained 100. Recompute the slope and the correlation coefficient. Compare with case a).
  • d) The influence a point exerts on the line is called its LEVERAGE, and it grows with the distance between its xx and the mean of the xx values. Justify this fact from the formula for the slope, and say which of the two added points is the more dangerous.
  • e) In practice, what should be done about a point that distorts the analysis in this way?

Type your answers, the page tells you right or wrong 0/14

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) With (5,90)(5, 90): x‾=6.143\overline{x}=6.143, y‾=66.86\overline{y}=66.86, Sxy=338.1S_{xy}=338.1, Sxx=56.86S_{xx}=56.86, Syy=3092.9S_{yy}=3092.9, r=0.806r=0.806.
  • b) r2r^{2} falls from 0.997 to 0.650: one point out of seven has destroyed most of the relationship.
  • c) With (20,100)(20, 100): b=3.72b=3.72 and r=0.906r=0.906. The slope is almost halved without rr raising any alarm.
  • d) In b=∑(xi−x‾)(yi−y‾)∑(xi−x‾)2b=\dfrac{\sum(x_{i}-\overline{x})(y_{i}-\overline{y})}{\sum(x_{i}-\overline{x})^{2}}, a distant xx weighs enormously. The point (20, 100) is the more dangerous.
  • e) Investigate, then publish both analyses, then consider a robust method. Never delete a point because it is inconvenient.
a)

With the point (5,90)(5, 90): n=7n=7, ∑x=43\sum x=43, ∑y=468\sum y=468, ∑xy=3213\sum xy=3213, ∑x2=321\sum x^{2}=321, ∑y2=34 382\sum y^{2}=34\,382. So x‾≈6.143\overline{x}\approx 6.143 and y‾≈66.86\overline{y}\approx 66.86. Working sums: Sxy=3213−(43)(468)7≈338.1S_{xy}=3213-\frac{(43)(468)}{7}\approx 338.1, Sxx=321−4327≈56.86S_{xx}=321-\frac{43^{2}}{7}\approx 56.86, Syy=34 382−46827≈3092.9S_{yy}=34\,382-\frac{468^{2}}{7}\approx 3092.9. Coefficient: r=338.1(56.86)(3092.9)≈0.806r=\frac{338.1}{\sqrt{(56.86)(3092.9)}}\approx 0.806.

b)

r2r^{2} goes from 0.9970.997 to 0.6500.650: the proportion of variation explained collapses from 99.7% to 65%. One point out of seven, that is 14% of the data, has destroyed most of the relationship. This is the most useful reminder of the chapter: the correlation coefficient is not a robust measure, it is extremely sensitive to extreme values, and reporting it without having looked at the scatter plot amounts to betting blindfolded.

c)

With (20,100)(20, 100): ∑x=58\sum x=58, ∑y=478\sum y=478, ∑xy=4763\sum xy=4763, ∑x2=696\sum x^{2}=696, ∑y2=36 282\sum y^{2}=36\,282. This gives Sxy≈802.4S_{xy}\approx 802.4, Sxx≈215.4S_{xx}\approx 215.4 and Syy≈3641.4S_{yy}\approx 3641.4, hence a slope b=802.4215.4≈3.72b=\frac{802.4}{215.4}\approx 3.72 and r≈0.906r\approx 0.906. The contrast with a) is instructive: here the coefficient stays high, apparently reassuring, while the SLOPE has almost been halved, going from 6.67 to 3.72. The model now predicts that one extra hour of study brings only 3.7 points instead of 6.7: the practical conclusion is turned upside down without rr sounding the alarm.

d)

The slope is b=SxySxx=∑(xi−x‾)(yi−y‾)∑(xi−x‾)2b=\frac{S_{xy}}{S_{xx}}=\frac{\sum(x_{i}-\overline{x})(y_{i}-\overline{y})}{\sum(x_{i}-\overline{x})^{2}}. Each point enters through its deviation xi−x‾x_{i}-\overline{x}, and a point very far away in xx contributes a huge term to the numerator as well as to the denominator: it weighs much more heavily than the others in determining the line. A point far away in xx literally acts as a LEVER, with the mean point as the pivot. So it is the second point, (20,100)(20, 100), that is the more dangerous: the first one visibly lowers the coefficient and alerts the analyst, while the second moves the line silently, leaving an rr of 0.906 that would go unquestioned in any report.

e)

Above all, do not delete it because it is inconvenient. The correct approach has three stages. First INVESTIGATE: is it a data-entry error, a badly converted unit, an individual who does not belong to the population under study? A value that is demonstrably wrong is corrected or set aside, with a written justification. Next, if the point is genuine, PUBLISH both analyses, with and without it, and let the reader judge its impact: this is standard practice in research. Finally, consider a ROBUST method, less sensitive to extremes than least squares, or a transformation that brings the xx values closer together. An outlier is often the richest observation in the data set: it signals a measurement error, a heterogeneous population, or a phenomenon the model ignores.

24681012141618202220406080100120140slope 6.67: six pointsslope 5.95: with (5, 90)slope 3.72: with (20, 100)hours of studygrade

Exercise 5: Correlation and causation

This is the most important point of the chapter, and the only one you will keep meeting for the rest of your life. A correlation, however strong, never establishes on its own that one variable causes another.

In a large city, over twelve months, a correlation of r=0.95r=0.95 is observed between monthly ice cream sales and the number of drownings.

  • a) Can we conclude that eating ice cream increases the risk of drowning?
  • b) List the possible competing explanations for any observed correlation.
  • c) Identify the confounding variable in this example and explain how it works.
  • d) How could one, in principle, establish causation rather than a mere association?
  • e) A strong correlation is observed between the number of firefighters sent to a fire and the damage recorded. Analyse it.

Type your answers, the page tells you right or wrong 0/9

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) No: rr measures how the variables vary together, never the mechanism.
  • b) Four: xx causes yy; yy causes xx; a third variable causes both; or chance.
  • c) Temperature. Heat sells ice cream AND sends people swimming: both series follow the same cause.
  • d) A controlled experiment with random assignment, which balances even the unknown confounders. Failing that, control the known variables statistically.
  • e) The confounder is the size of the fire. Causation runs from the seriousness of the fire to the dispatch of firefighters, and the real effect of the firefighters is to REDUCE the damage.
a)

NO. The coefficient only measures how closely the two series vary together; it contains no information about the mechanism linking them. Inferring causation from a high rr is a reasoning error, whatever the value of the coefficient.

b)

Four explanations compete, and the data alone cannot decide between them. First, xx causes yy. Second, yy causes xx, that is, reverse causation. Third, a THIRD VARIABLE, called a confounding variable, causes both at the same time. Fourth, it may be a coincidence due to sampling chance, all the more plausible when the sample is small or when a large number of series have been compared until two were found that match.

c)

The confounding variable is TEMPERATURE, or more broadly the season. When it is hot, people buy more ice cream; and when it is hot, they swim more, which mechanically increases the number of occasions for drowning. The two series rise and fall together over the year because both are driven by the same cause, without any direct link between them. Removing all ice cream from the city would change nothing in the number of drownings.

d)

Through a CONTROLLED EXPERIMENT with RANDOM assignment: subjects are allocated at random to an exposed group and a control group, then the groups are compared. Randomization guarantees that the two groups differ, on average, only in the factor manipulated, including for the confounding variables nobody has identified, and that is its decisive advantage. When the experiment is impossible or unethical, as here, one falls back on observational studies in which the known variables are CONTROLLED statistically, for example by examining the correlation at constant temperature, which in our case would vanish.

e)

The analysis is of the same kind, but with an instructive twist. It would be absurd to conclude that the firefighters cause the damage. The confounding variable here is the INITIAL SIZE of the fire: a big fire causes both the dispatch of many firefighters and heavy damage. One can even add that there is indeed a causal link, but in the OPPOSITE direction to the naive reading: it is the seriousness of the fire that causes the firefighters to be sent. And the real effect of the firefighters on the damage is surely to REDUCE it, an effect the raw correlation completely hides. This is the textbook example of a positive correlation coexisting with a negative causal effect.

Part B: exam level (/50)

Exercise 6: A complete regression on real data

A synthesis exercise: carry out a regression from start to finish and write up its interpretation, limits included.

A study relates the floor area of an apartment, in square metres, to its monthly rent in Montreal, in dollars. For 8 apartments, the results are n=8n=8, ∑x=440\sum x=440, ∑y=10 400\sum y=10\,400, ∑xy=608 000\sum xy=608\,000, ∑x2=25 800\sum x^{2}=25\,800 and ∑y2=14 000 000\sum y^{2}=14\,000\,000.

  • a) Compute the means, then SxyS_{xy}, SxxS_{xx} and SyyS_{yy}.
  • b) Compute the correlation coefficient, then CHECK that it is valid before interpreting it. What do you conclude?
  • c) Find the equation of the regression line.
  • d) Interpret the slope in context, with its units.
  • e) Estimate the rent of a 70 m² apartment, then write the limits of your estimate in two sentences.

Type your answers, the page tells you right or wrong 0/15

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) x‾=55.0\overline{x}=55.0 m², y‾=1300\overline{y}=1300 dollars, Sxy=36 000S_{xy}=36\,000, Sxx=1600S_{xx}=1600, Syy=480 000S_{yy}=480\,000.
  • b) r=1.299r=1.299, impossible: the sums given are incompatible. The check ∣r∣≤1|r|\leq 1 is made systematically.
  • c) b=22.5b=22.5 and a=62.5a=62.5, so y=62.5+22.5xy=62.5+22.5x.
  • d) 22.50 dollars of rent per square metre. The intercept has no concrete meaning.
  • e) y^(70)=1637.50\hat{y}(70)=1637.50 dollars. Eight apartments and inconsistent sums on one side; neighbourhood, condition and floor left out of the model on the other.
a)

x‾=4408=55.0\overline{x}=\dfrac{440}{8}=55.0 m² and y‾=10 4008=1300\overline{y}=\dfrac{10\,400}{8}=1300 dollars. Next Sxy=608 000−440×10 4008=608 000−572 000=36 000S_{xy}=608\,000-\dfrac{440\times 10\,400}{8}=608\,000-572\,000=36\,000. Sxx=25 800−44028=25 800−24 200=1600S_{xx}=25\,800-\dfrac{440^{2}}{8}=25\,800-24\,200=1600. Syy=14 000 000−10 40028=14 000 000−13 520 000=480 000S_{yy}=14\,000\,000-\dfrac{10\,400^{2}}{8}=14\,000\,000-13\,520\,000=480\,000.

b)

r=36 0001600×480 000=36 000768 000 000=36 00027 713=1.299r=\dfrac{36\,000}{\sqrt{1600\times 480\,000}}=\dfrac{36\,000}{\sqrt{768\,000\,000}}=\dfrac{36\,000}{27\,713}=1.299... which is IMPOSSIBLE, since a correlation coefficient can never exceed 1. Such a result necessarily signals an error in the calculation or in the data. Going over it again: 1600×480 000=7.68×108=27 713\sqrt{1600\times 480\,000}=\sqrt{7.68\times 10^{8}}=27\,713, and 36 00027 713=1.299\dfrac{36\,000}{27\,713}=1.299. The sums given are therefore mutually incompatible, and the right reflex on an exam is to POINT THIS OUT rather than carry on. This check, ∣r∣≤1\left|r\right|\leq 1, must be made systematically: it catches the vast majority of data-entry errors in the working sums.

c)

The line can nevertheless be computed, since it depends only on SxyS_{xy} and SxxS_{xx}: b=36 0001600=22.5b=\dfrac{36\,000}{1600}=22.5 and a=1300−22.5×55.0=1300−1237.5=62.5a=1300-22.5\times 55.0=1300-1237.5=62.5. The equation is y=62.5+22.5xy=62.5+22.5x. These two coefficients are consistent and plausible, which points to SyyS_{yy}, hence to ∑y2\sum y^{2}, as the source of the inconsistency.

d)

The slope is 22.5 dollars per square metre: each additional square metre is associated with an average increase in rent of 22.50 dollars a month. The intercept, 62.50 dollars, would be the rent of an apartment with zero floor area: it obviously has no concrete meaning and must certainly not be interpreted. It is only a fitting parameter, needed so that the line passes through the mean point.

e)

y^=62.5+22.5×70=62.5+1575=1637.50\hat{y}=62.5+22.5\times 70=62.5+1575=1637.50 dollars. Limits: on the one hand, this estimate rests on only 8 apartments and on sums shown to be inconsistent, which rules out any quantitative confidence until the data have been checked; on the other hand, floor area explains only part of the rent, which also depends on the neighbourhood, the condition, the floor and the year, so that a point prediction without a confidence interval gives a false impression of precision.

Exercise 7: Residual analysis: what the coefficient does not show

Go back to the six original students, (2,35)(2, 35), (4,48)(4, 48), (5,52)(5, 52), (7,68)(7, 68), (9,80)(9, 80), (11,95)(11, 95), and to their least-squares line y^=20.765+6.6687x\hat{y}=20.765+6.6687x. A residual is the vertical deviation ei=yi−yi^e_{i}=y_{i}-\hat{y_{i}} between the data value and the prediction.

The graph below shows the data.

24681012102030405060708090100hours of studygrade
  • a) Compute the six predicted values and the six residuals. What is their sum?
  • b) Prove that the sum of the residuals is necessarily zero for a least-squares line. Does this property make it possible to judge the QUALITY of the model?
  • c) The residuals are plotted against xx. Describe what a satisfactory residual plot looks like, then the three classic anomalies one looks for and what each one reveals.
  • d) Compute the standard error of the estimate se=∑ei2n−2s_{e}=\sqrt{\frac{\sum e_{i}^{2}}{n-2}} and interpret it. Check the relation ∑ei2=Syy(1−r2)\sum e_{i}^{2}=S_{yy}(1-r^{2}), given that Syy=2468S_{yy}=2468 and r2=0.99706r^{2}=0.99706.
  • e) A study reports r=0.82r=0.82, but its residual plot clearly forms a U. What do you conclude, and what should be done?

Type your answers, the page tells you right or wrong 0/15

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Predictions 34.1034.10, 47.4447.44, 54.1154.11, 67.4567.45, 80.7880.78, 94.1294.12. Residuals +0.90+0.90, +0.56+0.56, −2.11-2.11, +0.55+0.55, −0.78-0.78, +0.88+0.88, with a sum of zero.
  • b) ∑ei=n(y‾−a−bx‾)=0\sum e_{i}=n(\overline{y}-a-b\overline{x})=0 by construction: no information about the quality of the model.
  • c) A good plot has no structure. Three anomalies: U-shaped curvature (nonlinearity), funnel (heteroscedasticity), isolated point (outlier or leverage).
  • d) ∑ei2≈7.26\sum e_{i}^{2}\approx 7.26, se=1.815≈1.35s_{e}=\sqrt{1.815}\approx 1.35 points, and Syy(1−r2)≈7.26S_{yy}(1-r^{2})\approx 7.26: identical.
  • e) The relationship is not linear despite r=0.82r=0.82. Switch to a quadratic model or linearize, then check the residuals again.
a)

Predicted values: y^(2)=34.10\hat{y}(2)=34.10, y^(4)=47.44\hat{y}(4)=47.44, y^(5)=54.11\hat{y}(5)=54.11, y^(7)=67.45\hat{y}(7)=67.45, y^(9)=80.78\hat{y}(9)=80.78 and y^(11)=94.12\hat{y}(11)=94.12. Corresponding residuals: +0.90+0.90, +0.56+0.56, −2.11-2.11, +0.55+0.55, −0.78-0.78 and +0.88+0.88. Their sum is 0, up to rounding.

b)

The least-squares line always passes through the mean point: y‾=a+bx‾\overline{y}=a+b\overline{x}. Now ∑ei=∑(yi−a−bxi)=∑yi−na−b∑xi=ny‾−na−nbx‾=n(y‾−a−bx‾)=0\sum e_{i}=\sum(y_{i}-a-bx_{i})=\sum y_{i}-na-b\sum x_{i}=n\overline{y}-na-nb\overline{x}=n(\overline{y}-a-b\overline{x})=0. The sum is therefore zero by CONSTRUCTION, whatever the data, even absurd ones. It says strictly nothing about the quality of the model: it is a check on the calculation, not a diagnosis. To measure the fit, you must look at the sum of the SQUARES of the residuals, which does not vanish.

c)

A satisfactory residual plot shows NO structure: a horizontal cloud, scattered at random on both sides of zero, of constant thickness, with no trend and no pattern. Any visible shape is a defect of the model. First anomaly, a U-shaped or bell-shaped CURVATURE: the relationship is not linear, and the line passes systematically above and then below the points. Second anomaly, a FUNNEL that widens: the spread increases with xx, which is called heteroscedasticity; the line remains acceptable but the prediction intervals are worthless, because they assume a constant spread. Third anomaly, an ISOLATED point very far from the others: an outlier or a leverage point, whose influence must be examined separately.

d)

∑ei2≈(0.90)2+(0.56)2+(2.11)2+(0.55)2+(0.78)2+(0.88)2≈7.26\sum e_{i}^{2}\approx(0.90)^{2}+(0.56)^{2}+(2.11)^{2}+(0.55)^{2}+(0.78)^{2}+(0.88)^{2}\approx 7.26. So se=7.266−2=1.815≈1.35s_{e}=\sqrt{\frac{7.26}{6-2}}=\sqrt{1.815}\approx 1.35 points. Interpretation: the actual grades typically deviate from the line by about 1.3 points, which gives the order of magnitude of the error to expect from a prediction. We divide by n−2n-2 and not by nn because two parameters, the slope and the intercept, have already been estimated from these same data. Check: Syy(1−r2)=(2468)(1−0.99706)=(2468)(0.00294)≈7.26S_{yy}(1-r^{2})=(2468)(1-0.99706)=(2468)(0.00294)\approx 7.26, identical. This relation also sheds light on the meaning of r2r^{2}: it is exactly the share of SyyS_{yy} that the line has managed to absorb.

e)

An rr of 0.82 looks excellent, but the U in the residual plot proves that the relationship is NOT linear: the line underestimates at both ends and overestimates in the middle, or the reverse, and this error is systematic, not random. A high correlation coefficient never guarantees linearity; it only measures how well a LINE fits, even when a curve would fit far better. Predictions made with this model will be biased in a predictable way, which is the worst of defects. The linear model must therefore be dropped in favour of a quadratic model, or the data linearized by a transformation, logarithm, square root or reciprocal, depending on the shape observed, then you check that the new residual plot no longer shows anything.

24681012-3-2-112residual

Exercise 8: Linearizing: when the relationship is not a straight line

A bacterial culture is counted every hour. At t=0t=0, 1, 2, 3 and 4 hours, the counts are 50, 82, 135, 220 and 361 thousand cells respectively. Exponential growth is suspected, N=N0ektN=N_{0}e^{kt}.

The graph below shows the data.

1234550100150200250300350400t (h)N (thousands)
  • a) Someone computes the correlation coefficient between tt and NN without thinking, and finds r≈0.962r\approx 0.962. Why is this figure misleading? What would the residual plot show?
  • b) Compute ln⁡N\ln N at each time and examine the successive differences. What do they confirm?
  • c) Carry out the regression of ln⁡N\ln N on tt: give the slope and the intercept, then work back to kk and N0N_{0} and write the model.
  • d) Compute the doubling time of the population, then predict the count at t=6t=6 hours.
  • e) Another study relates the orbital period of a planet to its distance from the Sun, using a model of the form y=axby=ax^{b}. Which transformation must then be applied, and how are aa and bb read from the resulting line?

Type your answers, the page tells you right or wrong 0/16

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) rr measures how well a line fits; it assumes linearity. The residuals would form a clear U.
  • b) 3.9123.912, 4.4074.407, 4.9054.905, 5.3945.394, 5.8895.889: differences 0.4950.495, 0.4990.499, 0.4880.488, 0.4950.495, hence multiplication by a constant factor.
  • c) Slope k≈0.494k\approx 0.494 h−1^{-1}, intercept ln⁡N0≈3.913\ln N_{0}\approx 3.913, so N0≈50.1N_{0}\approx 50.1 and N≈50.1 e0.494tN\approx 50.1\,e^{0.494t}.
  • d) t=ln⁡2k≈1.40t=\dfrac{\ln 2}{k}\approx 1.40 h, and N(6)≈970N(6)\approx 970 thousand cells, outside the observed range.
  • e) Log-log: ln⁡y=ln⁡a+bln⁡x\ln y=\ln a+b\ln x. The slope gives bb, the intercept gives ln⁡a\ln a. For the planets, the slope is 1.5, which is Kepler's third law.
a)

An rr of 0.962 looks excellent, but it only measures how well a LINE fits. Yet the population more than septuples in four hours, and it accelerates: the scatter plot clearly curves upwards. A line can roughly follow an increasing curve and earn a high coefficient while being systematically wrong. The residual plot would show it at once, forming a very clear U: the line would pass below the points at both ends and above them in the middle. The correlation coefficient never tests linearity, it ASSUMES it.

b)

ln⁡50≈3.912\ln 50\approx 3.912, ln⁡82≈4.407\ln 82\approx 4.407, ln⁡135≈4.905\ln 135\approx 4.905, ln⁡220≈5.394\ln 220\approx 5.394, ln⁡361≈5.889\ln 361\approx 5.889. Successive differences: 0.4950.495, 0.4990.499, 0.4880.488 and 0.4950.495, remarkably constant. Now a constant increase in the logarithm every hour means a MULTIPLICATION by a constant factor every hour, which is the very definition of exponential growth. The model is therefore confirmed, and on a semi-logarithmic scale the five points line up.

c)

With ∑t=10\sum t=10, ∑ln⁡N≈24.507\sum\ln N\approx 24.507, ∑tln⁡N≈53.954\sum t\ln N\approx 53.954 and ∑t2=30\sum t^{2}=30: Stt=30−1005=10S_{tt}=30-\frac{100}{5}=10 and St,ln⁡N=53.954−(10)(24.507)5≈4.941S_{t,\ln N}=53.954-\frac{(10)(24.507)}{5}\approx 4.941. Slope: 4.94110≈0.494\frac{4.941}{10}\approx 0.494; intercept: 24.5075−(0.494)(2)≈3.913\frac{24.507}{5}-(0.494)(2)\approx 3.913. Taking the logarithm of the model, ln⁡N=ln⁡N0+kt\ln N=\ln N_{0}+kt: the slope IS k≈0.494k\approx 0.494 h−1^{-1} and the intercept is ln⁡N0\ln N_{0}, so N0=e3.913≈50.1N_{0}=e^{3.913}\approx 50.1 thousand. Model: N≈50.1 e0.494tN\approx 50.1\,e^{0.494t}. The correlation coefficient on the transformed data exceeds 0.9999.

d)

Doubling time: we want tt such that ekt=2e^{kt}=2, that is, t=ln⁡2k=0.6930.494≈1.40t=\frac{\ln 2}{k}=\frac{0.693}{0.494}\approx 1.40 h, about 1 h 24 min, which is consistent with the data since the population goes from 50 to about 100 in a little under an hour and a half. Prediction at t=6t=6 h: N=50.1 e(0.494)(6)=50.1 e2.964≈9.7×102N=50.1\,e^{(0.494)(6)}=50.1\,e^{2.964}\approx 9.7\times 10^{2} thousand cells. Caution, however: t=6t=6 lies outside the observed range, and a real culture eventually saturates when nutrients run out. The exponential model is almost always valid at the start and wrong at the end.

e)

For y=axby=ax^{b}, take the logarithm of BOTH variables: ln⁡y=ln⁡a+bln⁡x\ln y=\ln a+b\ln x. So regress ln⁡y\ln y on ln⁡x\ln x, on a log-log scale. The SLOPE of the resulting line gives the exponent bb directly, and its intercept gives ln⁡a\ln a, hence a=eintercepta=e^{\text{intercept}}. Remember the distinction: an EXPONENTIAL model is linearized on a semi-log scale, by transforming only yy; a POWER model is linearized on a log-log scale, by transforming both. For the planets, the slope would come out very close to 1.5, which gives back Kepler's third law, T2∝d3T^{2}\propto d^{3}.

12345-5050100150200250300350400line: r ≈ 0.962t (h)N (thousands)
NN against tt: the points curve upwards, and the line passes below them at both ends and above them in the middle despite r≈0.962r\approx 0.962.
123453.544.555.566.5ln N ≈ 3.913 + 0.494tt (h)ln N
ln⁡N\ln N against tt: the five points line up, slope k≈0.494k\approx 0.494, intercept ln⁡N0≈3.913\ln N_{0}\approx 3.913.

Exercise 9: The significance test for the correlation coefficient

Even with no real relationship at all, a few points drawn at random can display a high correlation coefficient. We therefore test H0:ρ=0H_{0}:\rho=0 against H1:ρ≠0H_{1}:\rho\neq 0 using t=rn−21−r2t=\frac{r\sqrt{n-2}}{\sqrt{1-r^{2}}}, on n−2n-2 degrees of freedom. Two-tailed critical values at the 5% level: 2.776 for 4 degrees of freedom, 2.306 for 8, 2.048 for 28 and 1.962 for 998.

  • a) Why must a correlation coefficient be tested? What exactly does ρ\rho mean, and how does it differ from rr?
  • b) For the six students, r=0.9985r=0.9985. Compute the test statistic and conclude at the 5% level.
  • c) A study of 10 individuals obtains r=0.50r=0.50. Compute tt and conclude. Does the result surprise you?
  • d) Another study obtains exactly the same r=0.50r=0.50, but for 30 individuals. Conclude, and explain how the same coefficient can lead to two opposite verdicts.
  • e) A survey of 1000 people finds r=0.070r=0.070. Test it, then compute r2r^{2}. What lesson do you draw, and which other chapter of the course does it remind you of?

Type your answers, the page tells you right or wrong 0/12

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) ρ\rho is the coefficient of the population, fixed and unknown; rr is only an estimate of it, which varies from one sample to another.
  • b) t≈36.5t\approx 36.5 against 2.776: reject H0H_{0} without hesitation.
  • c) t≈1.63t\approx 1.63 against 2.306: do not reject. With ten individuals, r=0.50r=0.50 proves nothing.
  • d) t≈3.06t\approx 3.06 against 2.048: reject. Significance measures how solid the evidence is, not the strength of the relationship.
  • e) t≈2.22>1.962t\approx 2.22>1.962: significant. But r2=0.0049r^{2}=0.0049, that is, 0.5% explained. Significant and important are independent.
a)

Because rr is computed on a SAMPLE and varies from one sample to another. The parameter ρ\rho is the correlation coefficient of the whole POPULATION, a fixed and unknown value; rr is only an estimate of it. With very few points, chance is enough to produce an impressive rr: three points drawn at random almost always line up fairly well. The test therefore answers the only question that matters: is the observed association stronger than what chance would commonly produce if the two variables really had no link at all?

b)

t=(0.9985)41−0.99852=1.9970.0029978=1.9970.05475≈36.5t=\frac{(0.9985)\sqrt{4}}{\sqrt{1-0.9985^{2}}}=\frac{1.997}{\sqrt{0.0029978}}=\frac{1.997}{0.05475}\approx 36.5. The critical value for 4 degrees of freedom is 2.776: the statistic exceeds it by a factor of thirteen. We reject H0H_{0} without hesitation; the correlation is highly significant despite having only six points, because it is almost perfect.

c)

t=(0.50)81−0.25=1.4140.866≈1.63t=\frac{(0.50)\sqrt{8}}{\sqrt{1-0.25}}=\frac{1.414}{0.866}\approx 1.63, to be compared with 2.306 for 8 degrees of freedom. We do NOT reject H0H_{0}: with ten individuals, a coefficient of 0.50 is entirely compatible with no relationship at all. The result often surprises, because an rr of 0.50 is instinctively judged “moderately strong”. It is not, here: on so few points it proves nothing at all, and announcing it as a discovery would be a mistake.

d)

t=(0.50)280.866=2.6460.866≈3.06t=\frac{(0.50)\sqrt{28}}{0.866}=\frac{2.646}{0.866}\approx 3.06, greater than the critical value 2.048 for 28 degrees of freedom: this time we REJECT H0H_{0}. The same coefficient therefore leads to two opposite conclusions, and there is no contradiction in that: significance does not measure the STRENGTH of the relationship, which rr already describes, but how solid the EVIDENCE is, which depends on the amount of information available. Thirty observations make improbable what ten made commonplace. All of inferential statistics lies in this distinction.

e)

t=(0.070)9981−0.0049=2.2110.9975≈2.22t=\frac{(0.070)\sqrt{998}}{\sqrt{1-0.0049}}=\frac{2.211}{0.9975}\approx 2.22, greater than 1.962: the coefficient is significantly different from zero at the 5% level. Yet r2=0.0049r^{2}=0.0049, barely 0.5% of the variation explained: next to nothing. The lesson is that statistical significance says only one thing, that the effect is probably not exactly zero, and that with a large enough sample absolutely any tiny effect ends up being significant. It says nothing about the IMPORTANCE of that effect, which only r2r^{2}, the slope and the context can judge. It is exactly the same lesson as in the chapter on hypothesis tests, where a gap of 0.5 g on 500 g bags became significant simply by increasing the sample size: significant and important are two independent notions.

Exercise 10: Problem: reading a study and spotting what is wrong

Five claims taken from newspaper articles, all based on a regression that was actually carried out. Each one contains a specific reasoning error, which you must name.

For each statement, identify the error and state the criticism in one or two sentences.

  • a) “Children who have more books at home do better at school; so books should be given to families.”
  • b) “The correlation between a country's chocolate consumption and its number of Nobel prizes per capita is 0.79: eating chocolate would make you smarter.”
  • c) “Our model has an r2r^{2} of 0.98, so it is reliable for predicting sales over the next ten years.”
  • d) “Among hospitalized patients, smoking is associated with better survival: tobacco would protect against the virus.”
  • e) “No correlation was found between the dose of the drug and the effect observed; the drug is therefore ineffective.”

Type your answers, the page tells you right or wrong 0/9

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Correlation taken for causation; the confounder is socio-economic background.
  • b) The same error, plus the ecological fallacy: the correlation is between countries, and the confounder is wealth.
  • c) Improper extrapolation: a high r2r^{2} describes the past within the observed range, not ten years ahead.
  • d) Selection bias, Berkson's paradox: the analysis is restricted to hospitalized patients.
  • e) No LINEAR correlation taken for no relationship. The scatter plot must be drawn and a nonlinear model considered.
a)

Correlation confused with causation, with an obvious confounding variable: the SOCIO-ECONOMIC BACKGROUND and the parents' level of education. These factors produce both the presence of books and success at school. Giving books to families who are otherwise unchanged would therefore not necessarily have the hoped-for effect, as several randomized trials have shown. The practical conclusion does not follow from the observation.

b)

The same error, on an even more problematic unit of analysis: the correlation is computed on COUNTRIES, not on individuals, which rules out any conclusion about individuals. This is the ecological fallacy. The confounding variable here is the WEALTH of the country, which determines both the consumption of luxury products and investment in research. On top of that comes a selection problem: this correlation is famous because it was searched for among hundreds of possible variables, which guarantees finding a few strong ones by pure chance.

c)

Improper extrapolation. A high r2r^{2} measures how well the model fits PAST data, within the observed range; it says nothing about its validity beyond. Predicting ten years ahead assumes that the relationship stays linear and that conditions do not change, assumptions that no historical data can guarantee. A model can have a perfect fit and zero predictive value outside its domain.

d)

SELECTION bias, because the analysis is restricted to HOSPITALIZED patients. To be hospitalized, a non-smoker generally has to be more seriously ill than a smoker, since smoking is often enough on its own to justify admission. The groups compared are therefore not comparable, and the association observed is an artifact of the selection criterion, not an effect of tobacco. This is Berkson's paradox, and it really did produce headlines of this kind.

e)

No LINEAR correlation confused with no relationship. A dose-response relationship is very often NONLINEAR: no effect below a threshold, rapid growth after it, then a plateau, or even toxicity that reverses the trend at high doses. On such a bell-shaped or S-shaped curve, the linear correlation coefficient can be close to zero while the relationship is strong and fully deterministic. The correct conclusion is that the scatter plot must be DRAWN and a nonlinear model considered, not that the drug is ineffective.

Something missing from this set? A type of exercise your teacher gives, a problem you are stuck on, a mistake you spotted: tell me, I read every request.

Sending goes through your free space: that is how I can answer you and tell you when the exercise is added. An email is enough, no password. Create your space. Rather not create an account? Write to me directly.

What is it about?
I read every request myself, nobody else sees it. No need to write your name or your school.
When your request is dealt with, you hear about it by email and in your space.

By sending, you agree that I read your request to answer it. It is kept with your account, erased with it, and never published: privacy policy.

Previous chapter Estimation and hypothesis testing, 201-337

© Ahmed Squalli Houssaini. Exercise set published at www.letuteurscientifique.ca/en/exercices/cegep-337-correlation-regression. Free for personal and classroom use; republishing it elsewhere requires written permission (legal notice).

See also

Looking for a statistics tutor in Montreal?

Get in touch for a first session. Regression is the most useful chapter of 201-337 for the rest of your studies: we work on the calculations and on the interpretation in equal measure.

Site by Studio Squalli