Calculating the Least Squares Regression Line Lecture 40 Secs Wed, Dec 6, 2006
The Least Squares Regression Line The equation of the regression line is The equation of the regression line is y ^ = a + bx. Thus, we need to find the coefficients a and b. Thus, we need to find the coefficients a and b. The formulas are The formulas are or
Example Consider again the data set Consider again the data set xy
Method 1 Compute the means and deviations for x and y. Compute the means and deviations for x and y. xy x – xy – y x = 5 y = 9
Method 1 Compute the squared deviations, etc. Compute the squared deviations, etc. xy x – xy – y(x – x) 2 (y – y) 2 (x – x)(y – y)
Method 1 Find the sums of the last three columns. Find the sums of the last three columns. xy x – xy – y(x – x) 2 (y – y) 2 (x – x)(y – y)
Method 1 Compute b: Compute b: Then compute a: Then compute a:
Method 2 Consider again the data Consider again the data xy
Method 2 Compute x 2, y 2, and xy for each row. Compute x 2, y 2, and xy for each row. xyx2x2 y2y2 xy
Method 2 Then find the sums of x, y, x 2, y 2, and xy. Then find the sums of x, y, x 2, y 2, and xy. xyx2x2 y2y2 xy
Method 2 Then find the sums of x, y, x 2, y 2, and xy. Then find the sums of x, y, x 2, y 2, and xy. xyx2x2 y2y2 xy x = 25 y = 45 x 2 = 155 y 2 = 515 xy =
Method 2 Compute b: Compute b: Then compute a: Then compute a:
Example The second method is usually easier. The second method is usually easier. By either method, we get the equation By either method, we get the equation y ^ = x.
TI-83 – Regression Line On the TI-83, we could use 2-Var Stats to get the basic summations. Then use the formulas for a and b. On the TI-83, we could use 2-Var Stats to get the basic summations. Then use the formulas for a and b. For our example, 2-Var Stats L 1, L 2 reports that For our example, 2-Var Stats L 1, L 2 reports that n = 5 n = 5 x = 25 x = 25 x 2 = 155 x 2 = 155 y = 45 y = 45 y 2 = 515 y 2 = 515 xy = 282 xy = 282
TI-83 – Regression Line Or we can use the LinReg function. Or we can use the LinReg function. Put the x values in L 1 and the y values in L 2. Put the x values in L 1 and the y values in L 2. Select STAT > CALC > LinReg(a+bx). Select STAT > CALC > LinReg(a+bx). Press Enter. LinReg(a+bx) appears in the display. Press Enter. LinReg(a+bx) appears in the display. Enter L 1, L 2. Enter L 1, L 2. Press Enter. Press Enter.
TI-83 – Regression Line The following appear in the display. The following appear in the display. The title LinReg. The title LinReg. The equation y = a + bx. The equation y = a + bx. The value of a. The value of a. The value of b. The value of b. The value of r 2 (to be discussed later). The value of r 2 (to be discussed later). The value of r (to be discussed later). The value of r (to be discussed later).
TI-83 – Regression Line To graph the regression line along with the scatterplot, To graph the regression line along with the scatterplot, Put the x values in L 1 and the y values in L 2. Put the x values in L 1 and the y values in L 2. Select STAT > CALC > LinReg(a+bx). Select STAT > CALC > LinReg(a+bx). Press Enter. LinReg(a+bx) appears in the display. Press Enter. LinReg(a+bx) appears in the display. Enter L 1, L 2, Y 1 Enter L 1, L 2, Y 1 Press Enter. Press Enter. Press Y= to see the equation. Press Y= to see the equation. Press ZOOM > ZoomStat to see the graph. Press ZOOM > ZoomStat to see the graph.
Example Find the regression line for the Calorie/Cholesterol data. Find the regression line for the Calorie/Cholesterol data. Calories (x) Cholesterol (y)
Example Calories Cholesterol
Example Estimate the cholesterol content of sandwiches with 290 calories and 250 calories. Estimate the cholesterol content of sandwiches with 290 calories and 250 calories. Predict the cholesterol content of sandwiches with 500 calories and 1000 calories. Predict the cholesterol content of sandwiches with 500 calories and 1000 calories.
Example Calories Cholesterol
Example Calories Cholesterol
Example Calories Cholesterol