housekeeping - newcastle universitynag48/teaching/mas1403/slides7slr.pdf · 14 124 196 15376 1736...

93
House Keeping Tutorials at the usual times this week but note some venue changes! Tues 10-11 Bedson Teaching Centre 1.48 Tues 11-12 Herschel LT2 (ground) Tues 2-3 Herschel TR2 (level 4) Thurs 10-11 Herschel TR1 (level 4) Thurs 11-12 Herschel TR3 (level 4) Assignment 2 available from Wednesday (at the latest) – deadline Friday 2nd May This week’s work will help with the last question! This week’s exercise sheet contains a prize question!

Upload: others

Post on 02-Nov-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

House Keeping

Tutorials at the usual times this week but note some venuechanges!

Tues 10-11 Bedson Teaching Centre 1.48Tues 11-12 Herschel LT2 (ground)Tues 2-3 Herschel TR2 (level 4)Thurs 10-11 Herschel TR1 (level 4)Thurs 11-12 Herschel TR3 (level 4)

Assignment 2 available from Wednesday (at the latest) –deadline Friday 2nd May

This week’s work will help with the last question!

This week’s exercise sheet contains a prize question!

Page 2: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

CBA 5

CBA 5 goes live this week in assessed mode (will test you onchapters 4 and 5)

The is a glitch in question 3 when working out the expectedfrequencies for ‘Mathematics’

This has now been fixed!

For those people who have already completed the CBA inassessed mode, the marks will be adjusted!

Page 3: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Lecture 8

CORRELATIONAND

LINEAR REGRESSION

Page 4: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Introduction

In this lecture we look at relationships between pairs ofcontinuous variables. These might be

Page 5: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Introduction

In this lecture we look at relationships between pairs ofcontinuous variables. These might be

height and weight

Page 6: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Introduction

In this lecture we look at relationships between pairs ofcontinuous variables. These might be

height and weight

market value and number of transactions

Page 7: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Introduction

In this lecture we look at relationships between pairs ofcontinuous variables. These might be

height and weight

market value and number of transactions

temperatures and sales of ice cream

Page 8: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Introduction

In this lecture we look at relationships between pairs ofcontinuous variables. These might be

height and weight

market value and number of transactions

temperatures and sales of ice cream

We can examine the relationship between our two variablesthrough a scatter diagram (plot one against the other).

Page 9: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Introduction

In this lecture we look at relationships between pairs ofcontinuous variables. These might be

height and weight

market value and number of transactions

temperatures and sales of ice cream

We can examine the relationship between our two variablesthrough a scatter diagram (plot one against the other).

Today we will look at how to examine such relationships moreformally.

Page 10: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The following data are monthly ice cream sales at Luigi Minchella’sice cream parlour.

Page 11: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Month Average Temp (oC) Sales (£000’s)

January 4 73February 4 57March 7 81April 8 94May 12 110June 15 124July 16 134

August 17 139September 14 124October 11 103November 7 81December 5 80

Page 12: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Month Average Temp (oC) Sales (£000’s)

January 4 73February 4 57March 7 81April 8 94May 12 110June 15 124July 16 134

August 17 139September 14 124October 11 103November 7 81December 5 80

Is there any relationship between temperature and sales?

Page 13: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Month Average Temp (oC) Sales (£000’s)

January 4 73February 4 57March 7 81April 8 94May 12 110June 15 124July 16 134

August 17 139September 14 124October 11 103November 7 81December 5 80

Is there any relationship between temperature and sales?

Can you DESCRIBE this relationship?

Page 14: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362
Page 15: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The scatter plot goes “uphill”, so we say there is a positiverelationship between temperature and ice cream sales.

Page 16: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The scatter plot goes “uphill”, so we say there is a positiverelationship between temperature and ice cream sales.

As temperatures rise, so do ice cream sales!

Page 17: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The scatter plot goes “uphill”, so we say there is a positiverelationship between temperature and ice cream sales.

As temperatures rise, so do ice cream sales!

If the scatter plot had shown a “downhill” slope, we wouldhave a negative relationship.

Page 18: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The scatter plot goes “uphill”, so we say there is a positiverelationship between temperature and ice cream sales.

As temperatures rise, so do ice cream sales!

If the scatter plot had shown a “downhill” slope, we wouldhave a negative relationship.

We could draw a straight line through the middle of most ofthe points. Thus, there is also a linear association present.

Page 19: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The scatter plot goes “uphill”, so we say there is a positiverelationship between temperature and ice cream sales.

As temperatures rise, so do ice cream sales!

If the scatter plot had shown a “downhill” slope, we wouldhave a negative relationship.

We could draw a straight line through the middle of most ofthe points. Thus, there is also a linear association present.

If we were to draw a line through the points, most pointswould lie close to this line. The closer the points lie to a line,the stronger the relationship.

Page 20: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Correlation

We now look at how to quantify the relationship between twovariables by calculating the sample correlation coefficient. Thisis

Page 21: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Correlation

We now look at how to quantify the relationship between twovariables by calculating the sample correlation coefficient. Thisis

r =SXY√

SXX × SYY,

where

Page 22: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Correlation

We now look at how to quantify the relationship between twovariables by calculating the sample correlation coefficient. Thisis

r =SXY√

SXX × SYY,

where

SXY =(

xy)

− nx y ,

Page 23: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Correlation

We now look at how to quantify the relationship between twovariables by calculating the sample correlation coefficient. Thisis

r =SXY√

SXX × SYY,

where

SXY =(

xy)

− nx y ,

SXX =(

x2)

− nx2,

Page 24: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Correlation

We now look at how to quantify the relationship between twovariables by calculating the sample correlation coefficient. Thisis

r =SXY√

SXX × SYY,

where

SXY =(

xy)

− nx y ,

SXX =(

x2)

− nx2,

SYY =(

y2)

− ny2.

Page 25: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

r always lies between –1 and +1.

Page 26: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

r always lies between –1 and +1.

If r is close to +1, we have evidence of a strong positive(linear) association.

Page 27: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

r always lies between –1 and +1.

If r is close to +1, we have evidence of a strong positive(linear) association.

If r is close to –1, we have evidence of a strong negative(linear) association.

Page 28: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

r always lies between –1 and +1.

If r is close to +1, we have evidence of a strong positive(linear) association.

If r is close to –1, we have evidence of a strong negative(linear) association.

If r is close to zero, there is probably no association!

Page 29: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

r always lies between –1 and +1.

If r is close to +1, we have evidence of a strong positive(linear) association.

If r is close to –1, we have evidence of a strong negative(linear) association.

If r is close to zero, there is probably no association!

A correlation coefficient close to zero does not imply norelationship at all, just no linear relationship.

Page 30: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

Page 31: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73

Page 32: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16

Page 33: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329

Page 34: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329 2924 57

Page 35: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329 2924 57 16

Page 36: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329 2924 57 16 3249

Page 37: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329 2924 57 16 3249 228

Page 38: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329 2924 57 16 3249 2287 81 49 6561 567

Page 39: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329 2924 57 16 3249 2287 81 49 6561 5678 94 64 8836 752

Page 40: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

The easiest way to calculate r is to draw up a table!

x y x2 y2 xy

4 73 16 5329 2924 57 16 3249 2287 81 49 6561 5678 94 64 8836 75212 110 144 12100 132015 124 225 15376 186016 134 256 17956 214417 139 289 19321 236314 124 196 15376 173611 103 121 10609 11337 81 49 6561 5675 80 25 6400 400

120 1200 1450 127674 13362

Page 41: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Notice in the formulae for SXY , SXX and SYY we need the samplemeans x and y . Thus,

Page 42: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Notice in the formulae for SXY , SXX and SYY we need the samplemeans x and y . Thus,

x =120

12

= 10 and

Page 43: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Notice in the formulae for SXY , SXX and SYY we need the samplemeans x and y . Thus,

x =120

12

= 10 and

y =1200

12

= 100.

Page 44: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Similarly,

Page 45: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Similarly,

SXY =(

xy)

− nx y

= 13362− 12× 10× 100

= 1362,

Page 46: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Similarly,

SXY =(

xy)

− nx y

= 13362− 12× 10× 100

= 1362,

SXX =(

x2)

− nx2

= 1450− 12× 10× 10

= 250 and

Page 47: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Similarly,

SXY =(

xy)

− nx y

= 13362− 12× 10× 100

= 1362,

SXX =(

x2)

− nx2

= 1450− 12× 10× 10

= 250 and

SYY =(

y2)

− ny2

= 127674− 12× 100× 100

= 7674.

Page 48: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Thus,

Page 49: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Thus,

r =SXY√

SXX × SYY

Page 50: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Thus,

r =SXY√

SXX × SYY

=1362

√250× 7674

Page 51: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Thus,

r =SXY√

SXX × SYY

=1362

√250× 7674

= 0.983 (to 3 decimal places).

Page 52: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

A few points to remember...

Page 53: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

A few points to remember...

If your calculated correlation coefficient does not lie between−1 and +1, you’ve done something wrong!

Page 54: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

A few points to remember...

If your calculated correlation coefficient does not lie between−1 and +1, you’ve done something wrong!

Check that your correlation coefficient agrees with your plot

Page 55: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

A few points to remember...

If your calculated correlation coefficient does not lie between−1 and +1, you’ve done something wrong!

Check that your correlation coefficient agrees with your plot

an “uphill” slope ties in with a positive correlation coefficient;

Page 56: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

A few points to remember...

If your calculated correlation coefficient does not lie between−1 and +1, you’ve done something wrong!

Check that your correlation coefficient agrees with your plot

an “uphill” slope ties in with a positive correlation coefficient;a “downhill” slope ties in with a negative correlationcoefficient;

Page 57: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

A few points to remember...

If your calculated correlation coefficient does not lie between−1 and +1, you’ve done something wrong!

Check that your correlation coefficient agrees with your plot

an “uphill” slope ties in with a positive correlation coefficient;a “downhill” slope ties in with a negative correlationcoefficient;a random scattering of points indicates a correlationcoefficient close to zero;

Page 58: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

A few points to remember...

If your calculated correlation coefficient does not lie between−1 and +1, you’ve done something wrong!

Check that your correlation coefficient agrees with your plot

an “uphill” slope ties in with a positive correlation coefficient;a “downhill” slope ties in with a negative correlationcoefficient;a random scattering of points indicates a correlationcoefficient close to zero;the closer the points lie to a straight line (either “uphill” or

“downhill”), the closer to either +1 or −1 the correlationcoefficient will be!

Page 59: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Simple linear regression

A correlation analysis helps to establish whether or not there is alinear relationship between two variables. However, it doesn’t allowus to use this linear relationship.

Page 60: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Simple linear regression

A correlation analysis helps to establish whether or not there is alinear relationship between two variables. However, it doesn’t allowus to use this linear relationship.

Regression analysis allows us to use the linear relationshipbetween two variables. For example, with a regression analysis, wecan predict the value of one variable given the value of another.

Page 61: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Simple linear regression

A correlation analysis helps to establish whether or not there is alinear relationship between two variables. However, it doesn’t allowus to use this linear relationship.

Regression analysis allows us to use the linear relationshipbetween two variables. For example, with a regression analysis, wecan predict the value of one variable given the value of another.

To perform a regression analysis, we must assume that

Page 62: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Simple linear regression

A correlation analysis helps to establish whether or not there is alinear relationship between two variables. However, it doesn’t allowus to use this linear relationship.

Regression analysis allows us to use the linear relationshipbetween two variables. For example, with a regression analysis, wecan predict the value of one variable given the value of another.

To perform a regression analysis, we must assume that

the scatter plot of the two variables (roughly) shows astraight line, and

Page 63: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Simple linear regression

A correlation analysis helps to establish whether or not there is alinear relationship between two variables. However, it doesn’t allowus to use this linear relationship.

Regression analysis allows us to use the linear relationshipbetween two variables. For example, with a regression analysis, wecan predict the value of one variable given the value of another.

To perform a regression analysis, we must assume that

the scatter plot of the two variables (roughly) shows astraight line, and

the spread in the Y –direction is roughly constant with X .

Page 64: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362
Page 65: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Look at the scatter plot of ice cream sales against temperature.

Page 66: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Look at the scatter plot of ice cream sales against temperature.

A “line of best fit” can be drawn through the data;

Page 67: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Look at the scatter plot of ice cream sales against temperature.

A “line of best fit” can be drawn through the data;

This line could then be used to make predictions of icecream sales based on temperature.

Page 68: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Look at the scatter plot of ice cream sales against temperature.

A “line of best fit” can be drawn through the data;

This line could then be used to make predictions of icecream sales based on temperature.

However, everyone’s line is bound to be slightly different!

Page 69: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Look at the scatter plot of ice cream sales against temperature.

A “line of best fit” can be drawn through the data;

This line could then be used to make predictions of icecream sales based on temperature.

However, everyone’s line is bound to be slightly different!

And so everyone’s predictions will be slightly different!

Page 70: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Look at the scatter plot of ice cream sales against temperature.

A “line of best fit” can be drawn through the data;

This line could then be used to make predictions of icecream sales based on temperature.

However, everyone’s line is bound to be slightly different!

And so everyone’s predictions will be slightly different!

The aim of regression analysis is to find the “best” line whichgoes through the data.

Page 71: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Look at the scatter plot of ice cream sales against temperature.

A “line of best fit” can be drawn through the data;

This line could then be used to make predictions of icecream sales based on temperature.

However, everyone’s line is bound to be slightly different!

And so everyone’s predictions will be slightly different!

The aim of regression analysis is to find the “best” line whichgoes through the data.

At this point, we should remind ourselves about the equationfor a straight line and how to draw it!

Page 72: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

Page 73: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

The simple linear regression model is given by

Y = α+ βx + ǫ,

where

Page 74: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

The simple linear regression model is given by

Y = α+ βx + ǫ,

where

Y is the response variable and

Page 75: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

The simple linear regression model is given by

Y = α+ βx + ǫ,

where

Y is the response variable and

X is the explanatory variable.

Page 76: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

The simple linear regression model is given by

Y = α+ βx + ǫ,

where

Y is the response variable and

X is the explanatory variable.

ǫ is the random error taken to be zero on average, withconstant variance.

Page 77: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

The simple linear regression model is given by

Y = α+ βx + ǫ,

where

Y is the response variable and

X is the explanatory variable.

ǫ is the random error taken to be zero on average, withconstant variance.

α represents the intercept of the regression line (the pointwhere the line “cuts” the Y –axis),

Page 78: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

The simple linear regression model is given by

Y = α+ βx + ǫ,

where

Y is the response variable and

X is the explanatory variable.

ǫ is the random error taken to be zero on average, withconstant variance.

α represents the intercept of the regression line (the pointwhere the line “cuts” the Y –axis),

β represents the slope of the regression line (i.e. how steepthe line is), and

Page 79: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

The regression equation

The simple linear regression model is given by

Y = α+ βx + ǫ,

where

Y is the response variable and

X is the explanatory variable.

ǫ is the random error taken to be zero on average, withconstant variance.

α represents the intercept of the regression line (the pointwhere the line “cuts” the Y –axis),

β represents the slope of the regression line (i.e. how steepthe line is), and

We need to estimate α and β from our sample data. But how?

Page 80: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Remember, the aim of regression analysis is to find a linewhich goes through the middle of the data in the scatter plot,closer to the points than any other line;

Page 81: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Remember, the aim of regression analysis is to find a linewhich goes through the middle of the data in the scatter plot,closer to the points than any other line;

So the “best” line will minimise any gaps between the line andthe data!

Page 82: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Remember, the aim of regression analysis is to find a linewhich goes through the middle of the data in the scatter plot,closer to the points than any other line;

So the “best” line will minimise any gaps between the line andthe data!

It turns out that the values of α and β which give this bestline are

β =SXY

SXXand

Page 83: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Remember, the aim of regression analysis is to find a linewhich goes through the middle of the data in the scatter plot,closer to the points than any other line;

So the “best” line will minimise any gaps between the line andthe data!

It turns out that the values of α and β which give this bestline are

β =SXY

SXXand

α = y − βx .

Page 84: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

For the ice cream sales data, we can find the “best” line using theformulae on the previous slide! Thus

Page 85: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

For the ice cream sales data, we can find the “best” line using theformulae on the previous slide! Thus

β =SXY

SXX

=1362

250

= 5.448,

and

Page 86: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Example: ice cream sales

For the ice cream sales data, we can find the “best” line using theformulae on the previous slide! Thus

β =SXY

SXX

=1362

250

= 5.448,

and

α = y − βx

= 100− 5.448× 10

= 45.52.

Page 87: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Thus, the regression equation is

Page 88: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Thus, the regression equation is

y = 45.52 + 5.448x

Page 89: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362
Page 90: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

Making predictions

We can use our estimated regression equation to make predictionsof ice cream sales based on average temperature.

Page 91: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

For example: Predict monthly sales if the average temperature is10oC.

Page 92: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

For example: Predict monthly sales if the average temperature is10oC.

We can use take a reading from our graph, or, more accurately, useour regression equation!

y = 45.52 + 5.448x i.e.

= 45.52 + 5.448× 10

= 45.52 + 54.48

= 100,

Page 93: HouseKeeping - Newcastle Universitynag48/teaching/MAS1403/slides7slr.pdf · 14 124 196 15376 1736 11 103 121 10609 1133 7 81 49 6561 567 5 80 25 6400 400 120 1200 1450 127674 13362

For example: Predict monthly sales if the average temperature is10oC.

We can use take a reading from our graph, or, more accurately, useour regression equation!

y = 45.52 + 5.448x i.e.

= 45.52 + 5.448× 10

= 45.52 + 54.48

= 100,

i.e. if the average temperature is 10oC, we can expect sales of£100,000.