data analysis and statistical methods statistics 651suhasini/teaching651/lecture29mwf.pdflecture 29...

74
Data Analysis and Statistical Methods Statistics 651 http://www.stat.tamu.edu/~suhasini/teaching.html Lecture 29 (MWF) Linear regression: The linear model and statistical inference Suhasini Subba Rao

Upload: others

Post on 11-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Data Analysis and Statistical MethodsStatistics 651

http://www.stat.tamu.edu/~suhasini/teaching.html

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Suhasini Subba Rao

Page 2: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Linear regression

• Suppose I randomly pick a pick an adult and I ask you to guess theirheight. You would probably give me an interval, of say, 4.5 to 6.5 feet.

• Suppose I gave you the additional information that they have size 5 feet,would you reassess your previous estimate?

• Your would probably change your estimate. In this case you may saytheir height would be between 5-5.5.

• The size 5 gives us additional information about that person. It allowsus to narrow down our estimate and make a more ‘precise’ estimate ofher height.

• Put into statistical terms, without knowledge of their shoe size thestandard deviation is quite large. Recall that standard devation is a

1

Page 3: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

measure of error. Once we know their shoe size the standard devation(amount of error) decreases.

• Often we believe that one variable may have an influence on anothervariable.

• For example the variable X (shoe size of person) may influence thevariable Y (the height height of that person).

– We call X the independent variable.– We call Y the dependent variable.

• To see if X has an influence on Y we often plot a scatter plot with Xon the x-axis and Y on the Y -axis. We look for a relationship betweenthe two.

2

Page 4: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• Sometimes it is not clear what influences what (for example does shoesize have an influence on height or height have an influence on shoesize), in which case, you let the dependent variable Y be the variable ofinterest.

• In many cases, the dependency between the independent and dependentvariable can be modelled using a linear relationship, which we describebelow.

3

Page 5: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Review: The equation of a line y = β0 + β1x

• Given any value x, we can use the equation y = β0 + β1x to determinethe corresponding y-value.

• β0 corresponds to the line of the y-axis when x = 0 (often called theintercept).

• β1 the slope and ‘determines’ how x is related to y. For one unit changein x, β1 corresponds to the change in y. So if β1 = 2, and x increases by

4

Page 6: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

one, then y will increase by two. On the other hand, if β1 = −2, and xincreases by one, then y will decrease by two. When β1 = 0, the slope isflat. This means that x exerts no linear influence on y.

5

Page 7: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Data: size of a person and their shoe sizeData rarely follows an exact linear line. But in several examples, a a

linear-type of relationship is plausible. Here is one example:

Height yi 6 14 10 14 26

Feet size xi 1 3 4 5 7

6

Page 8: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Least squares - the line of best fitThis is the estimator which leads to the smallest squared distance

between each observation pair (xi, yi) and the corresponding point on theline, yi = β0 + β1xi (this difference turns out to be the residual). Thisdistance is known as the the residual sum of squares:

n∑i=1

(yi − yi)2 =n∑i=1

(yi − β0 − β1xi)2.

β0 and β1 are selected to minimise it.

7

Page 9: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Expressions for β1 and β0

• We need to calculate:

Sxy =Xi

(yi − y)(xi − x)| {z }relationship

and Sxx =Xi

(xi − x)2

| {z }spread of x-axis

• β1 = SxySxx

and β0 = y − β1x.

• You never have to calculate these (that is the purpose of statisticalsoftware).

• Equation of best fitting line: yi = β0 + β1xi (which we can use forprediction).

8

Page 10: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

What Sxy and Sxx mean

• What the slope, β1, means:

– A positive β1 means a positive relationship. In other words, if (Xi−X)is positive then (Yi − Y ) tends to be positive. Thus a positive Sxymeans that β1 will be positive.

– On the other hand a negative β1 means a negative relationship. If(Xi − X) is positive then (Yi − Y ) tends to be negative. Thus anegative Sxy means that β1 will be negative. β1 means a negativerelationship.

– If Xi does not exert any linear influence on Yi, then the product(Xi − X)(Yi − Y ) can be either negative or positive and the sumSxy =

∑i(Xi − X)(Yi − Y ) will cancel out the negative and positive

and is likely to be close to zero. In turn this means that β1 will be‘close’ to zero.

9

Page 11: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• Sxx is simply the sample standard deviation before dividing by n−1, andmeasure the amount of variation of the independent variables.

• The value of the coefficient β1 will vary according to the units you use.For example, suppose you want to measure the temperature has on thevolume of ice on a lake, if you measure the temperature in Celcius, theslope will be different to if you measure the temperature in Fahrenheit.Thus the slope (like the mean) is sensitive to the units used.

10

Page 12: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Factors which may effect the regression: Leverage andoutliers

• The least squares estimator β1 of β1 is heavily influenced by outliers andwhat are known as leverage points. This is why we need to look out forthese points when we perform a linear regression and look for their effecton the estimators.

– An outlier is a y value (value on the y-axis) that lies outside most ofthe y-values.

– A leverage point is a x value (value on the x-axis) that lies outsidemost of the x-values.

• We shall now see how the influence the parameter estimates.

11

Page 13: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The effect of Leverage points

• Leverage points lie quite far from the main cluster of x-values (they canbe considered as outliers on the x-axis).

• Because they are far from the main cluster, they can dramatically

12

Page 14: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

influence the gradient of the line (β1).

• There are three ways to check for the influence of leverage points:

– Leverage plots. This is basically a qqplot for the x-values.– Cooks distance. This measures how much the fitted line changes is

the x-value is omitted.– See Ott and Longnecker, Chapter 13, for details.

13

Page 15: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The effect of outliers

• The picture illustrates how the outlier point can shift and change theshape of the linear term.

14

Page 16: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Height example

Height yi 6 14 10 14 26 y = 14feet size xi 1 3 4 5 7 x = 4Height yi 6 14 10 14 26yi − y -8 0 -4 0 12

feet size xi 1 3 4 5 7xi − x -3 -1 0 1 3

(xi − x)2 9 1 0 1 9(yi − y)(xi − x) (−8)× (−3) = 24 0 0 0 12× 3 = 36

• Sxy =∑4i=1(yi − y)(xi − x) = 24 + 0 + 0 + 0 + 36 = 60.

• Sxx =∑4i=1(xi − x)2 = 9 + 1 + 0 + 1 + 9 = 20.

15

Page 17: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• Then we have β1 = 6020 = 3 and

β0 = y − β1 × x = 14− 3× 4 = 2.

• The line of best fit is Y = 2 + 3x.

16

Page 18: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Height example in JMP

17

Page 19: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Is the slope really there?

• What does the slope y = 2 + 3x (where x is the shoe size and y is thepredictive length) tell us about the relationship between shoe size andheight?

• The slope looks quite convincing, the value β1 = 3 is ‘large’ and positive.

Looking at the plot, you can easily believe there is linear a relationshipbetween these two variables.

18

Page 20: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• However, we can put a line through any set of points and see a relationshipwhich may not be there.

Consider the following example, the height of people and the number ofbananas they have eaten that day:

It appears that the number of bananas one eats has a profound influenceon their height. However, when you look closer you see the sample size isthree and it is quite easy to random choose three people which can giveyou such data when there is no underlying relationship between bananasand height.

19

Page 21: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• Therefore our objectives are to determine:

(i) If the slope (estimator) is statistically significant? Ie. is there reallyevidence of a relationship. Here we need to use statistical techniquessince as usual we do not observe the entire population (in this exampleit is just 5 people!).

(ii) If there is a relationship, how strong is this relationship, the strengthof a relationship is determined by how ‘well’ the line fits the points(this is commonly measured using the R2 or correlation).

20

Page 22: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Comparing bananas and feet

The main part of the inference is that we are trying to see if the global slope (to be

defined precisely later) H0 : β1 = 0 against HA : β1 6= 0. JMP tells us that the p-value

for the banana example is 33%, which means that there is a 33% change of regenerating

a slope like that when there isn’t a linear relationship. Whereas, the p-value for the shoe

size example is 3.94%.

Before understanding the JMP output, we first introduce the notion of a linear model.

21

Page 23: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The sample and true slope

• For every random sample we draw, we will get new values of (Yi, xi)which gives us different values on the X-Y graph and also different linesof best fit. In other words, each new sample leads to a new β0 and β1,hence β0 and β1 are random variables and have a distribution.

• What do we mean by random sample, and what are β0 and β1 estimating?

• We start by understanding what (Y, x) means.

22

Page 24: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Returning to the shoe size/height example

• Recall if we randomly select someone from the population of all peoplethere is wide variation in what their height could be.

• Suppose we restrict ourselves to the subpopulation of all people withsize x = 12 feet. Then we narrow the amount of variation in the height.Size 12 is quite a large shoe size, hence it is reasonable to suppose thatpeople with size 12 feet are also quite tall.

• However, even if you knew that someone has size 12 feet, you will notknow their exact height. Their shoe size will only give an indication oftheir height. You could say, that the mean height of a person with size12 feet will be 6 feet give or take a bit. That give or take a bit, is therandom variation due to differences between people.

23

Page 25: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• But it seems reasonable to assume that the mean height of a personvaries linearly according to shoe sizes, ie.

y = β0 + β1x

where x denotes the shoe size and y the mean height of a person withsize x feet. (for now ignore what β0 and β1 are).

Why this formula?

– Remember before we had a population of people, the average heightis taken over the entire population.Now we have restricted ourselves to a subpopulation of people withsize 12 people. The average is take over this subpopulation. It is quitereasonable to suppose that the average of this subpopulation shouldbe quite large.

– Compare this average with the subpopulation of people with size 2

24

Page 26: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

feet. This is a small size, so it is quite likely the average height ofpeople with size 4 feet should be small, say 4.11 feet.

– Compare this average with the subpopulation of people with size 6feet. This size is somehow ‘normal’ hence we would expect the averageheight of people with this shoes size to be about 5.4.

• Now let us look at the general average β0 + β1x again.

• If β1 is positive, it tells us that the average height grows with shoe size.This fits with out intuition that height increases with shoe size. HenceModelling the mean height as β0 + β1x seems quite reasonable.

• But remember there is a lot of variation about the mean. That is heightof a randomly selected size 12 may be quite far from the mean β0 +12β1.

To model the variation we add error to the mean.

25

Page 27: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• Hence the linear regression model is Y = β0 + β1x + ε︸︷︷︸error

(the error is

due to random variation due to differences in individuals).

x1 x2 x3

X

Y

E((Y | X)) == ββ0 ++ ββ1X

26

Page 28: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The linear regression model

• The height of a randomly selection person with size x feet is

Y = β0 + β1x+ ε.

• β0 + β1x the mean height of a person who is x feet tall. In generalβ0 + β1x is the mean in a linear regression.

• Examples. Suppose for now it is known that β0 = 1 and β1 = 2

We model the height of a person who has size two feet as

Y = 1 + 2× 2 + ε︸︷︷︸due to random variation

.

27

Page 29: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Observe that 5 is the average height of a person with size two feet. Theresidual ε is the variation about the mean because every individual isdifferent (this is ‘individual effect’).

We model the height of a person who has size 12 feet as

Y = 1 + 2× 12 + ε︸︷︷︸due to random variation

.

• 23 = 1 + 2× 12 is the average height of a person with size 12 feet.

28

Page 30: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The linear model and the least squares estimators

• In reality we will not know β0 and β1 (just like the mean is unknown),therefore the mean equation β0 + β1x is also unknown.

• However, we do observe (yi, xi) (recall the shoe size/height example wehad 5 observations).

• The least squares estimator β0 and β1 are estimators of β0 and β1

based on the sample, and y(x) = β1x+ β0 is an estimators of the meanβ1x+ β0.

• Since β0 and β1 are estimators of β0 and β1 we will want to do theobvious things like construct confidence intervals for β0 and β1 and dostatistical tests.

29

Page 31: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The Prediction equation (predicting the mean)

• Once we have estimated β0 and β1 we can use the prediction equationy(x) = β0 + β1x to predict the mean of Y given any value of x.

At this point there are a few issues that we need to keep in mind whenwe do this.

• As budding statisticians, we know that β0 and β1 are estimators of β0

and β1. Thus, there will be errors in the prediction, Y (x) = β0 + β1x,and it would be wiser to construct a confidence interval.

• However, we need to decide, what exactly are we trying to predict?

(i) If we are predicting the the mean β0 +β1x, and construct a confidenceinterval for the mean, β0 + β1x. The confidence interval will getnarrower as the estimators become more reliable.

30

Page 32: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

(ii) On the other hand, we are trying to predict Y = β1x + β0 itself,the confidence interval for Y will not become too narrow, even if theestimators are extremely reliableThis confidence interval not only has to take into account the variationof the estimator, but also the variability in the population. It can bewide, and will not get narrower as the sample size grow. Eg. SupposeI am interested in a CI for the height of someone with size 8 feet,even if I have huge sample size, that give me accurate estimates of β0

and β1, I still I will not be able to make my interval narrow, as it isimpossible to predict the inter-person variation ε.Details are not given here but can be found in Ott and Longnecker,Chapter 11.

31

Page 33: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Prediction and extrapolationIf x lies outside the interval of observations that we have used to calculate β0 and β1

(the interval where we do have information) then Y (x) = β0 + β1x is extrapolating. It

can be done, but extreme caution must be used, because we have not have data on how

x influences Y in this interval. To see how it can go terribly wrong, look at the Nature

article on Olympic times on my website.

brief communications

NATURE | VOL431 | 30 SEPTEMBER 2004 | www.nature.com/nature 525

Lung cancer

Intragenic ERBB2 kinasemutations in tumours

The protein-kinase family is the mostfrequently mutated gene family foundin human cancer and faulty kinase

enzymes are being investigated as promisingtargets for the design of antitumour thera-pies. We have sequenced the gene encodingthe transmembrane protein tyrosine kinaseERBB2 (also known as HER2 or Neu) from120 primary lung tumours and identified4% that have mutations within the kinasedomain; in the adenocarcinoma subtype oflung cancer, 10% of cases had mutations.ERBB2 inhibitors, which have so far provedto be ineffective in treating lung cancer,should now be clinically re-evaluated in thespecific subset of patients with lung cancerwhose tumours carry ERBB2 mutations.

The successful treatment of chronicmyelogenous leukaemia with a drug (knownas imatinib, marketed as Gleevec) thatinhibits a mutant protein kinase has fosteredinterest in the development of other kinaseinhibitors1. Gefitinib, an inhibitor of the epidermal growth-factor receptor (EGFR),induces a marked response in a small subsetof lung cancers; activating mutations havebeen found in the EGFR gene in tumoursthat respond to gefitinib but are rare in thosethat do not respond2,3. The response to gefi-tinib as a treatment for lung cancer thereforeseems to be predicated upon the presence ofan EGFR mutation in the tumour.

Momentous sprint at the 2156 Olympics?Women sprinters are closing the gap on men and may one day overtake them.

r2 = 0.789

r2 = 0.882

Year

Win

ning

tim

e (s

)

1900

1916

1932

1948

1964

1980

1996

2012

2028

2044

2060

2076

2092

2108

2124

2140

2156

2172

2188

2204

2220

2236

2252

6

7

8

9

10

11

12

13

Figure 1 The winning Olympic 100-metre sprint times for men (blue points) and women (red points), with superimposed best-fit linear regres-

sion lines (solid black lines) and coefficients of determination. The regression lines are extrapolated (broken blue and red lines for men and

women, respectively) and 95% confidence intervals (dotted black lines) based on the available points are superimposed. The projections inter-

sect just before the 2156 Olympics, when the winning women’s 100-metre sprint time of 8.079 s will be faster than the men’s at 8.098 s.

The 2004 Olympic women’s 100-metresprint champion, Yuliya Nesterenko, isassured of fame and fortune. But we

show here that — if current trends continue— it is the winner of the event in the 2156Olympics whose name will be etched insporting history forever, because this maybe the first occasion on which the race iswon in a faster time than the men’s event.

The Athens Olympic Games could beviewed as another giant experiment inhuman athletic achievement. Are womennarrowing the gap with men, or falling further behind? Some argue that the gainsmade by women in running events betweenthe 1930s and the 1980s are decreasing as thewomen’s achievements plateau1.Others con-tend that there is no evidence that athletes,male or female, are reaching the limits oftheir potential1,2.

In a limited test,we plot the winning timesof the men’s and women’s Olympic finals overthe past 100 years (ref. 3; for data set, see sup-plementary information) against the compe-tition date (Fig. 1). A range of curve-fittingprocedures were tested (for methods,see sup-plementary information), but there was noevidence that the addition of extra para-meters improved the model fit significantlyfrom the simple linear relationships shownhere. The remarkably strong linear trendsthat were first highlighted over ten years ago2

persist for the Olympic 100-metre sprints.There is no indication that a plateau has beenreached by either male or female athletes inthe Olympic 100-metre sprint record.

Extrapolation of these trends to the 2008Olympiad indicates that the women’s 100-metre race could be won in a time of10.57�0.232 seconds and the men’s event in9.73�0.144 seconds. Should these trendscontinue, the projections will intersect at the2156 Olympics, when — for the first timeever — the winning women’s 100-metresprint time of 8.079 seconds will be lowerthan that of the men’s winning time of 8.098seconds (Fig. 1). The 95% confidence inter-vals, estimated through Markov chain MonteCarlo simulation4 (see supplementary infor-mation), indicate that this could occur asearly as the 2064 or as late as the 2788 Games.

This simple analysis overlooks numerousconfounding influences, such as timing accuracy,environmental variations,nationalboycotts and the use of legal and illegal stim-ulants. But it is also defended by the limitedamount of variance that remains unex-plained by these linear relationships.

So will these trends continue and canwomen really close the gap on men? Thosewho contend that the gender gap is widening

say that drug use explains why women’stimes were improving faster than men’s,particularly as that improvement slowedafter the introduction of drug testing1.How-ever, no evidence for this is found here. Bycontrast, those who maintain that therecould be a continuing decrease in gendergap point out that only a minority of theworld’s female population has been giventhe opportunity to compete (O. Anderson,www.pponline.co.uk/encyc/0151.htm).

Whether these trends will continue at theBeijing Olympics in 2008 remains to be seen.Sports, biological and medical sciencesshould enable athletes to continue toimprove on Olympic and world records, byfair means or foul5. But only time will tellwhether in the 66th Olympiad the fastesthuman on the planet will be female.Andrew J. Tatem*, Carlos A. Guerra*, PeterM. Atkinson†, Simon I. Hay*‡*TALA Research Group, Department of Zoology,University of Oxford, Oxford OX1 3PS, UKe-mail: [email protected]†School of Geography, University of Southampton,Highfield, Southampton SO17 1BJ, UK‡Public Health Group, KEMRI/Wellcome TrustResearch Laboratories, PO Box 43640, 00100 GPO,Nairobi, Kenya1. Holden, C. Science 305, 639–640 (2004).

2. Whipp, B. J. & Ward, S. A. Nature 355, 25 (1992).

3. Rendell, M. (ed.) The Olympics: Athens to Athens 1896–2004

338–340 (Weidenfeld and Nicolson, London, 2003).

4. Gilks, W. R., Thomas, A. & Spiegelhalter, D. J. Statistician 43,

169–178 (1994).

5. Vogel, G. Science 305, 632–635 (2004).

Supplementary information accompanies this communication on

Nature’s website.

Competing financial interests: declared none.

30.9 brief comms 525 MH 23/9/04 4:33 pm Page 525

© 2004 Nature Publishing Group

32

Page 34: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Inference for the slope β1

• In the one sample t-test that we did several weeks ago (though we neverdirectly specified the model), the model is

Y = µ+ ε,

µ is the population mean (which we do not know), Y is the observation(eg. height or a randomly chosen person) and ε is the pertubation or theerror about the mean (eg. of the mean height of a person is 170cm, I am160cm, in this case ε = −10cm - of course in practice we do not knowwhat the mean height is and this has to be estimated from the a sampleof heights). The sample average X, calculated form n observations is anestimator of µ.

33

Page 35: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• This can be extended to the linear model:

Y = β0 + β1X + ε.

Like the population mean µ, β1 and β0 are unknown.

• We observe the sample (y1, x1), . . . , (yn, xn), from this we can calculateβ1 and β0. β1 and β0 are estimators of β1 and β0.

• To make inference about the unknown β1 we need to know thedistribution of its estimator β1.

• Since Y (x) = β0 + β1x, understanding the distribution behind β1 willhelp us to make inference about the mean value of Y and construct CIsfor β0 + β1x. This is what the computer is very useful for.

34

Page 36: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The distribution of β1

• Because for every sample drawn we will get new (Y1, X1), . . . , (Yn, Xn),the estimator of the slope β1 will be different for each sample. Hence β1

is a random variable and has a distribution.

• The variance of β1 isσ2ε

SXX(σ2ε is the variance of ε).

• If all the assumptions are satisfied (and the variance of ε is known) ithas the normal distribution

β1 ∼ N (β1,σ2ε∑n

i=1(xi − x)2) = N (β1,

σ2ε

SXX),

(aside: X here is nonrandom).

35

Page 37: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• This result holds true, if the sample size is relative small and the residualsεt are normally distributed or the sample size is large (in which case wedo not need normality of the residuals).

36

Page 38: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Estimating the variance and standard error• To estimate the variance of the residuals σ2

ε we use the estimatedresiduals;

εi = yi − β0 − β1xi,

and use as an estimator of σ2ε, s2

ε, where

s2ε =

1n− 2

n∑i=1

ε2i =

1n− 2

n∑i=1

(Yi − β0 − β1xi)2.

• The standard error for β1 is√σ2ε

SXX=

√var(εi)∑n

i=1(xi − x)2

37

Page 39: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Factors that influence the standard error of β1

• Of course we want a small standard error.

• We see to get a small variance (thus a better estimator of β1), werequire;

– The sample size n to be large. This means more (Xi− X)2 terms, the

larger the denominator∑ni=1(xi − x)2, therefore

σ2ε

SXXgets smaller.

– More variation in Xi. This means the more different values Xi takes

the larger (xi− x)2, hence SXX will be larger andσ2ε

SXXwill be smaller.

More different values of Xi mean the more sure we are of the gradient.

• If you are able to design your experiment (this means select Xi - eg.people with certain shoe size), choose Xis which are very different.

38

Page 40: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

For example, don’t choose people with size 3 feet. Choose people witha wide range of feet sizes, this gives a lot of information about the slopeβ1.

• More spread out Xi means we get more information about the entirelinear function Y = β0 + β1X + ε.

• It is worth noting the distribution of β0 is also known. See page 561 ofOtt and Longnecker.

39

Page 41: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The distribution of β1

• Since σ2ε is unknown and we use instead the sample variance based on the

residuals s2ε, we do not use the normal distribution but the t-distribution.

β1 − β1√s2ε

SXX

∼ tn−2.

• It is a t-distribution with (n − 2)-degrees of freedom (the reason for -2rather than -1, is because we have now estimated two parameters β0 andβ1). Before we had estimated only one parameter, the mean µ.

• We can use this result to:

– Construct confidence intervals for the true slope β1.

40

Page 42: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

– Test whether the x-variable exerts an influence on the y-variable, inother words test for the true slope β1 (often H0 : β1 = 0 againstHA : β1 6= 0, or H0 : β1 ≤ 0 against HA : β1 > 0 or H0 : β1 ≥ 0against HA : β1 < 0,).

– Construct CI for the mean β0 + β1x and also the individual observationY (usually done in JMP).

41

Page 43: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Confidence intervals for β1

• To make a 95% CI for β1 use

[β1 − tn−2(0.025)

√s2ε

SXX, β1 + tn−2(0.025)

√s2ε

SXX],

where SXX =∑ni=1(xi − x)2.

42

Page 44: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Testing β1 = 0We can apply the above result to test H0 : β1 = 0 against the alternative

HA : β1 6= 0.

• Make Z-transformation:

t =β1√s2ε

SXX

.

• Now look calculate the p-value of this P (t(n− 2) ≥ |t|) or construct thenon-rejection region.

• We can also do a one-sided test, but by calculating the area to the leftor right of t, depending on which side the alternative is ‘pointing’.

43

Page 45: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example: Height and Shoe size

• The output tells us that the prediction equation (for the mean) isy = 3x + 2. To test H0 : β ≤ 0 against HA : β > 0 (noting thatour hunch is that larger feet increase the chance of a taller person) the

44

Page 46: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

t-transform is t = 30.85 = 3.5. The number of degrees of freedom is given

next to Error and is df=5 − 2 = 3. The area to the right of 3.5 (usingthe t-tables with 3df is between 1-2%). As it is a one-sided test, thep-value is between 1-2%. If you look at the output it gives the p-valueas 3.94% (this is because Statcrunch is doing a two-sided test). Fromthis p-value we can deduce that the exact p-value in the one-sided testis 1.96% = 3.94/2%.

• This means there is a 1.96% chance of seeing a positive slope like thiswhen there is no linear dependence between shoe size and height. If weuse 5% as the significance level, there is evidence in the data to suggestthere is a linear dependence between the shoe size and height.

• A 95% confidence interval for the slope is

[3± 3.182× 0.85].

45

Page 47: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example: Height and bananasLet us return to the bananas example:

• The prediction equations (for the mean) is y = 0.375x+ 4.875.

• To test H0 : β = 0 against HA : β 6= 0 (we have no real reason to

46

Page 48: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

believe that the hypothesis should be pointing one way or the other) thet-transform is t = 0.375

0.21 = 1.74. The number of degrees of freedom isdf=3− 2 = 1. The area to the right of 1.73 (using the t-tables with 1df)is more than 15%). As it is a two-sided test, the p-value is more than30%. If you look at the output the precise p-value is 33%.

• This means that there that the chance of having a curve that fits like itdoes through the data given that there is no linear association betweenbananas and height is 33%. As this p-value is so large, there isn’t anyevidence in the data of linear dependence between height and bananas.

Remember, this result does not tell us that bananas do not influenceheight, but there is no evidence in the data that there is a linear influence.The reason for out getting this result:

– There really is NO influence.– There is a linear influence, but we do not have enough data to detect

47

Page 49: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

it (may be the influence is too small for a sample size of three todetect).

– The influence could be nonlinear - which a linear model cannot accountfor.

48

Page 50: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example: Banks and Businesses

As one part of a study of commerical bank branches, data are obtainedon the number of independent businesses (x) and number of banks in 11different areas. The commerical centers of cities are excluded. The data isgiven below:

busi. 92 116 124 210 216 267 306 378 415 502 615 703

banks 3 2 3 5 4 5 5 6 7 7 9 9

Plot the data, does a linear line seem plausible?

49

Page 51: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Solution: Banks and Businesses

50

Page 52: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Analysing the output

• It is clear from the output that the parameter estimators are β1 = 0.011and β0 = Y − β1X = 5.4 − 0.011 × 328.7 = 1.87. Thus the predictionequation is y = 0.011x+ 1.87.

• Our hypothesis is this case is that the number of businesses positivelyinfluence the businesses, which means H0 : β1 ≤ 0 against HA : β1 > 0.The t-value is t = 0.011/0.000845 = 13.14, the t-distribution has 10dfand the area to the right of 13.14 is tiny (less than (0.01/2)%).

• The data suggests that the number businesses in a region has a linearinfluence on the number of banks.

51

Page 53: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example: Global Temperatures over time

We want to see global temperature anamolies have increased over time:

52

Page 54: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Discussion: Global Temperatures over time

• The prediction equation is Y = 0.0036x− 7.29.

• Here we want to test H0 : β1 ≤ 0 against HA : β1 > 0.

• The t-value is t = 0.0036/0.00026 = 13.71. As this is a one-sided testthe p-value is the area to the right of 13.71, which is less than (0.01/2)%.Therefore there is evidence that temperatures are increasing.

• We can examine how much it has increased by constructing confidenceintervals for the slope. The 95% confidence interval is

[0.00368± 1.96× 0.000269] = [0.0032, 0.0042].

53

Page 55: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

This suggests a yearly increase of between 0.0032 to 0.0042 degrees.Therefore over the past 150 years this suggests an increase of between150× 0.0032 to 150× 0.0042 celsius, ie between [0.48, 0.63] degrees.

54

Page 56: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example: Global Temperatures and CO2

Next we want to investigate whether man-made emission CO2 hasimpacted the global temperatures.

55

Page 57: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Discussion: Global Temperatures and CO2

• The prediction equation is Y = 0.079x− 0.35.

• Here we want to test H0 : β1 ≤ 0 against HA : β1 > 0.

• The t-value is t = 0.079/0.0043 = 16.44. The area to the right of 16.44is less than 0.01/2%. Therefore there is evidence that increasing CO2levels are corresponding with increasing temperature levels (notice I haveavoided the use of a causality here).

• Comparing CO2 with time as explanatory variables for temperature, itappears that CO2 better fits the data.

We will describe a numerical comparison for the fit in a later lecture.

56

Page 58: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Residuals

• Recall that when we did an ANOVA, and to check the assumptions wecalculated the residuals.

In this case, the residuals were the the difference between the samplemean in each group and each of the observations in each group.

• Residuals are an important component in many statistical analysis. Theyhelp in determining whether such modelling assumptions are realistic ornot.

• In the case of regression the residuals are the difference between eachYi and corresponding point on the line of best fit Yi = β0 + β1xi. Theresiduals are calculated with εi = Yi− Yi = Yi− β0− β1xi. The residualsare basically estimates of the deviation from the mean in the ‘true’ modelY = β1x+ β0 + ε.

57

Page 59: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• We came across residuals above when obtaining an estimator of σ2ε

(which was used in the expression for the standard error).

• Usually, you do not have to calculate the residuals, the statistical softwareshould give it.

• Recall the residuals are used to calculate the standard error of β1 (seeslide 37).

58

Page 60: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The residuals in shoe size/height example

The predictor of yi given xi is yi = β0 + β1xi . Hence the predictiveline is y = 2 + 3x. We use this to obtain the residuals:

Height yi 6 14 10 14 26Feet size xi 1 3 4 5 7yi = 3xi + 2 5 11 14 17 24

Error in prediction: εi = yi − yi 1 3 4 3 2

• Residuals are very important. If they residuals are ‘small’ the line fits thedata very well. If the residuals are ‘large’, the line does not fit so well.Of course, in many situations, the line fit will not be particularly good,because the association between the x and y variable is weak. However,even if the association is weak it can still be important. For example, theamount of milk a child drink may have an influence on his or her height,

59

Page 61: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

but it is unlikely the link is strong. However, it is still an importantassociation.

A strong link can be seen when the cloud of points cling closely to theline.

A weak link can be seen when the cloud of points do not cling to thecloud, but there appears to be a trend nevertheless.

60

Page 62: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

The residuals in JMP

61

Page 63: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example 2

As one part of a study of commerical bank branches, data are obtainedon the number of independent businesses (x) and number of banks in 11different areas. The commerical centers of cities are excluded. The data isgiven below:

busi. 92 116 124 210 216 267 306 378 415 502 615 703

banks 3 2 3 5 4 5 5 6 7 7 9 9

What are the residuals?

62

Page 64: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Solution 2

• We know from previously that the predictive equation is Y = 1.87 +0.011X.

x 92 116 124 210 216 267 306 378 415 502 615 703y 3 2 3 5 4 5 5 6 7 7 9 9y 2.8 3.0 3.1 4.1 4.1 4.7 5.1 5.9 6.3 7.3 8.5 9.5εi 0.22 -1.04 -0.13 0.92 -0.14 0.30 -0.13 0.08 0.67 -0.29 0.47 -0.50

εi = yi − yi are the estimated residuals, they look ‘small’ with respect to xand y values, suggesting the fit is good.

63

Page 65: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Assumptions required for linear regressionIn the analysis we did above we made the assumption that the estimated

slope β1 was close to normally distributed (and thus t, since we had toestimate the standard deviation of the residuals). Therefore, the confidenceintervals and p-values were derived under this assumption. How accuratethey are depend on the following assumptions being satisfied.

(1) A straight line fits the data:

Y = β0 + β1X + ε.

In reality, this means if we plot the data, we see several a cloud of dotsabout a line.

(2) If the sample size is relatively small, the errors ε are approximatelynormal).

64

Page 66: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

(3) The variance of the errors ε is the same for all samples (checking thiscan be a bit tricky and is not discussed here). In other words, there isn’tany heteroscedasticity.

(4) The observations are independent of each other.

If there is heteroscedasticity or dependence in the data then the standarderrors are incorrect, which can give rise to the incorrect t-transform andp-values/CIs. There are ways to take these into account, but they requirea more complex analysis.

65

Page 67: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

1. Checking to see whether the linear model is correct

To see check whether the linear model is appropriate.

• We should fit the linear models to the data (x1, Y1), . . . , (xn, Yn).

• Obtain the parameter estimators β1, β0.

• Estimate the residuals εi.

• Make a scatter plot of εi against {xi} or make a scatter plot of predictionβ1xi + β0 against the residuals (they are similar).

• If you still see a ‘pattern’ in the scatter plot (what looks like arelationship), then the linear model may not be the most appropriate.

66

Page 68: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

• If the scatter plots looks ‘random’, then the linear plot may beappropriate.

• A pattern would suggest there is still some probably nonlinear dependencebetween the Yi and xi which has not been taken into account throughthe linear model.

To overcome this problem we could make a transformation of xi (suchas looking at the relationship between Yi and x2

i etc.).

67

Page 69: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

2. Checking for normality of the residuals

• It is very easy to check for normality.

• Effectively we just make a QQplot of the residuals.

We recall we calculate the residuals by fitting a line of best fit to thedata, Y = β0 + β1x, and estimate the residuals with εt = Yi− β0− β1xi.

• After estimating the residuals (there are the same number as the numberof observations), we can make a QQplot of the residuals to check fornormality and also a boxplot to check for outliers.

A large deviation from normality and many outliers will give inaccurate CIsand misleading results in statistical tests.

68

Page 70: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example: Banks/Businesses and assumptions

69

Page 71: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Discussion: Assumptions

• From the first plot of the residuals against the predicted banks, we don’tsee any clear pattern. This suggests that there is no dependence betweenthe residuals and the prediction equation. In other words, the residualsdo not contain information about the x-variable that the linear modelcannot model. Therefore, the linear model appears to be appropriate.

• From the second plot we see that the prediction equation closely matchesthe Y -values. This means that the linear equation appears to capturemost the variability in the data (in other words the linear equation modelswell the number of banks).

• The right hand plot is the QQplot of the residuals. We recall that ourinference on the slope was based on the normality of β1. Since thesample size is small, this means we require that the residuals are close

70

Page 72: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

to normal. Looking at the QQplot there does not appear to be a muchdeviation from the line. Therefore the residuals do not appear to deviatemuch from normality.

• From how the data has been collected it appears that the observationsare independent of each other and there is no real reason to think thedata is heteroscedastic.

In summary the data appears to satisfy the assumptions for doing a simplelinear regression,

71

Page 73: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Example: Temperatures over time and assumptions

72

Page 74: Data Analysis and Statistical Methods Statistics 651suhasini/teaching651/lecture29MWF.pdfLecture 29 (MWF) Linear regression: The linear model and statistical inference Comparing bananas

Lecture 29 (MWF) Linear regression: The linear model and statistical inference

Discussion: Global temperatures and assumptions

• A plot of the residuals against the predicted values, shows some sort ofpattern, this suggests that the mean temperatures have not evolved ina precisely linear way over time. Therefore, if possible a more complexmodel (rather than just a linear one) may be more appropriate.

• The QQplot of the residuals does not show huge deviation from normality(and the sample size is quite large), which suggests that our normal/tapproximation is accurate.

• However, one assumption which probably does not hold is independenceof the data. As the data are temperatures over time, they are highlylikely to be dependent, and this as not been accounted for in the analysis.Therefore the standard errors obtained may not be accurate.

73