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 a non linear relationship between number of calories and amount of carbohydrates.
  2. In this scenario, what are the explanatory and response variables?
    • The eplanatory varaible is number of calories and the response variable is amount of carbohydrate.
  3. Why might we want to fit a regression line to these data?
    • If the amount of carbohydratre is not available for certain type of food, we can fit it with the linear regression.
  4. Do these data meet the conditions required for fitting a least squares line?
    • The observations are indepedent, but there is not a constant variablity of the residual. The sparsity extends when the number of calories increase. We see a cone around the x axe. The histogram shows that the residual distribution is nearly normal. All conditions are not met to fit a least square line.

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.
    • The relationship between girth and height is linear.
gh <- lm(hgt ~ sho.gi, bdims)
summary(gh)
## 
## Call:
## lm(formula = hgt ~ sho.gi, data = bdims)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -19.2297  -4.7976  -0.1142   4.7885  21.0979 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 105.83246    3.27245   32.34   <2e-16 ***
## sho.gi        0.60364    0.03011   20.05   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.026 on 505 degrees of freedom
## Multiple R-squared:  0.4432, Adjusted R-squared:  0.4421 
## F-statistic:   402 on 1 and 505 DF,  p-value: < 2.2e-16
Linear model Height = 0.60364*Shoulder_girth + 105.032
The median is nearly null, min and max are in the same magnitude.
The residual square  (44.42%) remains low. The model fit the data at 44.32% 
  1. How would the relationship change if shoulder girth was measured in inches while the units of height re- mained in centimeters? The unit does not change the nature of the relationship.

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.
    • \(a=r\frac{S_y}{S_x}\) Where ‘a’ is the regression slope, Sx and Sy are respectively the standard deviation of x and y variables.
slope <- 0.67*9.41/10.37
slope
## [1] 0.6079749

Since the means are coordinates of the line, we can write \(171.14 = 0.607974*107.20 + b\)

intercept <- 171.14 - 0.6079749*107.20
intercept
## [1] 105.9651

The equation of the line is \(Heigth=0.608*girth +105.9651\)

  1. Interpret the slope and the intercept in this context.
    • For each cm of shoulder girth, the heigth increase by 0.608
  2. Calculate \(R^2\) of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.
rsq <- .67*.67
rsq
## [1] 0.4489
- $R^2=44.89\%$ of the variation of heigth is explain by shoulder girth.
  1. A randomly selected student from your class has a shoulder girth of 100 cm. Predict the height of this student using the model.
0.608*100 + 105.9651
## [1] 166.7651
- That random student will have 166.76 cm of height
  1. The student from part (d) is 160 cm tall. Calculate the residual, and explain what this residual means.
160 - 166.76
## [1] -6.76
- The model overestimates the student heigth for 6.76 cm
  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?
    • Estimate the height of a children with a shoulder girth of 56 cm wuold be an extrapolation because the minimun shoulder girth in the data is greater than 80 cm.

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
  2. Interpret the intercept.
    • The heart weight is a negative value when the body weight is 0.
  3. Interpret the slope.
    • For an increase of 1 cm of body weight, the heart weight increase by 4.034 cm.
  4. Interpret \(R^2\).
    • The body weigth can predict the heart weight at 64.66%
  5. Calculate the correlation coefficient.
r <- sqrt(.6466)
r
## [1] 0.8041144
- The correlation coefficient is 0.8041

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.
    • means(-0.0883, 3.9983)
slope <- (4.010-3.9983)/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.
    • We state the null hypothesis \(H_0\): slope = 0 and the alternative hypothesis \(H_A\): slope > 0. The model summary shows that the p-value=0. We reject the null hypothesis. There is a convincing evidence that the relationship between beauty and teachind evaluation is positive.
  2. List the conditions required for linear regression and check if each one is satisfied for this model based on the following diagnostic plots.
    • Independent observations. Since the survey is anonymous, the observations are independent.
    • Nearly normal distribution residual. The histogram and the theoritical quantile show that the distribution is nearly normal.
    • Linearity is not strong
    • Constant variabilty. We can draw two horizontal lines that bound the residuals