Graded: 7.24, 7.26, 7.30, 7.40
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.
Ex7.24
‘Calories’ is the explanatory variable and ‘Carb’ is the response variable.
People on low carb diets may be interested in knowing how many of the calories in a menu item are from carbs vs. from fat or protein.
No, the residuals plot shows that the variance seems to increase as the number of calories increases. So the data do not meet the “constant variability” condition for using a least squares linear regression.
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.
# calculate slope
b1 <- 0.67 * (9.41/10.37)
# calculate intercept
b0 <- 171.14 - b1 * 107.2
The equation for the regression line is \(\hat{y}\) = 105.97 + 0.61\(x\)
For each additional cm in shoulder girth the model predicts an additional 0.61 cm in height. At a shoulder girth of 0 cm we would expect a height of 105.97 cm. Zero shoulder girth does not make sense in this context so the intercept serves only to set the height of the line.
R2 <- 0.67^2
\(R^2\) = 0.45. The linear model accounts for about 45 percent of the variability in height.
height <- b0 + b1 * 100
I would predict the students height to be 166.76 cm based on the model.
residual <- 160 - height
The residual is -6.76. A negative residual means the student’s height is -6.76 cm less than the expected height based on this model.
No, the smallest shoulder girth in the data set this model is based on is about 85 cm, so a shoulder girth of only 56 cm would be extrapolation and would not be an appropriate use of this model.
The following regression output is for predicting the heart weight (in g) of cats from their body weight (in kg). The coefficients are estimated using a dataset of 144 domestic cats.
—– | Estimate | Std. Error | t value | Pr(> |
---|---|---|---|---|
(Intercept) | -0.357 | 0.692 | -0.515 | 0.607 |
body wt | 4.034 | 0.250 | 16.119 | 0.000 |
\(s\) = 1.452 | \(R^2\) = 64.66% | \(R^2_{adj}\) = 64.41% |
Ex7.30
\(\hat{\text{heart weight}} = -0.357 + 4.034 \times \text{body weight}\)
At a body weight of 0 kg we would expect a heart weight of -0.357 g. Zero body weight and -0.357g heart weight both do not make sense in this context so the intercept serves only to set the height of the line in the model.
For each additional kg in body weight the model predicts an additional 4.034g in heart weight.
About 64.66% of the variability in heart weight is explained by body weight in this model.
r <- sqrt(64.66/100)
The correlation coefficient is 0.804.
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 influence 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.
Ex7.40a
# calculate slope
b1 <- (4.010-3.9983) / (0-(-0.0883))
b1
## [1] 0.1325028
The slope is 0.13.
Assuming that our data meet the conditions for a least squares regression, then yes, the data provide convincing evidence that the relationship between teaching evaluation and beauty is positively correlated. A positive slope indicates a positive correlation and the p-value in the regression table is so small that the probability of the null hypothesis (slope of zero) being true is basically zero.
Ex7.40b
Conditions for linear regression using least squares: