ch13 - linear regression and correlation · 2021. 5. 5. · 10/8/18 3 step 1: look at the data...

13
10/8/18 1 Linear Regression and Correlation Dr. Rick Jerz © 2018 rjerz.com 1 Correlation and Regression Analysis Correlation Analysis is the study of the relationship between variables. It is also defined as group of techniques to measure the association between two variables. Regression Analysis is a technique used to express the relationship between two variables. If the relationship is assumed to be a straight line, this is called “linear regression.” © 2018 rjerz.com 2 Three Questions 1. Are two variables related? (correlation analysis) 2. Is there a linear relationship between two variables? (linear regression analysis) 3. How strong are these relationships? © 2018 rjerz.com 3

Upload: others

Post on 31-Jul-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

1

Linear Regression and Correlation

Dr. Rick Jerz

© 2018 rjerz.com1

Correlation and Regression Analysis

• Correlation Analysis is the study of the relationship between variables. It is also defined as group of techniques to measure the association between two variables.

• Regression Analysis is a technique used to express the relationship between two variables. If the relationship is assumed to be a straight line, this is called “linear regression.”

© 2018 rjerz.com2

Three Questions

1. Are two variables related? (correlation analysis)

2. Is there a linear relationship between two variables? (linear regression analysis)

3. How strong are these relationships?

© 2018 rjerz.com3

Page 2: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

2

Correlation and Linear Regression

© 2018 rjerz.com4

Correlation

© 2018 rjerz.com5

Correlation & Regression Example

• The sales manager of Copier Sales of America, which has a large sales force throughout the United States and Canada, wants to determine whether there is a relationship between the number of sales calls made in a month and the number of copiers sold that month. The manager selects a random sample of 10 representatives and determines the number of sales calls each representative made last month and the number of copiers sold.

© 2018 rjerz.com6

Page 3: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

3

Step 1: Look at the Data (Plot the Data)

• A Scatter Diagram is a chart that portrays the relationship between the two variables. It is the usual first step in correlation analysis

• The Dependent Variable is the variable being predicted or estimated.

• The Independent Variable provides the basis for estimation. It is the predictor variable.

© 2018 rjerz.com7

Step 2: Are they correlated?

© 2018 rjerz.com8

The Coefficient of Correlation, r

The Coefficient of Correlation (r) is a measure of the strength of the relationship between two variables. It requires interval or ratio-scaled data. • It can range from -1.00 to 1.00.• Values of -1.00 or 1.00 indicate perfect and

strong correlation.• Values close to 0.0 indicate weak correlation.• Negative values indicate an inverse relationship

and positive values indicate a direct relationship.

© 2018 rjerz.com9

Page 4: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

4

Correlation Coefficient –Interpretation

© 2018 rjerz.com10

Correlation Coefficient Equation, r

© 2018 rjerz.com11

Coefficient of Determination

The coefficient of determination (r2) is the proportion of the total variation in the dependent variable (Y) that is explained or accounted for by the variation in the independent variable (X). It is the square of the coefficient of correlation. • It ranges from 0 to 1.• It does not give any information on the direction

of the relationship between the variables.

© 2018 rjerz.com12

Page 5: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

5

Example: Correlation Coefficient

How do we interpret a correlation of 0.759? First, it is positive, so we see there is a direct relationship between the number of sales calls and the number of copiers sold. The value of 0.759 is fairly close to 1.00, so we conclude that the association is strong.

However, does this mean that more sales calls cause more sales? No, we have not demonstrated cause and effect here, only that the two variables—sales calls and copiers sold—are related.

© 2018 rjerz.com13

Coefficient of Determination (r2) - Example

• The coefficient of determination, r2 ,is 0.576, found by (0.759)2

• This is a proportion or a percent; we can say that 57.6 percent of the variation in the number of copiers sold is explained, or accounted for, by the variation in the number of sales calls.

© 2018 rjerz.com14

Step 3: How strong are they correlated?

© 2018 rjerz.com15

Page 6: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

6

Testing the Significance ofthe Correlation Coefficient

• H0: r = 0 (the correlation in the population is 0)

• H1: r ≠ 0 (the correlation in the population is not 0)• Reject H0 if:• t > ta/2,n-2 or t < -ta/2,n-2

© 2018 rjerz.com16

Example: Testing the Significance of

the Correlation CoefficientH0: r = 0 (the correlation in the population is 0)H1: r ≠ 0 (the correlation in the population is not 0)

Reject H0 if:t > ta/2,n-2 or t < -ta/2,n-2t > t0.025,8 or t < -t0.025,8

t > 2.306 or t < -2.306

© 2018 rjerz.com17

Testing the Significance ofthe Correlation Coefficient

• Equivalently, you can calculate the critical value for the correlation coefficient using

• This method gives a benchmark for the correlation coefficient.

• However, there is no p-value and is inflexible if you change your mind about α.

© 2018 rjerz.com18

Page 7: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

7

Testing Relationship with r

• Step 1: State the HypothesesDetermine whether you are using a one or two-tailed test and the level of significance (a).

H0: ρ = 0H1: ρ ≠ 0

• Step 2: Calculate the Critical ValueFor degrees of freedom n = n -2, determine tα then calculate

© 2018 rjerz.com19

Testing Relationship with r

• Make the Decision

If the sample correlation coefficient r exceeds the critical value rα, then reject H0.

If using the t statistic method, reject H0 if t > tα or if the p-value ≤ α.

© 2018 rjerz.com20

Ex: Testing the Significance ofthe Correlation Coefficient

The computed t (3.297) is within the rejection region, therefore, we will reject H0. This means the correlation in the population is not zero. From a practical standpoint, it indicates to the sales manager that there is correlation with respect to the number of sales calls made and the number of copiers sold in the population of salespeople.

© 2018 rjerz.com21

Page 8: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

8

Step 4: Is there a linear relationship? Regression

© 2018 rjerz.com22

Example: Robot Repeatability Data

© 2018 rjerz.com23

© 2018 rjerz.com24

Page 9: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

9

Bivariate Regression Analysis

• Bivariate Regression analyzes the relationship between two variables.

• It specifies one dependent (response) variable and one independent (predictor) variable.

• This hypothesized relationship may be linear, quadratic, or whatever.

© 2018 rjerz.com25

Linear Regression

• Unknown parameters areβ0 Interceptβ1 Slope

• The assumed model for a linear relationship is• yi = β 0 + β 1xi + ei, for all observations (i = 1, 2, …,

n)• The error term is not observable, is assumed

normally distributed with mean of 0 and standard deviation σ.

© 2018 rjerz.com26

Linear Regression Model

• Y “Hat”, is the estimate of Y given X• a is the Y-intercept• b is the slope of the line• X is any value of the independent variable

bXaY +=ˆ

© 2018 rjerz.com27

Page 10: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

10

Differences between Actual Y –Estimated Y

© 2018 rjerz.com28

Least Squares Principle

• Determining a regression equation by minimizing the sum of the squares (the variance) of the vertical distances between the actual Y values and the predicted values of Y.

© 2018 rjerz.com29

Calculating a and b (least squares)

22 XnXYXnXYb

-å-å

=

XbYa -=

© 2018 rjerz.com30

Page 11: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

11

Example: Finding the Regression Equation

6316.42

)20(1842.19476.18

1842.19476.18

:isequation regression The

^

^

^

^

=

+=

+=

+=

Y

Y

XY

bXaY

© 2018 rjerz.com31

Step 5: Plot the Estimated and the Actual Y’s

© 2018 rjerz.com32

Computing the Estimates of Y

• Step 1 – Using the regression equation, substitute the value of each X to solve for the estimated sales

6316.42

)20(1842.19476.18

1842.19476.18

Keller Tom

^

^

^

=

+=

+=

Y

Y

XY

4736.54

)30(1842.19476.18

1842.19476.18

Jones Soni

^

^

^

=

+=

+=

Y

Y

XY

© 2018 rjerz.com33

Page 12: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

12

Step 6: Predict other values

6316.42

)20(1842.19476.18

1842.19476.18

:isequation regression The

^

^

^

^

=

+=

+=

+=

Y

Y

XY

bXaY

© 2018 rjerz.com34

Assumptions Underlying Linear Regression

• For each value of X, there is a group of Y values, and these • Y values are normally distributed. The means of

these normal distributions of Y values all lie on the straight line of regression.

• The standard deviations of these normal distributions are equal.

• The Y values are statistically independent. This means that in the selection of a sample, the Y values chosen for a particular X value do not depend on the Y values for any other X values.

© 2018 rjerz.com35

Assumptions: Graphic

© 2018 rjerz.com36

Page 13: Ch13 - Linear Regression and Correlation · 2021. 5. 5. · 10/8/18 3 Step 1: Look at the Data (Plot the Data) •A Scatter Diagram is a chart that portrays the relationship between

10/8/18

13

Confidence Intervals for Slope and Intercept

• Confidence interval for the true slope:

• Confidence interval for the true intercept:

© 2018 rjerz.com37

Ex: Confidence Interval Estimate

• Step 4 – Use the formula above by substituting the numbers computed in previous slides

• Thus, the 95 percent confidence interval for the average sales of all sales representatives who make 25 calls is from 40.9170 up to 56.1882 copiers.

© 2018 rjerz.com38

Ex: Prediction Interval Estimate

• Step 2 – Using the information computed earlier in the confidence interval estimation example, use the formula above.

• If Sheila Baker makes 25 sales calls, the number of copiers she will sell will be between about 24 and 73 copiers

© 2018 rjerz.com39