Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linear Regression and Correlation Analysis. Regression Analysis Regression Analysis attempts to determine the strength of the relationship between one.

Similar presentations


Presentation on theme: "Linear Regression and Correlation Analysis. Regression Analysis Regression Analysis attempts to determine the strength of the relationship between one."— Presentation transcript:

1 Linear Regression and Correlation Analysis

2 Regression Analysis Regression Analysis attempts to determine the strength of the relationship between one dependent variable (usually denoted by Y) and a series of other changing variables (known as independent variables).

3 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

4 Regression Analysis One of the two variables (X, Y), say X is an independent variable/ controlled variable/ ordinary variable, Y is random Variable Relationship between X and Y is described by a linear function Dependence of Y on X or Regression of Y on X Dependence of Blood Pressure Y on X Regression of gain of weight Y on food X

5 Types of Regression Models Positive Linear Relationship Negative Linear Relationship Relationship NOT Linear No Relationship

6 Regression Analysis In Regression Analysis the dependence of Y on x is the dependence of mean µ of Y on x µ = µ (x) The curve of µ (x) is called Regression Curve Straight Regression Line is: µ (x) = k 0 + k 1 x

7 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) value Independent Variable

8 Least Squares Principle The straight Line should be fitted through the given points, so that the sum of squares of distances of those points from the line is minimum, where the distance is measured in Vertical Direction. The x-values x 1, x 2,…, x n in the Sample (x 1, y 1 ), (x 2, y 2 ), …, (x n, y n ) are not all equal.

9 Sample Regression Line (Regression Coefficient)

10 Sample Regression Line S xy = Sample Covariance S x 2 = Variance of X values S y 2 = Variance of Y values

11 Sample Regression Line The decrease of values y[%] of Leather for certain fixed values of High Pressure X[atmosphere] was measured. Find Regression Line of Y on X. xjxj YjYj 4,0002.3 6,0004.1 8,0005.7 10,0006.9

12 Sample Regression Line (Regression Coefficient)

13 Sample Regression Line Given ValuesAuxiliary Values XjXj YjYj Xj2Xj2 XjYjXjYj 4,0002.316,000,0009,200 6,0004.136,000,00024,600 8,0005.764,000,00045,600 10,0006.9100,000,00069,000 ∑x j = 28,000∑y j = 19∑X j 2 216,000,000 ∑X j Y j 148,400 Regression Line = y = 0.0077x - 0.64

14 Formula: Regression Line Intercept Slope of the Line

15 Equation of Regression Line SubjectAge XPressure YXYX2X2 Y2Y2 A43128 B48120 C56135 D61143 E67141 F70152 ∑345819

16 Equation of Regression Line SubjectAge X Pressure Y XYX2X2 Y2Y2 A431285,5041,84916,384 B481205,7602,30414,400 C561357,5603,13618,225 D611438,7233,72120,449 E671419,4474,48919,881 F7015210,6404,90023,104 ∑34581947,63420,399112,443

17 Problem 1 Find and sketch or graph the Sample Regression Line of y and x for the points (-1, 1), (0, 1.7), and (1, 3).

18 Problem 3 Find and sketch or graph the Sample Regression Line of y and x for the points (2, 12), (5, 24), (9, 33) and (14, 50).

19 Problem 5 Find and sketch or graph the Sample Regression Line of y and x for the given data: Also find Stopping Distance at 35 mph. Speed X [mph] of a car 30405060 Stopping Distance Y [ft] 150195240295

20 Problem 7 Find and sketch or graph the Sample Regression Line of y and x for the given data: Revolutions per Minute = X 400500600700750 Power of a Diesel Engine [hp] = Y 5801030142018802100

21 Problem 9 Find and sketch or graph the Sample Regression Line of y and x for the given data: Voltage X [V] 40 80 110 Current Y[A] 5.14.810.010.313.012.7

22 Confidence Interval Assumptions  The x-values x 1, x 2,…, x n in the Sample (x 1, y 1 ), (x 2, y 2 ), …, (x n, y n ) are not all equal.  For each fixed x, the random variable Y is normal with mean µ (x) = k 0 + k 1 x and variance б 2 independent of x  The n performances of the experiment by which we obtain a sample (x 1, y 1 ), (x 2, y 2 ), …, (x n, y n ) are independent.

23 Steps to Find Confidence Interval  Choose a Confidence Level γ (95%, 99%, etc)  Determine the solution C of the equation F(C) = ½ (1 + γ) [ Table t-distribution with n-2 df ]  Using Sample Compute (n-1)S x 2, (n-1)S xy and K 1  Compute K  Confidence Interval (K 1 – K ≤ K 1 ≤ K 1 + K)

24 Problem 11 Find a 95% Confidence Interval for the Regression Coefficient K1, Assuming that A2 and A3 hold, for the given Sample data: X = Deformation of a Certain Steel [mm] 6911132226283335 Y = Brinell Hardness [kg/ mm 2 ] 686765534440373432

25 Problem 12 Find a 95% Confidence Interval for the Regression Coefficient K1, Assuming that A2 and A3 hold, for the given Sample data: Revolutions per Minute = X 400500600700750 Power of a Diesel Engine [hp] = Y 5801030142018802100

26 Problem 13 Find a 95% Confidence Interval for the Regression Coefficient K1, Assuming that A2 and A3 hold, for the given Sample data: Humidity of Air X [%] 10203040 Expansion of Gelatin Y [%] 0.81.62.32.8

27 Correlation Analysis Both variables (X, Y) are random variables –Grades X and Y of students in Math and Physics –Hardness X of steel plates in the centre and hardness Y near the edges of the plates

28 Scatter Plots and Correlation A scatter plot (or scatter diagram) is used to show the relationship between two variables Correlation analysis is used to measure strength of the association (linear relationship) between two variables –Only concerned with strength of the relationship –No causal effect is implied

29 Scatter Plot Examples y x y x y y x x Linear relationshipsCurvilinear relationships

30 Scatter Plot Examples y x y x y y x x Strong relationshipsWeak relationships

31 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

32 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

33 r = +.3r = +1 Approximate r Values y x y x y x y x y x r = -1 r = -.6r = 0

34 Population Correlation Coefficient Theorem: The Correlation Coefficient ρ satisfies -1 ≤ ρ ≤ 1. In particular ρ = ±1, if and only if X and Y are linearly related i.e Y = rX + δ X = r*Y + δ* X and Y are called uncorrelated, if ρ = 0.

35 Theorem (Normal Distribution) Independent X and Y are uncorrelated. If (X, Y) is normal, the uncorrelated X and Y are independent. Example: If X assumes -1, 0, 1 with probability 1/3. and Y = X 2

36 Test For Correlation Coefficient : ρ  Test H 0 : ρ = 0 and H 1 : ρ > 0  Choose a Significance Level α (5%, 1%, etc)  Determine the solution C of the equation P(T ≤ C) = 1 - α [ Table t-distribution with n-2 df ]  Compute r and t  If t ≤ C, accept the Hypothesis, otherwise reject the Hypothesis.

37 Example: Correlation Coefficient Tree Height Trunk Diameter xyy2y2 x2x2 yx 358 499 277 336 6013 217 4511 5112  =321  =73

38 Example: Correlation Coefficient Tree Height Trunk Diameter xyy2y2 x2x2 yx 358280122564 499441240181 27718972949 336198108936 60137803600169 21714744149 45114952025121 51126122601144  =321  =73  =3142  =14111  =713

39 Trunk Diameter, x Tree Height, y Calculation Example r = 0.886 → relatively strong positive linear association between x and y

40 Excel Output Excel Correlation Output Tools / data analysis / correlation… Correlation between Tree Height and Trunk Diameter

41 Significance Test for Correlation Hypotheses H 0 : ρ = 0 (no correlation) H A : ρ ≠ 0 (correlation exists) Test statistic – (with n – 2 degrees of freedom)

42 Example: Produce Stores Is there evidence of a linear relationship between tree height and trunk diameter at the.05 level of significance? H 0 : ρ = 0 (No correlation) H 1 : ρ ≠ 0 (correlation exists)  =.05, df = 8 - 2 = 6

43 Example: Test Solution Conclusion: There is evidence of a linear relationship at the 5% level of significance Decision: Reject H 0 Reject H 0  /2=.025 -t α/2 Do not reject H 0 0 t α/2  /2=.025 -2.44692.4469 4.68 d.f. = 8-2 = 6

44

45 Linear component Population Linear Regression The population regression model: Population y intercept Population Slope Coefficient Random Error term, or residual Dependent Variable Independent Variable Random Error component

46 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

47 Population Linear Regression (continued) Random Error for this x value y x Observed Value of y for x i Predicted Value of y for x i xixi Slope = β 1 Intercept = β 0 εiεi

48 Residual Analysis Purposes –Examine for linearity assumption –Examine for constant variance for all levels of x –Evaluate normal distribution assumption Graphical Analysis of Residuals –Can plot residuals vs. x –Can create histogram of residuals to check for normality

49 Residual Analysis for Linearity Not Linear Linear x residuals x y x y x

50 Residual Analysis for Constant Variance Non-constant variance Constant variance xx y x x y residuals

51 Excel Output RESIDUAL OUTPUT Predicted House PriceResiduals 1251.92316-6.923162 2273.8767138.12329 3284.85348-5.853484 4304.062843.937162 5218.99284-19.99284 6268.38832-49.38832 7356.2025148.79749 8367.17929-43.17929 9254.667464.33264 10284.85348-29.85348

52 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

53 Sample Data for House Price Model House Price in $1000s (y) Square Feet (x) 2451400 3121600 2791700 3081875 1991100 2191550 4052350 3242450 3191425 2551700

54 Regression Using Excel

55 Excel Output Regression Statistics Multiple R0.76211 R Square0.58082 Adjusted R Square0.52842 Standard Error41.33032 Observations10 ANOVA dfSSMSF Significance F Regression118934.9348 11.084 80.01039 Residual813665.56521708.1957 Total932600.5000 Coefficien tsStandard Errort Stat P- valueLower 95% Upper 95% Intercept98.2483358.033481.69296 0.1289 2-35.57720 232.0738 6 Square Feet0.109770.032973.32938 0.0103 90.033740.18580 The regression equation is:

56 Graphical Presentation House price model: scatter plot and regression line Slope = 0.10977 Intercept = 98.248

57 Interpretation of the Intercept, b 0 b 0 is the estimated average value of Y when the value of X is zero (if x = 0 is in the range of observed x values) –Here, no houses had 0 square feet, so b 0 = 98.24833 just indicates that, for houses within the range of sizes observed, $98,248.33 is the portion of the house price not explained by square feet

58 Interpretation of the Slope Coefficient, b 1 b 1 measures the estimated change in the average value of Y as a result of a one-unit change in X –Here, b 1 =.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

59 Least Squares Regression Properties The sum of the residuals from the least squares regression line is 0 ( ) The sum of the squared residuals is a minimum (minimized ) The simple regression line always passes through the mean of the y variable and the mean of the x variable The least squares coefficients are unbiased estimates of β 0 and β 1

60 Explained and Unexplained Variation Total variation is made up of two parts: Total sum of Squares Sum of Squares Regression Sum of Squares Error where: = Average value of the dependent variable y = Observed values of the dependent variable = Estimated value of y for the given x value

61 SST = total sum of squares –Measures the variation of the y i 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 Explained and Unexplained Variation

62 XiXi y x yiyi SST =  (y i - y) 2 SSE =  (y i - y i ) 2  SSR =  (y i - y) 2  _ _ _ Explained and Unexplained Variation y  y y _ y 

63 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 R 2 Coefficient of Determination, R 2 where

64 Coefficient of determination Coefficient of Determination, R 2 Note: In the single independent variable case, the coefficient of determination is where: R 2 = Coefficient of determination r = Simple correlation coefficient

65 R 2 = +1 Examples of Approximate R 2 Values y x y x R 2 = 1 Perfect linear relationship between x and y: 100% of the variation in y is explained by variation in x

66 Examples of Approximate R 2 Values y x y x 0 < R 2 < 1 Weaker linear relationship between x and y: Some but not all of the variation in y is explained by variation in x

67 Examples of Approximate R 2 Values R 2 = 0 No linear relationship between x and y: The value of Y does not depend on x. (None of the variation in y is explained by variation in x) y x R 2 = 0

68 Excel Output Regression Statistics Multiple R0.76211 R Square0.58082 Adjusted R Square0.52842 Standard Error41.33032 Observations10 ANOVA dfSSMSF Significance F Regression118934.9348 11.084 80.01039 Residual813665.56521708.1957 Total932600.5000 Coefficien tsStandard Errort Stat P- valueLower 95% Upper 95% Intercept98.2483358.033481.69296 0.1289 2-35.57720 232.0738 6 Square Feet0.109770.032973.32938 0.0103 90.033740.18580 58.08% 58.08% of the variation in house prices is explained by variation in square feet

69 Standard Error of Estimate The standard deviation of the variation of observations around the regression line is estimated by Where SSE = Sum of squares error n = Sample size k = number of independent variables in the model

70 The Standard Deviation of the Regression Slope The standard error of the regression slope coefficient (b 1 ) is estimated by where: = Estimate of the standard error of the least squares slope = Sample standard error of the estimate

71 Excel Output Regression Statistics Multiple R0.76211 R Square0.58082 Adjusted R Square0.52842 Standard Error41.33032 Observations10 ANOVA dfSSMSF Significance F Regression118934.9348 11.084 80.01039 Residual813665.56521708.1957 Total932600.5000 Coefficien tsStandard Errort Stat P- valueLower 95% Upper 95% Intercept98.2483358.033481.69296 0.1289 2-35.57720 232.0738 6 Square Feet0.109770.032973.32938 0.0103 90.033740.18580

72 Comparing Standard Errors y yy x x x y x Variation of observed y values from the regression line Variation in the slope of regression lines from different possible samples

73 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 –H 0 : β 1 = 0(no linear relationship) –H 1 : β 1  0(linear relationship does exist) Test statistic – where: b 1 = Sample regression slope coefficient β 1 = Hypothesized slope s b1 = Estimator of the standard error of the slope

74 House Price in $1000s (y) Square Feet (x) 2451400 3121600 2791700 3081875 1991100 2191550 4052350 3242450 3191425 2551700 Estimated Regression Equation: The slope of this model is 0.1098 Does square footage of the house affect its sales price? Inference about the Slope: t Test (continued)

75 Inferences about the Slope: t Test Example H 0 : β 1 = 0 H A : β 1  0 Test Statistic: t = 3.329 There is sufficient evidence that square footage affects house price From Excel output: Reject H 0 Coefficient s Standard Errort Stat P- value Intercept98.2483358.03348 1.6929 6 0.1289 2 Square Feet0.109770.03297 3.3293 8 0.0103 9 tb1b1 Decision: Conclusion: Reject H 0  /2=.025 -t α/2 Do not reject H 0 0 t α/2  /2=.025 -2.30602.3060 3.329 d.f. = 10-2 = 8

76 Regression Analysis for Description Confidence Interval Estimate of the Slope: Excel Printout for House Prices: At 95% level of confidence, the confidence interval for the slope is (0.0337, 0.1858) Coefficient s Standard Errort StatP-valueLower 95% Upper 95% Intercept98.2483358.033481.692960.12892-35.57720232.07386 Square Feet0.109770.032973.329380.010390.033740.18580 d.f. = n - 2

77 Regression Analysis for Description Since the units of the house price variable is $1000s, we are 95% confident that the average impact on sales price is between $33.70 and $185.80 per square foot of house size Coefficient s Standard Errort StatP-valueLower 95% Upper 95% Intercept98.2483358.033481.692960.12892-35.57720232.07386 Square Feet0.109770.032973.329380.010390.033740.18580 This 95% confidence interval does not include 0. Conclusion: There is a significant relationship between house price and square feet at the.05 level of significance

78 Confidence Interval for the Average y, Given x Confidence interval estimate for the mean of y given a particular x p Size of interval varies according to distance away from mean, x

79 Confidence Interval for an Individual y, Given x Confidence interval estimate for an Individual value of y given a particular x p This extra term adds to the interval width to reflect the added uncertainty for an individual case

80 Interval Estimates for Different Values of x y x Prediction Interval for an individual y, given x p x p y = b 0 + b 1 x  x Confidence Interval for the mean of y, given x p

81 House Price in $1000s (y) Square Feet (x) 2451400 3121600 2791700 3081875 1991100 2191550 4052350 3242450 3191425 2551700 Estimated Regression Equation: Example: House Prices Predict the price for a house with 2000 square feet

82 Example: House Prices Predict the price for a house with 2000 square feet: The predicted price for a house with 2000 square feet is 317.85($1,000s) = $317,850 (continued)

83 Estimation of Mean Values: Example Find the 95% confidence interval for the average price of 2,000 square-foot houses Predicted Price Y i = 317.85 ($1,000s)  Confidence Interval Estimate for E(y)|x p The confidence interval endpoints are 280.66 -- 354.90, or from $280,660 -- $354,900

84 Estimation of Individual Values: Example Find the 95% confidence interval for an individual house with 2,000 square feet Predicted Price Y i = 317.85 ($1,000s)  Prediction Interval Estimate for y|x p The prediction interval endpoints are 215.50 -- 420.07, or from $215,500 -- $420,070


Download ppt "Linear Regression and Correlation Analysis. Regression Analysis Regression Analysis attempts to determine the strength of the relationship between one."

Similar presentations


Ads by Google