Graded Exercises
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.
library("png")
pp <- readPNG("Starbucks1.png")
plot.new()
rasterImage(pp,0,0,1,1)

- Describe the relationship between number of calories and amount of carbohydrates (in grams) that Starbucks food menu items contain.
The relationship looks linear, Upward trend and somewhat strong
- In this scenario, what are the explanatory and response variables?
Explanatory variable: Calories; Response variable: Carbs
- Why might we want to ???t a regression line to these data?
We would want to fit a regression line in order to find the strength of linear relationship or correlation between the explanatory and response variables. Data = Fit + Residuals, the fitted line should minimize as much as possible the leftover variation (residuals)
- Do these data meet the conditions required for ???tting a least squares line?
Linearity: The data shows an upward linear trend somewhat strong
Nearly Normal Residuals: The Residual plot shows no apparent pattern or drastic outliers. The residual histogram is nearly normal even though it is not symmetric but again, no outliers present
Variability: Observations show a non-constant variability along the regression line. More density on the right side of the residuals plot which does not seem promising for a linear regression fit
Independent observations: No time series data
All the conditions are met except for the constant variability
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.
- Write the equation of the regression line for predicting height.
hgt_hat = B0 + B1 x Shldr_girth
- Interpret the slope and the intercept in this context.
B1 (slope) = (s_y/s_x)R = 0.6079749
B0 (intercept): y-y0 = slope x (x-x0): y = 171.14 + 0.6079 X (x - 107.20): y = 105.97312 + 0.6079x
- Calculate R2 of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.
R2 = 0.4489
45% of the variability in height can be explained by the linear model
- A randomly selected student from your class has a shoulder girth of 100 cm. Predict the height of this student using the model.
y_hat = 166.76
- The student from part (d) is 160 cm tall. Calculate the residual, and explain what this residual means.
Residual = y - y_hat = 160 - 166.76 = -6.76, the linear model overestimated the height, therefore the residual is negative
- 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?
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.
library("png")
pp <- readPNG("Cats.png")
plot.new()
rasterImage(pp,0,0,1,1)

(a) Model: heartwgt_hat = -0.357 + 4.034 x bodywgt
(b) Intercept: heart weight when the body weight equals zero, in this case it is irrelevant as the body weight can never be zero
(c) Slope: Estimated difference in the heart weight (in grams) given an increment in the body weight (kg)
(d) R2: 64.41% of the variability in heart weight can be explained by the linear model, meaning the body weight
(e) Correlation Coefficient: 0.8025584
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 effectiveness is often criticized because these measures may reflect 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.
library("png")
pp <- readPNG("RateProf1.png")
plot.new()
rasterImage(pp,0,0,1,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-y0 = slope x (x-x0): 3.9983 = 4.010 + slope x (-0.0883); slope = 0.1325028
- Do these data provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive? Explain your reasoning.
Yes, the slope is positive, so the teaching score increases by a factor of (0.1325028) as the beauty score increases by one unit.
- List the conditions required for linear regression and check if each one is satis???ed for this model based on the following diagnostic plots.
library("png")
pp <- readPNG("RateProf2.png")
plot.new()
rasterImage(pp,0,0,1,1)

Linearity: Based on the positive slope calculated before, the data shows a linear relationship with an upward (positive) trend
Nearly Normal Residuals: The Residual plot shows no apparent pattern or drastic outliers. The residual histogram is nearly normal with a left-skew but no outliers marked present. Normal probability plot confirms a normal distribution pattern
Variability: Observations show a constant variability along the dashed line (residual plot. Slightly more density on the left side of the residuals plot which does not represent an apparent issue
Independent observations: No time series data or apparent sequential observations
Based on the conditions described, it is reasonable to try to fit a linear model to the data