Chapter 7 - Linear Regression
Practice: 7.23, 7.25, 7.29, 7.39

Graded: 7.24, 7.26, 7.30, 7.40

Start of homework

7.24 Nutrition at Starbucks, Part I.

The scatterplot below shows the relationship between the number of calories and amount of carbohydrates (in grams) Starbucks food menu items contain. Since Starbucks only lists the number of calories on the display items, we are interested in predicting the amount of carbs a menu item has based on its calorie content.

  1. Describe the relationship between number of calories and amount of carbohydrates (in grams) that Starbucks food menu items contain.

There is a moderately strong association between number of calories and carbs with substantial residuals.

  1. In this scenario, what are the explanatory and response variables?

Number of calories is the explanatory variable, and number of carbs is the response.

  1. Why might we want to fit a regression line to these data?

We might want to project how many carbs a new drink would have based on number of carbs. Though, given that carbs are one of three components of calories, it seems a little weird that we’d start with calories to get carbs.

  1. Do these data meet the conditions required for fitting a least squares line?

Conditions: 1. Linearity: It shows a largely positive association - pretty linear.
2. Nearly normal residuals: Looks nearly normal in the graph and residual histogram.
3. Constant variability: Residuals are much larger at large values of x, so variability is not constant.Therefore, the conditions are not met.
4. Independent observations: Observations likely independent.

Because of non-constant variability, conditions for fitting a least squares line not met.

7.26 Body measurements, Part III.

Exercise 7.15 introduces data on shoulder girth and height of a group of individuals. The mean shoulder girth is 107.20 cm with a standard deviation of 10.37 cm. The mean height is 171.14 cm with a standard deviation of 9.41 cm. The correlation between height and shoulder girth is 0.67.

  1. Write the equation of the regression line for predicting height.

\[ y = B_0 + B_1x\\ height = B_0 + B_1 * girth_shoulder\\ \\ B_0 = y-intercept\\ B_1 = slope\\ B_1 = s_y/s_x * R\\ B_1 = s_height/s_girth_shoulder * correlation\\ B_1 = 9.41 cm/10.37 cm * .67 = \]

b1_7.26 <- (9.41/10.37) * .67
b1_7.26
## [1] 0.6079749

Back to 8th grade, using the mean values: \[ y - y_0 = b_1 * (x-x_0)\\ y - 171.14 = .6080 * (x - 107.20) \]

b0_7.26 = b1_7.26 * (-107.20) + 171.14
b0_7.26
## [1] 105.9651

\[ height = 105.965 + .608 * girth_shoulder \]

  1. Interpret the slope and the intercept in this context.

The y-intercept here is tricky, as it implies that someone with no shoulder girth would be more than 100 cm tall. The slope is more helpful - for every additional cm of shoulder girth, the regression line predicts a person is .608 cm taller.

  1. Calculate R^2 of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.

R-squared describes “the amount of variation in the response that is explained by the least squares line.”

R2_7.26 <- .67^2
R2_7.26
## [1] 0.4489

*44.9% of the variation in height is reduced by using information about shoulder girth.**

  1. A randomly selected student from your class has a shoulder girth of 100 cm. Predict the height of this student using the model.
x_7.26 = 100
height_7.26 = 105.965 + .608 * x_7.26
height_7.26
## [1] 166.765

166.77 cm tall

  1. The student from part (d) is 160 cm tall. Calculate the residual, and explain what this residual means.
actual_height_7.26 <- 160
actual_height_7.26 - height_7.26 
## [1] -6.765

Residual is -6.77 cm, which means the least squares line overestimated the residual by more than 6 cm.

  1. A one year old has a shoulder girth of 56 cm. Would it be appropriate to use this linear model to predict the height of this child?

Nope. Looking at the data in 7.15, we see that the smallest shoulder girths in the study are above 80 cm. 56 cm is way outside our study - should not use linear regression on values outsides the study value minimum and maximums.

7.30 Cats, Part I.

The following regression output is for predicting the heart weight (in g) of cats from their body weight (in kg). The coecients are estimated using a dataset of 144 domestic cats.

  1. Write out the linear model.

\[ hweight = -.357 + 4.034 * bweight \]

  1. Interpret the intercept.

Heart weight can’t be negative at 0 or close to 0 bodyweights, so not a meaningful value. Function is to adjust the height of the line for regression.

  1. Interpret the slope.

For each increase of 1 kg in body weight, the heart weight increases more than 4 g.

  1. Interpret R2.

More than 64 percent of the variation in heart weight can be explained by changes in body weight.

  1. Calculate the correlation coecient.
sqrt(.6466)
## [1] 0.8041144

7.40 Rate my professor.

Many college courses conclude by giving students the opportunity to evaluate the course and the instructor anonymously. However, the use of these student evaluations as an indicator of course quality and teaching e???ectiveness is often criticized because these measures may re???ect the in???uence of non-teaching related characteristics, such as the physical appearance of the instructor. Researchers at University of Texas, Austin collected data on teaching evaluation score (higher score means better) and standardized beauty score (a score of 0 means average, negative score means below average, and a positive score means above average) for a sample of 463 professors. The scatterplot below shows the relationship between these variables, and also provided is a regression output for predicting teaching evaluation score from beauty score.

  1. Given that the average standardized beauty score is -0.0883 and average teaching evaluation score is 3.9983, calculate the slope. Alternatively, the slope may be computed using just the information provided in the model summary table.

\[ y = B_0 + B_1 * x\\ y_1 = 4.010 + B_1 * x_1 3.9983 = 4.010 + B_1 * -.0883 \]

(3.9983-4.010)/-.0883
## [1] 0.1325028

Slope is .133.

  1. Do these data provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive? Explain your reasoning.

The slope is slightly positive. P values are very small. The null hypothesis would be that the slope is 0. With our p values and slope, we can reject the null hypothesis and conclude the relationship is slightly positive.

  1. List the conditions required for linear regression and check if each one is satis???ed for this model based on the following diagnostic plots.

Conditions: 1. Linearity: This is the weakest performing. Slope is only slightly positive with huge residuals abounding. Marginal pass. 2. Nearly normal residuals: Looks nearly normal in the residual histogram.
3. Constant variability: Residuals are mostly constant, though there seem to be more negative ones at lower beauty ratings.
4. Independent observations: Looks soundly independent.

Despite the relatively weak linearity, the seems to satisfy the conditions.