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.
There appears to be a moderate positive relationship between
calories and grams of carbs.
Calories are the explanatory variable, whereas grams of carbs is the
response.
If starbucks comes out with a new item and only releases the number
of calories for some reason, we can predict the number of grams of carbs
using our regression line.
Yes. There is no apparent pattern of the residuals (although I note
that the residuals do not show constant variability since the
residuals are much smaller at the lower calorie side) and the
residuals appear normally distributed. The data shows a linear trend
and we also assume independent observations.
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}
There appears to be a positive relationship between the two.
The positive relationship will remain. It would just change the slope of the line due
to the conversion factor. Slope is rise over run, and with shoulder girth becoming
smaller (converting cm to inches), that means the denominator is a smaller number in
inches. This makes the slope steeper.
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.
mean_sh = 107.20
sd_sh = 10.37
mean_h = 171.14
sd_h = 9.41
R = .67
slope = sd_h/sd_sh * R
slope
## [1] 0.6079749
# y - mean_h = slope * (x - mean_sh)
inter = slope * -mean_sh + mean_h
inter
## [1] 105.9651
# height_pred = .6079749 * shoulder_girth + 105.9651
For every 1cm increase in shoulder girth, the heigh will increase by .6079749cm.
If someone could have 0cm shoulder girth, they would be 105.9651cm tall, or that
the "base" height without taking shoulder girth into account is 105.9651cm.
R^2
## [1] 0.4489
# The model explains about 44.89% percent of the variation in height.
.6079749 * 100 + 105.9651
## [1] 166.7626
160 - (.6079749 * 100 + 105.9651)
## [1] -6.76259
# The residual is the difference between the actual and the predicted.
# The residual is -6.76259 which means our model overpredicted the height.
No because 56cm is well outside of the range of values that the model was trained
on. This also doesn't match the population that the sample was collected from of
presumed active individuals.
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}
heart_weight = 4.034 * body_weight - 0.357
At body_weight of 0kg, the heart_weight is -0.357kg, or that -0.357kg is
the "base" heart rate.
For every 1kg increase on body_weight, the heart weight increases by
4.034g.
The model says body_weight accounts for 64.66% of the variability in
heart_weight.
sqrt(.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}
# y = mx + b
slope = (3.9983 - 4.010)/-0.0883
slope
## [1] 0.1325028
Looking at just the data points, it appears to be slightly positive but is hard
to eyeball. We can check the plots below.
The residuals plot doesn't show any particular pattern and look normally distributed.
The qqplot does stick closely to the qqline, so it looks like a good fit aside from
the extreme quantiles. There is also no pattern with residuals and order of collection.
Linearity: The scatterplot of the data should show a linear relationship between
dependent and independent variable. Very slight relationship can be eyed.
Independent observations: These are probably not independent because they are from
the same college.
Nearly Normal Residuals: The residual histogram plot looks fairly normal so
condition met.
Constant Variability: The residuals plot shows similar dispersion all around the 0 residual line
so this condition is met.