Nutrition at Starbucks, Part I. (8.22, p. 326) 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.
The relationship between number of calories and amount of carbohydrates that Starbucks food menu items contain is a linear relationship where most of the time if calories increases, carbohydrates increases as well.
The explanatory and response variables are calories is the explanatory variable and carbohydrates is the response variable.
We want to fit a regression line to these data because if we are looking to track the amount of carbohydrates based on the number of calories, then a regression line would best be used to predict this.
Body measurements, Part I. (8.13, p. 316) Researchers studying anthropometry collected body girth measurements and skeletal diameter measurements, as well as age, weight, height and gender for 507 physically active individuals.19 The scatterplot below shows the relationship between height and shoulder girth (over deltoid muscles), both measured in centimeters.
\begin{center} \end{center}
The relationship between shoulder girth and height is almost always as shoulder girth increases, height increases. This shows on most cases that the longer the shoulder girth, the taller the person.
Body measurements, Part III. (8.24, p. 326) Exercise above 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.
shoulder_girth_mean <- 107.20
shoulder_girth_sd <- 10.37
height_mean <- 171.14
height_sd <- 9.41
correlation <- 0.67
slope <- correlation * (height_sd / shoulder_girth_sd)
slope
## [1] 0.6079749
intercept <- height_mean - slope * shoulder_girth_mean
intercept
## [1] 105.9651
The equation of the regression line for predicting height is height = 105.97 + 0.61 * shoulder girth.
The slope tells us the predicted increase in height, in cm, for every one cm increase in shoulder girth. For every 1 cm increase in shoulder girth, there will be an additional 0.61 cm to the height. The intercept tell us the height, in cm, when shoulder girth = 0. This is not useful information since a person cannot have a shoudler girth = 0.
r_squared <- correlation^2
r_squared
## [1] 0.4489
R^2 of the regression line for predicting height is 0.45. This means that 45% of the variability in height can be explained by the shoudler girth.
shoulder_girth_100 <- intercept + slope * 100
shoulder_girth_100
## [1] 166.7626
The predicted height for the random student with a shoulder girth of 100 cm is 166.76.
160 - shoulder_girth_100
## [1] -6.762581
The residual for the student from part (d) is -6.76. This means that the model overestimated the height of the student.
Cats, Part I. (8.26, p. 327) 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.
\begin{center} \end{center}
The linear model is heart weight = (4.034 * body weight) - 0.357. This was calculated using the table above.
The intercept is -0.357 g. This is not useful since it is telling us that the height weight is -0.357 g when the body weight is 0 kg, but a cat can’t have a body weight = 0 kg.
The slope is 4.034 g. This tells us that if body weight increases by 1 kg, height weight increases by 4.034 g.
R^2 = 64.66%. This means that 64.66% of the variability in heart weight can be explained by body weight.
sqrt(0.6466)
## [1] 0.8041144
Rate my professor. (8.44, p. 340) 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.
\begin{center} \end{center}
(3.9983 - 4.010) / -0.0883
## [1] 0.1325028
The slope is 0.133.
These data do provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive because the slope calcuated above is postive.
The conditions required for linear regression are linearity, nearly normal residuals, and constant variability. Linearity can be assumed to be met as there is no clear pattern on the scatterplot graphs though a weak linear relationship may be shown. Nearly normal residuals is met as the histogram shows a fairly normal distribution. Constant variability is met since the scatterplot graphs show we can assume that the residual variability is constant.