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.

    Answer: There appears to be a strong relationship between number of calories and amount of carbohydrates. As number of calories increase, so do amount of carbohydrates.

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

    Answer: The explanatory variable is Calories, and the response variable is Carbohydrates.

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

    Answer: We can use this to predict the amount of Carbohydrates in a display item base don the number of Calories it has.

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

    Answer: We can check for the below to see if this data meets the conditions or not:

    • Independency : The observations are independent.. yes
    • Linear relationshoip: The scatter plot shows a linear trend.. yes
    • Normal Residuals: The residuals distribution appears nearly normal.. yes
    • Constant variability: The scatter plot on Residuals shows weak relationship on the left.. no

    As contact variability condition is not met, we can say a simple linear model is inadequate for modeling these data.


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.

    Answer: There appears to be a strong relationship between shoulder girth and height. As size of shoulder girth increase, so do size of height.

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

    Answer: The relationship wouold remain same as we are just converting the units here. .


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.

    Answer: The equation of the regression line for predicting height can be written as below:

    \[ \hat{y} = B0 + B1 * x \]

    where X is the explanatory variable Shoulder and y is the response variable Height,
    B0 and B1 represent two model parameters,
    B1 is the slope given as B1 = (y SD) / (x SD) * R,
    and R is the correlation between the two variables

    # Given values:
    mean.shoulder <-  107.20 
    sd.shoulder <- 10.37
    mean.height <-   171.14
    sd.height <- 9.41
    R.shoulder.height <- 0.67
    
    # Calculate the slope  B1:
    B1 <- round( R.shoulder.height * (sd.height/sd.shoulder) , 4)
    
    # Calculte B0:
    B0 <- round( mean.height - B1 * mean.shoulder, 4)
    
    paste0('B0: ',B0 , ' and B1: ', B1)
    ## [1] "B0: 105.9624 and B1: 0.608"

    \[ \hat{y} = 105.9624 + 0.608 * Shoulder \]

  2. Interpret the slope and the intercept in this context.

    Answer: From above #a we can say the below: Slope /B1: For every 1 cm increase in shoulder girth, there will be an increase of 0.608 cm to the height.
    Intercept/ B0: This would be the height in centimeters at shoulder girth of 0 cm i.e. 105.9624 cm.

  3. Calculate \(R^2\) of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.

    Answer: From below we can say that 44.89% of the variation in shoulder girth is explained for by the model.

    paste0('R^2: ', R.shoulder.height^2)
    ## [1] "R^2: 0.4489"
  4. A randomly selected student from your class has a shoulder girth of 100 cm. Predict the height of this student using the model.

    Answer: Putting into the formula from above we can predict the height of this student as 166.77 cm.
    \[ \hat{y} = 105.9624 + 0.608 * 100 \]

    Shoulder.100 <- 100 
    
    paste0('Height of student with shoulder girth of 100 cm is: '
           , round( 105.9624 +  0.608 * Shoulder.100, 2), ' cm.')
    ## [1] "Height of student with shoulder girth of 100 cm is: 166.76 cm."
  5. The student from part (d) is 160 cm tall. Calculate the residual, and explain what this residual means.

    Answer: The residual is -6.77 cm. which means our model overestimated.

    height.160 <- 160
    
    paste0('The residual is: ', round(height.160 - 166.77 ,2))
    ## [1] "The residual is: -6.77"
  6. 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?

    Answer: Putting into the formula from above we can predict the height of this child as 140.01 cm.
    \[ \hat{y} = 105.9624 + 0.608 * 56 \]

    But this does not seem right; and looks quite dispropotionate body shape. The model can be used for adults only.

    Shoulder.56 <- 56 
    
    paste0('Height of child with shoulder girth of 56 cm is: '
           , round( 105.9624 +  0.608 * Shoulder.56, 2), ' cm.')
    ## [1] "Height of child with shoulder girth of 56 cm is: 140.01 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.

    Answer: The equation is as below:

    \[ \hat{y} = -0.357 + 4.034 * x \]

  2. Interpret the intercept.

    Answer: Intercept/ B0: This would be the heart weight (in g) at cat’s body weight of 0 gm i.e. -0.357 g.

  3. Interpret the slope.

    Answer: Slope /B1: For every 1 kg icrease in the cat’s body weight, there will be an increase of 4.034 g to the heart weight.

  4. Interpret \(R^2\).

    Answer: The R^2 is given as 64.66%; meaning 64.66% the variation in heart weight is explained for by the model.

  5. Calculate the correlation coefficient.

    paste0("The Correlation coefficient is: ", round(sqrt(64.66 /100 ),4))
    ## [1] "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.

    B1 <- round( ( 3.9983 - 4.010 )/ -0.0883 , 4)
    
    paste0('Slope/B1 is : ', B1)
    ## [1] "Slope/B1 is : 0.1325"
  2. Do these data provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive? Explain your reasoning.

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

  3. List the conditions required for linear regression and check if each one is satisfied for this model based on the following diagnostic plots.

    Answer: We can check for the below to see if this data meets the conditions or not:

    • Independency : The observations are independent.. yes
    • Linear relationshoip: The scatter plot shows a linear trend.. yes
    • Normal Residuals: The residuals distribution appears nearly normal.. yes
    • Constant variability: The scatter plot on Residuals shows strong relationship.. yes

    As all conditions are met, we can say a simple linear model is adequate for modeling these data.