Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-1 Lesson 11: Linear Regression and Correlation.

Similar presentations


Presentation on theme: "Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-1 Lesson 11: Linear Regression and Correlation."— Presentation transcript:

1 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-1 Lesson 11: Linear Regression and Correlation

2 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-2 Outline Correlation Analysis Regression Analysis Standard error of estimate Confidence interval and prediction interval Inference about the regression slope Cautions about the interpretation of significance Evaluating the model

3 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Correlation Analysis Correlation Analysis is a group of statistical techniques used to measure the strength of the association between two variables. A Scatter Diagram is a chart that portrays the relationship between the two variables. The Dependent Variable is the variable being predicted or estimated. The Independent Variable provides the basis for estimation. It is the predictor variable.

4 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-4 Example Suppose a university administrator wishes to determine whether any relationship exists between a student’s score on an entrance examination and that student’s cumulative GPA. A sample of eight students is taken. The results are shown below StudentExam ScoreGPA A742.6 B692.2 C853.4 D632.3 E823.1 F602.1 G793.2 H913.8

5 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-5 Scatter Diagram: GPA vs. Exam Score | | | | | | | | | | 50 55 60 65 70 75 80 85 90 95 Exam Score 4.00 - 3.75 - 3.50 - 3.25 - 3.00 - 2.75 - 2.50 - 2.25 - 2.00 - Cumulative GPA

6 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data The Coefficient of Correlation, r The Coefficient of Correlation (r) is a measure of the strength of the linear 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.

7 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Formula for r We calculate the coefficient of correlation from the following formulas. Sample covariance between x and y Sample standard deviation of x Sample standard deviation of y

8 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Coefficient of Determination The coefficient of determination (r 2 ) 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. Special cases: No correlation: r=0, r 2 =0. Perfect negative correlation: r=-1, r 2 =1. Perfect positive correlation: r=+1, r 2 =1.

9 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data EXAMPLE 1 Dan Ireland, the student body president at Toledo State University, is concerned about the cost to students of textbooks. He believes there is a relationship between the number of pages in the text and the selling price of the book. To provide insight into the problem he selects a sample of eight textbooks currently on sale in the bookstore. Draw a scatter diagram. Compute the correlation coefficient. BookPagePrice ($) Intro to History50084 Basic Algebra70075 Intro to Psyc80099 Intro to Sociology60072 Bus. Mgt.40069 Intro to Biology50081 Fund. of Jazz60063 Princ. Of Nursing80093

10 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-10 Example 1 continued

11 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-11 Example 1 continued BookPagePrice ($) XY Intro to History50084 Basic Algebra70075 Intro to Psyc80099 Intro to Sociology60072 Bus. Mgt.40069 Intro to Biology50081 Fund. of Jazz60063 Princ. Of Nursing80093 Total4,900636 The correlation between the number of pages and the selling price of the book is 0.614. This indicates a moderate association between the variable.

12 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-12 EXAMPLE 1 continued Is there a linear relation between number of pages and price of books? Test the hypothesis that there is no correlation in the population. Use a.02 significance level. Under the null hypothesis that there is no correlation in the population. The statistic follows student t-distribution with (n-2) degree of freedom.

13 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data EXAMPLE 1 continued Step 1: H 0 : The correlation in the population is zero. H 1 : The correlation in the population is not zero. Step 2: H 0 is rejected if t>3.143 or if t<-3.143. There are 6 degrees of freedom, found by n – 2 = 8 – 2 = 6. Step 3: To find the value of the test statistic we use: Step 4: H 0 is not rejected. We cannot reject the hypothesis that there is no correlation in the population. The amount of association could be due to chance.

14 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Regression Analysis In regression analysis we use the independent variable (X) to estimate the dependent variable (Y). The relationship between the variables is linear. Both variables must be at least interval scale.

15 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-15 Simple Linear Regression Model Relationship Between Variables Is a Linear Function Y intercept Slope Random Error Dependent (Response) Variable Independent (Explanatory) Variable x y 00 Run Rise  1 = Rise/Run  0 and  1 are unknown, therefore, are estimated from the data.

16 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-16 Finance Application: Market Model One of the most important applications of linear regression is the market model. It is assumed that rate of return on a stock (R) is linearly related to the rate of return on the overall market (R m ). Rate of return on a particular stock Rate of return on some major stock index The beta coefficient measures how sensitive the stock’s rate of return is to changes in the level of the overall market. R =  0 +  1 R m + 

17 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-17 Assumptions Underlying Linear Regression For each value of X, there is a group of Y values, and these Y values are normally distributed. Y i ~ N(E(Y|X),  i 2 ), i=1,2,…,n The means of these normal distributions of Y values all lie on the straight line of regression. E(Y|X) =  0 +  1 X The standard deviations of these normal distributions are equal.  i 2=  2 i=1,2,…,n

18 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-18 Assumptions Underlying Linear Regression y i and y k are independently drawn from the population, say, as in sampling with replacement.

19 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-19 Choosing the line that fits best The estimates are determined by drawing a sample from the population of interest, calculating sample statistics. producing a straight line that cuts into the data.           The question is: Which straight line fits best? x y

20 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-20 3 3     4 1 1 4 (1,2) 2 2 (2,4) (3,1.5) Sum of squared differences =(2 - 1) 2 +(4 - 2) 2 +(1.5 - 3) 2 + (4,3.2) (3.2 - 4) 2 = 6.89 Sum of squared differences =(2 -2.5) 2 +(4 - 2.5) 2 +(1.5 - 2.5) 2 +(3.2 - 2.5) 2 = 3.99 2.5 Let us compare two lines The second line is horizontal The smaller the sum of squared differences the better the fit of the line to the data. That is, the line with the least sum of squares (of differences) will fit the line best. The best line is the one that minimizes the sum of squared vertical differences between the points and the line. Choosing the line that fits best

21 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-21 Choosing the line that fits best Ordinary Least Squares (OLS) Principle Straight lines can be described generally by Y = b 0 + b 1 X Finding the best line with smallest sum of squared difference is the same as Let b 0 * and b 1 * be the solution of the above problem. Y * = b 0 * + b 1 * X is known as the “average predicted value” (or simply “predicted value”) of y for any X.

22 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-22 Coefficient estimates from the ordinary least squares (OLS) principle Solving the minimization problem implies the first order conditions:

23 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-23 Coefficient estimates from the ordinary least squares (OLS) principle Solving the first order conditions implies

24 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data EXAMPLE 2 continued from Example 1 Develop a regression equation for the information given in EXAMPLE 1. The information there can be used to estimate the selling price based on the number of pages.

25 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-25 Example 2 continued from Example 1 The regression equation is: Y * = 48.0 +.05143X The equation crosses the Y-axis at $48. A book with no pages would cost $48. The slope of the line is.05143. Each additional page costs about $0.05 or five cents. The sign of the b value and the sign of r will always be the same.

26 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-26 Example 2 continued from Example 1 We can use the regression equation to estimate values of Y. The estimated selling price of an 800 page book is $89.14, found by Y * = 48.0 +.05143X = 48.0 +.05143(800) = 89.14

27 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-27 Standard Error of Estimate (denoted s e or S y.x ) Measures the reliability of the estimating equation A measure of dispersion Measures the variability, or scatter of the observed values around the regression line 

28 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-28 More Accurate Estimator of X, Y Relationship Less Accurate Estimator of X, Y Relationship Scatter Around the Regression Line

29 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-29 s e measures the dispersion of the points around the regression line If s e = 0, equation is a “ perfect ” estimator s e is used to compute confidence intervals of the estimated value Assumptions: Observed Y values are normally distributed around each estimated value of Y * Constant variance Interpreting the Standard Error of the Estimate

30 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-30 X1X1 X2X2 X Y f(e) y values are normally distributed around the regression line. For each x value, the “spread” or variance around the regression line is the same. Regression Line Variation of Errors Around the Regression Line

31 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-31 Dependent Variable ( Y) Independent Variable (X) Y = b 0 + b 1 X + 2s e Y = b 0 + b 1 X + 1s e Y = b 0 + b 1 X - 1s e Y = b 0 + b 1 X - 2s e Y = b 0 + b 1 X regression line  2s e (95.5% Lie in this Region)  Scatter around the Regression Line  1s e (68% Lie in this Region)

32 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-32 Example 3 continued from Example 1 and 2. Find the standard error of estimate for the problem involving the number of pages in a book and the selling price.

33 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-33 Equations for the Interval Estimates Confidence Interval for the Mean of y Prediction Interval for the Mean of y

34 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-34 Confidence Interval Estimate for Mean Response X The following factors influence the width of the interval: Std Error, Sample Size, X Value y* = b 0 +b 1 x i

35 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Confidence Interval continued from Example 1, 2 and 3. For books of 800 pages long, what is that 95% confidence interval for the mean price? This calls for a confidence interval on the average price of books of 800 pages long.

36 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Prediction Interval continued from Example 1, 2 and 3. For a book of 800 pages long, what is the 95% prediction interval for its price? This calls for a prediction interval on the price of an individual book of 800 pages long.

37 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-37 1.Slope (b 1 ) Estimated Y changes by b 1 for each 1 unit increase in X 2.Y-Intercept (b 0 ) Estimated value of Y when X = 0 Interpretation of Coefficients

38 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-38 1.Tests if there is a linear relationship between X & Y 2.Involves population slope   3.Hypotheses H 0 :   = 0 (no linear relationship) H 1 :    0 (linear relationship) 4.Theoretical basis is sampling distribution of slopes Test of Slope Coefficient ( b 1 )

39 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-39 Sampling Distribution of the Least Squares Coefficient Estimator If the standard least squares assumptions hold, then b 1 is an unbiased estimator of  1 and has a population variance and an unbiased sample variance estimator Bias = E(b 1 )   1 “Unbiasd” means E(b 1 )   1 =0

40 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-40 Basis for Inference About the Population Regression Slope Let  1 be a population regression slope and b 1 its least squares estimate based on n pairs of sample observations. Then, if the standard regression assumptions hold and it can also be assumed that the errors  i are normally distributed, the random variable is distributed as Student ’ s t with (n – 2) degrees of freedom. In addition the central limit theorem enables us to conclude that this result is approximately valid for a wide range of non-normal distributions and large sample sizes, n.

41 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-41 Tests of the Population Regression Slope If the regression errors  i are normally distributed and the standard least squares assumptions hold (or if the distribution of b 1 is approximately normal), the following tests have significance value  : 1.To test either null hypothesis H 0 :  1 =  1 * or H 0 :  1   1 * against the alternative H 1 :  1 >  1 * The decision rule is to reject if

42 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-42 Tests of the Population Regression Slope 2.To test either null hypothesis H 0 :  1 =  1 * or H 0 :  1 >  1 * against the alternative H 1 :  1   1 * the decision rule is to reject if

43 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-43 Tests of the Population Regression Slope 3.To test either null hypothesis H 0 :  1 =  1 * against the alternative H 1 :  1   1 * the decision rule is to reject if Equivalently

44 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-44 Confidence Intervals for the Population Regression Slope  1 If the regression errors  i, are normally distributed and the standard regression assumptions hold, a 100(1 -  )% confidence interval for the population regression slope  1 is given by

45 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-45 Significance Test and Estimation for Slope If the regression assumptions hold, we can reject H 0 :  1 = 0 at the  level of significance (probability of Type I error equal to  ) if and only if the appropriate rejection point condition holds or, equivalently, if the corresponding p-value is less than . Test Statistic t , t  /2 and p-values are based on n – 2 degrees of freedom. AlternativeReject H 0 if: p-Value 100(1-  )% Confidence Interval for  1

46 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-46 Significance Test and Estimation for y- Intercept If the regression assumptions hold, we can reject H 0 :  0 = 0 at the  level of significance (probability of Type I error equal to  ) if and only if the appropriate rejection point condition holds or, equivalently, if the corresponding p-value is less than . Test Statistic t , t  /2 and p-values are based on n – 2 degrees of freedom. AlternativeReject H 0 if: p-Value 100(1-  )% Conf Interval for  0

47 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-47 Some cautions about the interpretation of significance tests Rejecting H 0 : b 1 = 0 and concluding that the relationship between x and y is significant does not enable us to conclude that a cause-and-effect relationship is present between x and y. Causation requires: Association Accurate time sequence Other explanation for correlation Correlation  Causation

48 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-48 Some cautions about the interpretation of significance tests Just because we are able to reject H 0 :  1 = 0 and demonstrate statistical significance does not enable us to conclude that there is a linear relationship between x and y. Linear relationship is a very small subset of possible relationship among variables. A test of linear versus nonlinear relationship requires another batch of analysis.

49 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-49 Variation Measures Coeff. Of Determination Standard Error of Estimate Test Coefficients for Significance y i * = b 0 +b 1 x i Evaluating the Model

50 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-50 Y X  Y X i Total Sum of Squares (Y i - Y) 2 Unexplained Sum of Squares (Y i -  Y i * ) 2 Explained Sum of Squares (Y i * - Y) 2 YiYi SST SSE SSR y i * = b 0 +b 1 x i Variation Measures

51 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-51 Total Sum of Squares (SST) Measures variation of observed Y i around the mean,  Y Explained Variation (SSR) Variation due to relationship between X & Y Unexplained Variation (SSE) Variation due to other factors SST=SSR+SSE Measures of Variation in Regression

52 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-52 R 2 (=r 2, the coefficient of determination) measures the proportion of the variation in y that is explained by the variation in x. R 2 takes on any value between zero and one. R 2 = 1: Perfect match between the line and the data points. R 2 = 0: There are no linear relationship between x and y. Variation in y (SST) = SSR + SSE

53 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Summarizing the Example ’ s results (Example 1, 2 and 3) The estimated selling price for a book with 800 pages is $89.14. The standard error of estimate is $10.41. The 95 percent confidence interval for all books with 800 pages is $89.14 ± $15.31. This means the limits are between $73.83 and $104.45. The 95 percent prediction interval for a particular book with 800 pages is $89.14 ± $29.72. The means the limits are between $59.42 and $118.86. These results appear in the following output.

54 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-54 Example 3 continued Regression Analysis: Price versus Pages The regression equation is Price = 48.0 + 0.0514 Pages Predictor Coef SE Coef T P Constant 48.00 16.94 2.83 0.030 Pages 0.05143 0.02700 1.90 0.105 S = 10.41 R-Sq = 37.7% R-Sq(adj) = 27.3% Analysis of Variance Source DF SS MS F P Regression 1 393.4 393.4 3.63 0.105 Residual Error 6 650.6 108.4 Total 7 1044.0

55 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Testing for Linearity Key Argument: If the value of y does not change linearly with the value of x, then using the mean value of y is the best predictor for the actual value of y. This implies is preferable. If the value of y does change linearly with the value of x, then using the regression model gives a better prediction for the value of y than using the mean of y. This implies is preferable.

56 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Three Tests for Linearity Testing the Coefficient of Correlation H 0 :  = 0 There is no linear relationship between x and y. H 1 :   0 There is a linear relationship between x and y. Test Statistic: Testing the Slope of the Regression Line H 0 :   = 0 There is no linear relationship between x and y. H 1 :    0 There is a linear relationship between x and y. Test Statistic:

57 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Three Tests for Linearity The Global F-test H 0 : There is no linear relationship between x and y. H 1 : There is a linear relationship between x and y. Test Statistic: [Variation in y] = SSR + SSE. Large F results from a large SSR. Then, much of the variation in y is explained by the regression model. The null hypothesis should be rejected; thus, the model is valid. Note: At the level of simple linear regression, the global F-test is equivalent to the t-test on b 1. When we conduct regression analysis of multiple variables, the global F-test will take on a unique function.

58 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-58 Purposes Examine Linearity Evaluate violations of assumptions Graphical Analysis of Residuals Plot residuals versus X i values Difference between actual Y i & predicted Y i * Studentized residuals: Allows consideration for the magnitude of the residuals Residual Analysis

59 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-59 Residual Analysis for Linearity Not LinearLinear OK X e e X

60 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-60 Heteroscedasticity OK Homoscedasticity Using Standardized Residuals SR X X Residual Analysis for Homoscedasticity When the requirement of a constant variance (homoscedasticity) is violated we have heteroscedasticity.

61 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-61 Residual Analysis for Independence Not IndependentIndependent X SR X OK

62 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-62 A time series is constituted if data were collected over time. Examining the residuals over time, no pattern should be observed if the errors are independent. When a pattern is detected, the errors are said to be autocorrelated. Autocorrelation can be detected by graphing the residuals against time. Non-independence of error variables

63 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-63 + + + + + + + + + + + + + + + + + + + + + + + + + Time Residual Time + + + Note the runs of positive residuals, replaced by runs of negative residuals Note the oscillating behavior of the residuals around zero. 00 Patterns in the appearance of the residuals over time indicates that autocorrelation exists.

64 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-64 Should be close to 2. If not, examine the model for autocorrelation. Used when data is collected over time to detect autocorrelation (Residuals in one time period are related to residuals in another period) Measures Violation of independence assumption The Durbin-Watson Statistic

65 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-65 An outlier is an observation that is unusually small or large. Several possibilities need to be investigated when an outlier is observed: There was an error in recording the value. The point does not belong in the sample. The observation is valid. Identify outliers from the scatter diagram. It is customary to suspect an observation is an outlier if its |standard residual| > 2 Outliers

66 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-66 + + + + + + + + + + + + + + + + + The outlier causes a shift in the regression line … but, some outliers may be very influential ++++++++++ An outlier An influential observation

67 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-67 Nonnormality or heteroscedasticity can be remedied using transformations on the y variable. The transformations can improve the linear relationship between the dependent variable and the independent variables. Many computer software systems allow us to make the transformations easily. Remedying violations of the required conditions

68 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-68 A brief list of transformations Y ’ = log y (for y > 0) Use when the s e increases with y, or Use when the error distribution is positively skewed y ’ = y 2 Use when the s e 2 is proportional to E(y), or Use when the error distribution is negatively skewed y ’ = y 1/2 (for y > 0) Use when the s e 2 is proportional to E(y) y ’ = 1/y Use when s e 2 increases significantly when y increases beyond some value.

69 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-69 Example: Transformation to get linearity Not Linear OK X e Linear e X Y i = b 0 + b X i + e i Y i = b 0 + b 1 X i + b 2 X i 2 + e i

70 Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-70 - END - Lesson 11: Linear Regression and Correlation


Download ppt "Ka-fu Wong © 2004 ECON1003: Analysis of Economic Data Lesson11-1 Lesson 11: Linear Regression and Correlation."

Similar presentations


Ads by Google