Download - Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Transcript
Page 1: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Lecture 10Introduction to Linear Regression

and Correlation Analysis

Page 2: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Scatter Plot Examples

y

x

y

x

y

y

x

x

Linear relationships Curvilinear relationships

Page 3: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Scatter Plot Examples

y

x

y

x

y

y

x

x

Strong relationships Weak relationships

(continued)

Page 4: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Scatter Plot Examples

y

x

y

x

No relationship(continued)

Page 5: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Correlation Coefficient

• The population correlation coefficient ρ (rho) measures the strength of the association between the variables

• The sample correlation coefficient r is an estimate of ρ and is used to measure the strength of the linear relationship in the sample observations

(continued)

Page 6: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Features of ρand r

• Unit free• Range between -1 and 1• The closer to -1, the stronger the negative

linear relationship• The closer to 1, the stronger the positive

linear relationship• The closer to 0, the weaker the linear

relationship

Page 7: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

r = +.3 r = +1

Examples of Approximate r Values

y

x

y

x

y

x

y

x

y

x

r = -1 r = -.6 r = 0

Page 8: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Calculating the Correlation Coefficient

])yy(][)xx([

)yy)(xx(r

22

where:r = Sample correlation coefficientn = Sample sizex = Value of the independent variabley = Value of the dependent variable

])y()y(n][)x()x(n[

yxxynr

2222

Sample correlation coefficient:

or the algebraic equivalent:

Page 9: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Calculation ExampleTree

HeightTrunk

Diametery x35 849 927 733 660 1321 745 1151 12

Page 10: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Scatter Plot (SPSS)

Step 1: select Graphs then press Scatter…Step 2: From Scatter window select Simple graph then press Define

Step 3: From Simple Scatter plot window select the (dependant) variable for y-axis and the (independent) variable for x-axis. Also you can press Title bottom to write the title for the scatter plot. Then press OK.

6 7 8 9 10 11 12 13

diameter

20

30

40

50

60

heig

htScatter Plot

SPSS Output Scatter Plot

Page 11: Lecture 10 Introduction to Linear Regression and Correlation Analysis.
Page 12: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

R or r (correlation coefficient estimation)

P-value for testing H0: ρ = 0 (no corr.) vs Ha: ρ≠ 0 (coor. Exist)

Since p-value = 0.003 << 0.05 rej. H0. So, correlation exist between y and x.

Page 13: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Introduction to Regression Analysis

• Regression analysis is used to:– Predict the value of a dependent variable based

on the value of at least one independent variable– Explain the impact of changes in an independent

variable on the dependent variable

Dependent variable: the variable we wish to explain

Independent variable: the variable used to explain the dependent

variable

Page 14: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Simple Linear Regression Model

• Only one independent variable, x

• Relationship between x and y is described by a linear function

• Changes in y are assumed to be caused by changes in x

Page 15: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Types of Regression Models

Positive Linear Relationship

Negative Linear Relationship

Relationship NOT Linear

No Relationship

Page 16: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

εxββy 10 Linear component

Population Linear Regression

The population regression model:

Population y intercept

Population SlopeCoefficient

Random Error term, or residualDependent

Variable

Independent Variable

Random Error component

Page 17: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Linear Regression Assumptions

• Error values (ε) are statistically independent• Error values are normally distributed for any

given value of x• The probability distribution of the errors is

normal• The probability distribution of the errors has

constant variance• The underlying relationship between the x

variable and the y variable is linear

Page 18: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Population Linear Regression(continued)

Random Error for this x value

y

x

Observed Value of y for xi

Predicted Value of y for xi

εxββy 10

xi

Slope = β1

Intercept = β0

εi

Page 19: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

xbby 10i

The sample regression line provides an estimate of the population regression line

Estimated Regression Model

Estimate of the regression

intercept

Estimate of the regression slope

Estimated (or predicted) y value

Independent variable

The individual random error terms ei have a mean of zero

Page 20: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Least Squares Criterion

• b0 and b1 are obtained by finding the values of b0 and b1 that minimize the sum of the squared residuals

210

22

x))b(b(y

)y(ye

Page 21: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

The Least Squares Equation

• The formulas for b1 and b0 are:

algebraic equivalent:

nx

x

nyx

xyb 2

21 )(

21 )())((

xxyyxx

b

xbyb 10

and

Page 22: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

• b0 is the estimated average value of y when the value of x is zero

• b1 is the estimated change in the average value of y as a result of a one-unit change in x

Interpretation of the Slope and the Intercept

Page 23: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Finding the Least Squares Equation

• The coefficients b0 and b1 will usually be found using computer software, such as Excel, SPSS, OR Minitab

• Other regression measures will also be computed as part of computer-based regression analysis

Page 24: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Simple Linear Regression Example

• A real estate agent wishes to examine the relationship between the selling price of a home and its size (measured in square feet)

• A random sample of 10 houses is selected

– Dependent variable (y) = house price in $1000s

– Independent variable (x) = square feet

Page 25: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Sample Data for House Price Model

House Price in $1000s(y)

Square Feet (x)

245 1400312 1600279 1700308 1875199 1100219 1550405 2350324 2450319 1425255 1700

Page 26: Lecture 10 Introduction to Linear Regression and Correlation Analysis.
Page 27: Lecture 10 Introduction to Linear Regression and Correlation Analysis.
Page 28: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Correlation Coefficient

P-value

bo

b1 (the Slop)

SE(b0)

SE(b1)

R^2 explained variation by this model (coefficient of determination)

= SSR/SST

=18934.93 / 32600.5

=0.581SLR Model

Y=98.248+0.11X

Null and alternative hypotheses

H0: β1 = 0 (no linear relationship)H1: β1 # 0(linear relationship does exist)

Test statistic

T=(b1-B1) / SE(b1)=(0.11- 0) / 0.033

=3.329

P-value = 0.01<0.05 sig. so Linear relation exist

SSRSSE

SST

Page 29: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

050

100150200250300350400450

0 500 1000 1500 2000 2500 3000

Square Feet

Hou

se P

rice

($10

00s)

Graphical Presentation

• House price model: scatter plot and regression line

feet) (square 0.10977 98.24833 price house

Slope = 0.10977

Intercept = 98.248

Page 30: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Interpretation of the Slope Coefficient, b1

• b1 measures the estimated change in the average value of Y as a result of a one-unit change in X

– Here, b1 = .10977 tells us that the average value of a house increases by .10977($1000) = $109.77, on average, for each additional one square foot of size

feet) (square 0.10977 98.24833 price house

Page 31: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Comparing Standard Errors

y

y y

x

x

x

y

x

1bs small

1bs large

s small

s large

Variation of observed y values from the regression line

Variation in the slope of regression lines from different possible samples

Page 32: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Explained and Unexplained Variation

• Total variation is made up of two parts:

SSR SSE SST Total sum of Squares

Sum of Squares Regression

Sum of Squares Error

2)yy(SST 2)yy(SSE 2)yy(SSR

where: = Average value of the dependent variabley = Observed values of the dependent variable = Estimated value of y for the given x valuey

y

Page 33: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

• SST = total sum of squares

– Measures the variation of the yi values around their mean y

• SSE = error sum of squares

– Variation attributable to factors other than the relationship between x and y

• SSR = regression sum of squares

– Explained variation attributable to the relationship between x and y

(continued)

Explained and Unexplained Variation

Page 34: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

(continued)

Xi

y

x

yi

SST = (yi - y)2

SSE = (yi - yi )2

SSR = (yi - y)2

_

_

_

Explained and Unexplained Variation

y

y

y_y

Page 35: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

• The coefficient of determination is the portion of the total variation in the dependent variable that is explained by variation in the independent variable

• The coefficient of determination is also called R-squared and is denoted as R2

Coefficient of Determination, R2

SSTSSRR 2 1R0 2 where

Page 36: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Coefficient of determination

Coefficient of Determination, R2

squares of sum totalregressionby explained squares of sum

SSTSSRR 2

(continued)

Note: In the single independent variable case, the coefficient of determination is

where:R2 = Coefficient of determination

r = Simple correlation coefficient

22 rR

Page 37: Lecture 10 Introduction to Linear Regression and Correlation Analysis.

Inference about the Slope: t Test

• t test for a population slope– Is there a linear relationship between x and y?

• Null and alternative hypotheses– H0: β1 = 0 (no linear relationship)– H1: β1 0 (linear relationship does exist)

• Test statistic

– 1b

11

sβbt

2nd.f.

where:

b1 = Sample regression slope coefficient

β1 = Hypothesized slope

sb1 = Estimator of the standard error of the slope