Simple Linear Regression: 1. Finding the Equation of the Line of Best Fit

Simple Linear Regression: 1. Finding the Equation of the Line of Best Fit

Simple Linear Regression: 1. Finding the equation of the line of best fit Objectives: To find the equation of the least squares regression line of y on x. Background and general principle The aim of regression is to find the linear relationship between two variables. This is in 85 turn translated into a mathematical problem 80 of finding the equation of the line that is 75 closest to all points observed. 70 65 Weight (kg) Weight Consider the scatter plot on the right. One 60 possible line of best fit has been drawn on 55 the diagram. Some of the points lie above 50 the line and some lie below it. 1·4 1·5 1·6 1·7 1·8 Height (m) The vertical distance each point is above or ε1 below the line has been added to the diagram. These distances are called deviations or errors – they are symbolised as d1,d2 ,...,dn . When drawing in a regression line, the aim is to make the line fit the points as closely as possible. We do this by making the total of the squares of the deviations as small as possible, i.e. we minimise 2 di . If a line of best fit is found using this principle, it is called the least-squares regression line. Example 1: A patient is given a drip feed containing a particular chemical and its concentration in his blood is measured, in suitable units, at one hour intervals. The doctors believe that a linear relationship will exist between the variables. Time, x (hours) 0 1 2 3 4 5 6 Concentration, y 2.4 4.3 5.0 6.9 9.1 11.4 13.5 We can plot these data on a scatter graph – time would be plotted on the horizontal axis 12 (as it is the independent variable). Time is here referred to as a controlled variable, 10 since the experimenter fixed the value of this 8 variable in advance (measurements were 6 taken every hour). Concentration 4 Concentration is the dependent variable as the 2 concentration in the blood is likely to vary according to time. 1 2 3 4 5 6 Time (hours) The doctor may wish to estimate the concentration of the chemical in the blood after 3.5 hours. She could do this by finding the equation of the line of best fit. There is a formula which gives the equation of the line of best fit. 1 ** The statistical equation of the simple linear regression line, when only the response variable Y is random, is: Y 0 1x (or in terms of each point: Yi 0 1xi i ) Here 0 is called the intercept, 1 the regression slope, is the random error with mean 0, x is the regressor (independent variable), and Y the response variable (dependent variable). ** The least squares regression line is obtained by finding the values of and values (denoted in ˆ ˆ the solutions as 0 & 1 ) that will minimize the sum of the squared vertical distances from all points 2 ˆ 2 2 to the line: di yi yi yi 0 1 xi The solutions are found by solving the equations: 0 and 0 0 1 ˆ ˆ ˆ ** The equation of the fitted least squares regression line is Y 0 1 x (or in terms of each point: ˆ ˆ ˆ Yi 0 1 xi ) ----- For simplicity of notations, many books denote the fitted regression equation as: ˆ Y b0 b1x (* you can see that for some examples, we will use this simpler notation.) S ˆ xy ˆ ˆ where 1 and 0 y 1 x . S xx 2 x y x Notations: S xy x xy y; S x 2 x x2 ; xy n i i xx n i x and y are the mean values of x and y respectively. Note 1: Please notice that in finding the least squares regression line, we do not need to assume any distribution for the random errors i . However, for statistical inference on the model parameters ( and ), it is assumed in our class that the errors have the following three properties: Normally distributed errors 2 Homoscedasticity (constant error variance var i for Y at all levels of X) Independent errors (usually checked when data collected over time or space) i.i.d. 2 ***The above three properties can be summarized as: i ~ N0, , i 1,,n Note 2: Please notice that the least squares regression is only suitable when the random errors exist in the dependent variable Y only. If the regression X is also random – it is then referred to as the Errors in Variable (EIV) regression. One can find a good summary of the EIV regression in section 12.2 of the book: “Statistical Inference” (2nd edition) by George Casella and Roger Berger. We can work out the equation for our example as follows: 21 x 0 1 ... 6 21 so x 3 7 52.6 These could all be y 2.4 4.3 ... 13.5 52.6 so y 7.514... found on a 7 calculator (if you xy (02.4) 14.3... 613.5 209.4 enter the data into a 21 calculator). x2 02 12 ... 62 91 so x 3 7 2 x y 2152.6 S xy 209.4 51.6 xy n 7 2 x 212 S x 2 91 28 xx n 7 S ˆ xy 51.6 ˆ ˆ So, 1 1.843 and 0 y 1 x 7.514 1.8433 1.985 . S xx 28 So the equation of the regression line is yˆ = 1.985 + 1.843x. To work out the concentration after 3.5 hours: yˆ = 1.985 + 1.843 × 3.5 = 8.44 (3sf) If you want to find how long it would be before the concentration reaches 8 units, we substitute yˆ = 8 into the regression equation: 8 = 1.985 + 1.843x Solving this we get: x = 3.26 hours Note: It would not be sensible to predict the concentration after 8 hours from this equation – we don’t know whether the relationship will continue to be linear. The process of trying to predict a value from outside the range of your data is called extrapolation. Example 2: The heights and weights of a sample of 11 students are: Height 1.36 1.47 1.54 1.56 1.59 1.63 1.66 1.67 1.69 1.74 1.81 (m) h Weight 52 50 67 62 69 74 59 87 77 73 67 (kg) w [ n 11 h 17.72 h2 28.705 w 737 w2 50571 hw 1196.1] a) Calculate the regression line of w on h. b) Use the regression line to estimate the weight of someone whose height is 1.6m. Note: Both height and weight are referred to as random variables – their values could not have been predicted before the data were collected. If the sampling were repeated again, different values would be obtained for the heights and weights. Solution: a) We begin by finding the mean of each variable: h 17.72 h 1.6109... n 11 w 737 w 67 n 11 Next we find the sums of squares: 3 2 h 17.722 S h 2 28.705 0.1597 hh n 11 2 w 737 2 S w2 50571 1192 ww n 11 h w 17.72 737 S hw 1196.1 8.86 hw n 11 The equation of the least squares regression line is: ˆ ˆ wˆ 0 1h where ˆ Shw 8.86 1 55.5 Shh 0.1597 and ˆ ˆ 0 w 1 h 67 55.51.6109 22.4 So the equation of the regression line of w on h is: wˆ = -22.4 + 55.5h b) To find the weight for someone that is 1.6m high: wˆ = -22.4 + 55.5×1.6 = 66.4 kg Simple Linear Regression: 2. Measures of Variation Objectives: measures of variation, the goodness-of-fit measure, and the correlation coefficient Sums of Squares . Total sum of squares = Regression sum of squares + Error sum of squares SST SSR SSE (Total variation = Explained variation + Unexplained variation) 2 . Total sum of squares (Total Variation): SST Yi Y ˆ 2 . Regression sum of squares (Explained Variation by the Regression): SSR Yi Y ˆ 2 . Error sum of squares (Unexplained Variation): SSE Yi Yi 4 Coefficients of Determination and Correlation Coefficient of Determination – it is a measure of the regression goodness-of-fit It also represents the proportion of variation in Y “explained” by the regression on X SSR R 2 ; 0 R 2 1 SST Pearson (Product-Moment) Correlation Coefficient -- measure of the direction and strength of the linear association between Y and X . The sample correlation is denoted by r and is closely related to the coefficient of determination as follows: ˆ 2 r sign1 R ; 1 r 1 The sample correlation is indeed defined by the following formula: (x x)(y y) S n xy x y r XY 2 2 S S 2 2 2 2 [(x x) ][(y y) ] XX YY [n( x ) ( x) ][n( y ) ( y) ] . The corresponding population correlation between Y and X is denoted by ρ and defined by: COV X ,Y EX X Y Y VarX VarY VarX VarY . Therefore one can see that in the population correlation definition, both X and Y are assumed to be random. When the joint distribution of X and Y is bivariate normal, one can perform the following t-test to test whether the population correlation is zero: • Hypotheses H0: ρ = 0 (no correlation) HA: ρ ≠ 0 (correlation exists) • Test statistic r H0 t t 0 ~ n2 1 r 2 n 2 Note: One can show that this t-test is indeed the same t-test in testing the regression slope β1 = 0 shown in the following section.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us