Chapter 7 Linear Regression Day 1 – (pg 176-184).

Post on 21-Jan-2016

225 views 0 download

transcript

Chapter 7

Linear RegressionDay 1 – (pg 176-184)

Correlation and Regression

• Correlation = linear relationship between two variables.

• Summarize relationship with line.• Called Regression line.– Explanatory variable (x)– Response variable (y)

Regression line

• Explains how response variable (y) changes in relation to explanatory variable (x).

• Use line to predict value of y for given value of x.– The predicted values are called • Values on the regression line.

– The observed values are called y.• Points in the scatterplot.

y

Regression line

• Residual - the difference between the observed value and its associated predicted value.

• To find the residuals, we always subtract the predicted value from the observed one:

yye ˆ

Least squares regression (LSRL)

• Most commonly used regression line.• Puts line where sum of the squared errors

(residuals) as small as possible.– Minimizes

• Based on statistics

rssyx yx ,,,,

2e

Regression line equation

where

xbby 10ˆ

x

y

s

srb 1 xbyb 10

Regression line equation

• b1 = slope of line. – For every unit increase in x, changes by the

amount of the slope.– Very important for interpreting data.

• b0 = y-intercept of line. – The value of when x = 0.– Usually not important for interpreting data.– Values of x are usually not close to 0.

y

y

Calculating the regression line.

• Degree Days vs. Gas Usage

9953.0,37.3,74.17,31.5,31.22 rssyx yx

x

y

s

srb 1

Calculating the regression line.

• Degree Days vs. Gas Usage

9953.0,37.3,74.17,31.5,31.22 rssyx yx

19.074.17

37.3)9953.0(1

x

y

s

srb

Calculating the regression line.

• Degree Days vs. Gas Usage

9953.0,37.3,74.17,31.5,31.22 rssyx yx

19.074.17

37.3)9953.0(1

x

y

s

srb

xbyb 10

Calculating the regression line.

• Degree Days vs. Gas Usage

9953.0,37.3,74.17,31.5,31.22 rssyx yx

19.074.17

37.3)9953.0(1

x

y

s

srb

07.1)31.22(19.031.510 xbyb

Calculating the regression line.

• Don’t forget to write the equation.

• Where = predicted gas usage• x = degree days

• ALWAYS IDENTIFY THE VARIABLES

xy 19.007.1ˆ

y

Interpretations

• Slope– For every one unit increase in degree days, the

predicted gas usage increases by 0.19

• Intercept– When the degree days is 0, the predicted gas

usage is 1.07

Prediction

• Use regression equation to predict y from x.– Ex. Predicted gas consumption when degree days

= 40?

– Ex. Predicted gas consumption when degree days = 20?

Prediction

• Use regression equation to predict y from x.– Ex. Predicted gas consumption when degree days

= 40?

– Ex. Predicted gas consumption when degree days = 20?

67.86.707.1)40(19.007.1ˆ y

Prediction

• Use regression equation to predict y from x.– Ex. Predicted gas consumption when degree days

= 40?

– Ex. Predicted gas consumption when degree days = 20?

67.86.707.1)40(19.007.1ˆ y

87.48.307.1)20(19.007.1ˆ y

Plotting the regression line

• Find two points on line.– Pick two x values– Find predicted for each x value.– Ex. x = 20, =4.87 and x = 40, = 8.67

• Plot two points on graph.• Make line through two points.• Regression line .

yy y

Finding In Calculator

• Stat Edit Enter Data in L1 and L2• Stat Calc 8: LinReg (y = a + bx)

• x 16 24 42 60 75 102 120

• y 24 30 35 40 48 56 60

• LSRL:

Example: A random sample of records of sales of homes from Feb.

15 to Apr. 30, 1993, from the files maintained by the Albuquerque Board of Realtors gives the price (in thousands of dollars) and size (in square feet) of 117 homes. A regression analysis gives us the model:

a. What does the slope of this line say about housing prices and house

size?b. What price would you predict to pay for a 3000 square foot home?c. A real estate agent shows a potential buyer a 1200 sq-ft home with

an asking price that is $6000 less than one would expect to pay for a house of that size. What is the asking price?

sizey 061.082.47ˆ

Example

a. Every square foot increase in size increases the average price $0.061x1000, or $61.

b. $230,820 (230.82 thousand)c. $115,020

Homework – Read Chapter 7 Pg 184 – 196

Ch 7 Day 1 WS

Properties of regression line

• Regression line always goes through point

• r is connected to the value of b1.– r has same sign as b1. (If slope is negative,

correlation is negative & vice versa)

),( yx

x

y

s

srb 1

Properties of regression line

• The values of the y variable vary.• Regression line tries to explain variation

of y through its relationship with x.– Not perfectly – points not exactly on line.– Points close to line = regression explains variation

of y well.– Points far from line = regression does not explain

variation of y well.

Properties of regression line

• How much variation can we explain with our regression?

• Answer: R2

– Percent of variation in y that is explained by the linear relationship with x.

– Higher values of R2 mean regression line helps explain the variation in y variable.

Degree Days vs. Gas Usage

– R2 = r2

– Ex. r = 0.9953, R2 = 0.9906 or 99.06% of the variation in gas usage can be explained by the linear relationship with number of degree days.

Example: Roller Coasters

People who responded to a July 2004 Discovery Channel poll names the 10 best roller coasters in the United States. A table in Chapter 7, Exercise 33 shows the length of the initial drop (in feet) and the duration of the ride (in seconds). A regression to predict duration from drop has R2=12.4%.

a. What are the variables and units in this regression?b. Write a sentence (in context) summarizing that the

R2 says about this regression.c. What is the correlation between drop and

duration?

Example: Roller Coasters

a. y: Duration (in seconds) x: drop (in feet) b. Differences in height explain 12.4% of the variability in

the duration of the ride… (or better)… “12.4% of the variation in y (the duration of the ride) can be explained by the least squares regression with x (length of the initial drop).”

c. 0.352

Residuals

• Variation in y not measured by regression line.• Formula: • Residual for each data point.• Mean of residuals = 0.

yye ˆ

Example: Calculating Residuals

• Degree Days vs. Gas Usage

• Find the residual for the point (30,6.4)

xy 19.007.1ˆ

Calculating Residuals

• Degree Days vs. Gas Usage

• Find the residual for the point (30,6.4)

xy 19.007.1ˆ

77.6)30(19.007.1ˆ y

Calculating Residuals

• Degree Days vs. Gas Usage

• Find the residual for the point (30,6.4)

xy 19.007.1ˆ

37.077.64.6ˆ

77.6)30(19.007.1ˆ

yye

y

Calculating Residuals

• Find the residual for the point (13,4.0)

Calculating Residuals

• Find the residual for the point (13,4.0)

54.3)13(19.007.1ˆ y

Calculating Residuals

• Find the residual for the point (13,4.0)

46.054.30.4ˆ

54.3)13(19.007.1ˆ

yye

y

Residual Plots

• Scatterplot– Explanatory variable (x) on horizontal axis.– Residuals (e) on vertical axis.– Horizontal line at residual = 0.

• Good Residual Plot– No pattern or shape– No outliers

Interpreting Residual Plots

The residual plot should show about the same amount of scatter throughout!!

If it has a…• Curved Pattern– relationship is not linear.

• Increasing spread about line as x increases.– Predictions of y for larger x will be less accurate.

• Decreasing spread about line as x increases.– Predictions of y for smaller x will be less accurate.

The ages (in months) and heights (in inches) of seven children are given.

x 16 24 42 60 75 102 120

y 24 30 35 40 48 56 60

Find the LSRL.

Interpret the slope and correlation coefficient in the context of the problem.

Example: Children’s Ages and Heights

Correlation coefficient:

There is a strong, positive, linearstrong, positive, linear association between the age and age and height of childrenheight of children.

Slope:For an increase in age of one monthage of one month, there is an approximate increaseincrease of .34 .34 inches in heights of children.inches in heights of children.

The ages (in months) and heights (in inches) of seven children are given.

x 16 24 42 60 75 102 120

y 24 30 35 40 48 56 60

Predict the height of a child who is 4.5 years old.

Predict the height of someone who is 20 years old.

Create the residual plot of the data in your calculator:

Stat Edit Enter Data in L1 and L2Stat Calc 8: LinReg (y = a + bx)2nd y= (stat plot) Plot 1

Type: Scatterplot Xlist = L1Ylist = 2nd Stat (List) 7: ResidualsEnter

Zoom 9

Is a LSRL appropriate here? Why?

ExtrapolationExtrapolation

• The LSRL should notshould not be used to predict y for values of x outside the data set. • It is unknown whether the pattern

observed in the scatterplot continues outside this range.

Reading Computer Output

Exercise physiologists are investigating the relationship between lean body mass (in kilograms) and the resting metabolic rate (in calories per day) in sedentary males.

What is the LSRL?

The correlation coefficient and the LSRL are both non-resistantnon-resistant measures.

You should be able to….

•Calculate a regression line given summary statistics.•Interpret the slope and intercept of the regression line.•Find predictions and residuals for points.•Interpret a residual plot.•Interpret the R2 value for a regression.•Understand the limitations of regression.