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.

  1. Describe the relationship between number of calories and amount of carbohydrates (in grams) that Starbucks food menu items contain.
There appears to be a moderate positive relationship between
calories and grams of carbs.
  1. In this scenario, what are the explanatory and response variables?
Calories are the explanatory variable, whereas grams of carbs is the
response.
  1. Why might we want to fit a regression line to these data?
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.
  1. Do these data meet the conditions required for fitting a least squares 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}

  1. Describe the relationship between shoulder girth and height.
There appears to be a positive relationship between the two.
  1. How would the relationship change if shoulder girth was measured in inches while the units of height remained in centimeters?
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.

  1. Write the equation of the regression line for predicting height.
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
  1. Interpret the slope and the intercept in this context.
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.
  1. Calculate \(R^2\) of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.
R^2
## [1] 0.4489
# The model explains about 44.89% percent of the variation in height.
  1. A randomly selected student from your class has a shoulder girth of 100 cm. Predict the height of this student using the model.
.6079749 * 100 + 105.9651
## [1] 166.7626
  1. The student from part (d) is 160 cm tall. Calculate the residual, and explain what this residual means.
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.
  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?
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}

  1. Write out the linear model.
heart_weight = 4.034 * body_weight - 0.357
  1. Interpret the intercept.
At body_weight of 0kg, the heart_weight is -0.357kg, or that -0.357kg is
the "base" heart rate.
  1. Interpret the slope.
For every 1kg increase on body_weight, the heart weight increases by
4.034g.
  1. Interpret \(R^2\).
The model says body_weight accounts for 64.66% of the variability in 
heart_weight.
  1. Calculate the correlation coefficient.
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}

  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 = mx + b
slope = (3.9983 - 4.010)/-0.0883
slope
## [1] 0.1325028
  1. Do these data provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive? Explain your reasoning.
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.
  1. List the conditions required for linear regression and check if each one is satisfied for this model based on the following diagnostic plots.
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.