1 / 51

Understanding Simple Linear Regression in Statistics

Learn the basics of simple linear regression, including the least squares method, estimation of coefficients, hypothesis testing, and interpreting the regression line. Gain insights into how this statistical technique is used to analyze relationships between variables.

crowl
Télécharger la présentation

Understanding Simple Linear Regression in Statistics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Warm-Up The least squares slope b1 is an estimate of the true slope of the line that relates global average temperature to CO2. Since b1 = 0.0103 is very close to 0, could it be that the true slope is NOT significantly different from 0 (that is, atmospheric CO2 gives very little information about global average temperature)?

  2. Simple Linear Regression1. review of least squares procedure2. inference for least squares lines Inference for Simple Linear Regression

  3. 1. Review of Least Squares Procedure Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) • We will examine the relationship between quantitative variables x and y via a mathematical equation. • The motivation for using the technique: • Forecast the value of a response variable (y) from the value of explanatory variables (x1, x2,…xk.). • Analyze the specific relationship between the explanatory variable and the dependent variable.

  4. The Model The model has a deterministic and a probabilistic component House Cost Building a house costs about $75 per square foot. House cost = 25000 + 75(Size) Most lots sell for $25,000 House size

  5. The Model However, house costs vary even among same size houses! Since cost behave unpredictably, we add a random component. House Cost Most lots sell for $25,000 + e House cost = 25000 + 75(Size) House size

  6. The Model • The first order linear model y = response variable x = explanatory variable b0 = y-intercept b1 = slope of the line e = error variable b0 and b1 are unknown populationparameters, therefore are estimated from the data. y Rise b1 = Rise/Run Run b0 x

  7. The Least Squares (Regression) Line A good line is one that minimizes the sum of squared differences between the points and the line.

  8. The Estimated Coefficients Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) To calculate the estimates of the slope and intercept of the least squares line , use the formulas: The least squares prediction equation that estimates the mean value of y for a particular value of x is:

  9. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) Example: The Least Squares Regression Line • A car dealer wants to find the relationship between the odometer reading and the selling price of used cars. • A random sample of 100 cars is selected, and the data recorded. • Find the regression line. Independent variable x Dependent variable y

  10. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) The Least Squares Regression Line • Solution • Solving by hand: Calculate a number of statistics where n = 100.

  11. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) The Least Squares Regression Line

  12. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) Interpreting the Least Squares Regression Line 17248.73 No data 0 The intercept is b0 = $17248.73. This is the slope of the line. For each additional mile on the odometer, the price decreases by an average of $0.0669 Do not interpret the intercept as the “Price of cars that have not been driven”

  13. Random Error Component e:Assumptions for Inference • The random error e is a critical part of the regression model. • To do statistical inference, four requirements involving the distribution of e must be satisfied. • The distribution of the e’s can be described by a normalmodel • The mean of e is zero: E(e) = 0. • The standard deviation SD(e) of e, denoted se, is the samefor all values of x. • The set of errors associated with different values of y are all independent.

  14. E(y|x3) b0 + b1x3 E(y|x2) b0 + b1x2 E(y|x1) b0 + b1x1 The Normality of e The distribution of the e’s can be described by a normal model The mean of e is zero: E(e) = 0. The standard deviation of e is sefor all values of x. The standard deviation seremains constant, m3 m2 but the mean value changes with x m1 From the first three assumptions we have: y is normally distributed with mean E(y) = b0 + b1x, and a constant standard deviation se x1 x2 x3

  15. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) Assessing the Model • Hypothesis test for the slope H0: b1 = 0 HA: b1 0 (or < 0,or > 0) • Check the value of r2 • Examine the residuals The above methods used to assess the model use the value of the Sum of Squares of the Errors, denoted SSE.

  16. Warm-Up (cont.) Results of hypothesis test H0 : 1 = 0 HA : 1  0 Reject H0 Confidence interval for 1

  17. A shortcut formula Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) SSE: Sum of Squares of the Errors • This is the sum of the squared differences between the observed y’s and the predicted y’s given by the regression line. • It can serve as a measure of how well the line fits the data. SSE is defined by

  18. Standard Error of Estimate • E(e) = 0. The mean error is equal to zero. • SD(e) is denoted by se. If se is small the errors tend to be close to zero (the mean error), and the model describes the data well. • Therefore we can use se as a measure of the suitability of using a linear model. • An estimator of se is given by se

  19. It is hard to assess the model based on seeven when compared with the mean value of y. Standard Error of Estimate,Example • Example: • Calculate the standard error of estimate for the previous example and describe what it tells you about the model fit. • Solution

  20. q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q Testing the slope • When no linear relationship exists between two variables, the regression line should be horizontal. q q Linear relationship. Linear relationship. Linear relationship. Linear relationship. No linear relationship. Different inputs (x) yield the same output (y). Different inputs (x) yield different outputs (y). The slope is not equal to zero The slope is equal to zero

  21. The standard error of b1. Testing the Slope • We can make an inference about b1 from b1 by testing H0: b1 = 0 HA: b1 = 0 (or < 0,or > 0) • The test statistic is • If the error variable e is normally distributed, the statistic is Student t distribution with d.f. = n-2. where

  22. Testing the Slope,Example • Example • Test to determine whether there is enough evidence to infer that there is a linear relationship between the car auction price and the odometer reading for all three-year-old Tauruses in the previous example.

  23. Testing the Slope, Example Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (x100 , y100 ) • Solving by hand • To compute “t” we need the values of b1 and sb1.P-value = 2P(t98 > |-13.44|) ~ 0

  24. Testing the Slope (Example) • Using the computer There is overwhelming evidence to infer that the odometer reading affects the auction selling price.

  25. Coefficient of determination r2 Reduction in prediction error when use x: TSS-SSE = SSR

  26. Explained in part by Remains, in part, unexplained Coefficient of determination r2 Reduction in prediction error when use x: TSS-SSE = SSR or TSS = SSR + SSE The regression model SSR Overall variability in y TSS The error SSE

  27. y Coefficient of determination: graphically y2 Two data points (x1,y1) and (x2,y2) of a certain sample are shown. Variation in y = SSR + SSE (TSS) y1 x1 x2 + Unexplained variation (error) Total variation in y = Variation explained by the regression line

  28. Coefficient of determination r2 • R2 (=r2 ) measures the proportion of the variation in y that is explained by the variation in x. • r2 takes on any value between zero and one (-1r 1). r2 = 1: Perfect match between the line and the data points. r2 = 0: There are no linear relationship between x and y.

  29. Coefficient of determination r2,Example • Example • Find the coefficient of determination for the used car price –odometer example.what does this statistic tell you about the model? • Solution • Solving by hand;

  30. Coefficient of determination r2 • Using the computerFrom the regression output we have 64.8% of the variation in the auction selling price is explained by the variation in odometer reading. The rest (35.2%) remains unexplained by this model.

  31. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (x100 , y100 ) Using the Regression Equation • Before using the regression model, we need to assess how well it fits the data. • If we are satisfied with how well the model fits the data, we can use it to predict the values of y. • To make a prediction we use • Point prediction, and • Interval prediction

  32. A point prediction Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (x100 , y100 ) Point Prediction • Example • Predict the selling price of a three-year-old Taurus with 40,000 miles on the odometer. • It is predicted that a 40,000 miles car would sell for $14,574. • How close is this prediction to the real price?

  33. The prediction interval Interval Estimates • Two intervals can be used to discover how closely the predicted value will match the true value of y. • Prediction interval – predicts y for a given value of x (price prediction for a specific car with 40,000 miles on odometer) • Confidence interval – estimates the average y for a given x (estimate the average price of all cars with 40,000 miles on odometer). • The confidence interval

  34. Interval Estimates,Example • Example - continued • Provide an interval estimate for the bidding price on a Ford Taurus with 40,000 miles on the odometer. • Two types of predictions are required: • A prediction for a specific car • An estimate for the average price per car

  35. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (x100 , y100 ) Interval Estimates: Example • Solution • A prediction interval provides the price estimate for a single car: t.025,98

  36. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (x100 , y100 ) Interval Estimates: Example • Solution – continued • A confidence interval provides the estimate of the mean price per car for a Ford Taurus with 40,000 miles reading on the odometer. • The confidence interval (95%) =

  37. Warm-Up (cont.) Simple linear regression results:(Statcrunch)Dependent Variable: Global Avg TempIndependent Variable: CO2 Global Avg Temp = 10.6442 + 0.010324616 CO2Sample size: 44R (correlation coefficient) = 0.85773986R-sq = 0.73571767Estimate of error standard deviation: 0.1316139

  38. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) The effect of the given x on the length of the interval • As xmoves away from x the interval becomes longer. That is, the shortest interval is found at x.

  39. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) The effect of the given x on the length of the interval • As xmoves away from x the interval becomes longer. That is, the shortest interval is found at x.

  40. Bivariate data: (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), … , (xn , yn ) The effect of the given x on the length of the interval • As xmoves away from x the interval becomes longer. That is, the shortest interval is found at x.

  41. Regression Diagnostics - I • The three conditions required for the validity of the regression analysis are: • the error variable is normally distributed. • SD() is constant for all values of x. • The errors are independent of each other. • How can we diagnose violations of these conditions?

  42. Residual Analysis • Examining the residuals (or standardized residuals), help detect violations of the required conditions. • Example – continued: • Nonnormality. • Use Excel to obtain the standardized residual histogram. • Examine the histogram and look for a bell shaped. diagram with a mean close to zero.

  43. Standardized residual ‘i’ = Residual ‘i’ Standard deviation Residual Analysis A Partial list of Standard residuals For each residual we calculate the standard deviation as follows:

  44. Residual Analysis It seems the residual are normally distributed with mean zero

  45. ^ y + + + + + + + + + + + + + + + + + + + + + + + ^ The spread increases with y SD() the Same for all x? Heteroscedasticity • When the requirement that SD() is the same for all x is violated, we have a condition called heteroscedasticity. • Diagnose heteroscedasticity by plotting the residual against the predicted y. Residual + + + + + + + + + + + + + ^ + + + y + + + + + + + +

  46. Homoscedasticity • When the requirement that SD() is the same for all x is not violated we have a condition of homoscedasticity. • Example - continued

  47. Non-Independence of Error Variables • 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.

  48. Non Independence of Error Variables Patterns in the appearance of the residuals over time indicates that autocorrelation exists. Residual Residual + + + + + + + + + + + + + + 0 0 + Time Time + + + + + + + + + + + + + Note the runs of positive residuals, replaced by runs of negative residuals Note the oscillating behavior of the residuals around zero.

  49. Outliers • 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 customaryto suspect an observation is an outlier if its |standard residual| > 2

  50. + + + + + + + + + + + An influential observation An outlier + + … but, some outliers may be very influential + + + + + + + + + + + + + + The outlier causes a shift in the regression line

More Related