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 is an upward trend between number of calories and amount of carbohydrates that Starbucks food menu items contain.

  1. In this scenario, what are the explanatory and response variables?

The amount of carbohydrates is the explanatory variable because carbs are known to have a lot of calories.

Number of calories is the response variables.

  1. Why might we want to fit a regression line to these data?

We want to see how one variable correlates to that other variable.

  1. Do these data meet the conditions required for fitting a least squares line?

No because we do not satisfied the critieria for constant variability.

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.

  1. Describe the relationship between shoulder girth and height.

As shoulder girth increases, so does the height. There is a positive correlation between the two variables.

  1. How would the relationship change if shoulder girth was measured in inches while the units of height remained in centimeters?

It would remain the same because it is just a unit conversion change. The scale of shoulder girth will display in inches instead of centimeters.

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.

y = b0 +b1 * ¯ x. Plug in ¯ x, ¯ y, and b1, and solve for b0. x= 107.20 y=171.14 b1=0.6079749 b0= 105.965

Formula: height= 105.965 + 0.6079749 * shoulder girth

#b1= R * sy/sx
0.67 * (9.41/10.37)
## [1] 0.6079749
  1. Interpret the slope and the intercept in this context.

For additional shoulder girth we have 0.6079749 cm in height. If shoulder girth is at 0, we start from 105.965.

  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 is 0.4489. About 44.9% of the variability in shoulder girth is accounted for by the model.

# Find R^2
0.67^2
## [1] 0.4489
  1. A randomly selected student from your class has a shoulder girth of 100 cm. Predict the height of this student using the model.

Based of this model, we can predict the height of the student to be 166.7625.

shoulder_girth<-100
height= 105.965 + 0.6079749 * shoulder_girth
height
## [1] 166.7625
  1. The student from part (d) is 160 cm tall. Calculate the residual, and explain what this residual means.

ei = yi − ˆyi= 160-166.7625= -6.7625

A negative residual means the model overestimates 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 it would not be appropriate to use this model.

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}

# load packages -----------------------------------------------------
library(openintro)
library(xtable)
library(MASS)
## 
## Attaching package: 'MASS'
## The following objects are masked from 'package:openintro':
## 
##     housing, mammals
# load data ---------------------------------------------------------
data(cats)
# model heart weight vs. weight -------------------------------------
m_cats_hwt_bwt <- lm(cats$Hwt ~ cats$Bwt)
# plot heart weight vs. weight --------------------------------------
par(mar = c(3.7, 3.7, 0.5, 0.5), las = 1, mgp = c(2.5, 0.7, 0), 
    cex.lab = 1.5, cex.axis = 1.5)
plot(cats$Hwt ~ cats$Bwt, 
     xlab = "Body weight (kg)", ylab = "Heart weight (g)", 
     pch = 19, col = COL[1,2],
     xlim = c(2,4), ylim = c(5, 20.5), axes = FALSE)
axis(1, at = seq(2, 4, 0.5))
axis(2, at = seq(5, 20, 5))
box()

\end{center}

  1. Write out the linear model.

heart weight= -0.357 + 4.034 * body wt

  1. Interpret the intercept. The intercept is -0.357. This is obviously not a meaningful value, it just serves to adjust the height of the regression line.

  2. Interpret the slope.

For every one kg body wt, heart weight is increased by 4.034.

  1. Interpret \(R^2\).

The body weight explains 64.66% variance between the heart weights in cats.

  1. Calculate the correlation coefficient.

8.041144

cor_coef<-sqrt(64.66)
cor_coef
## [1] 8.041144

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.

  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.

0.1325028

(3.9983-4.010)/-0.0883
## [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.

Based of this data, we can tell the slope of the relationship between teaching evaluation and beauty is positive.

  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: Based on the scatterplot there appears to be a weak linear relationship.

Nearly normal residuals: Based on the residual graph, it looks like a normal distribution.

Constant variability: There also seems to be constant variablility in the residual plot.

Independent observations: It appears to be independent observations.