7.24 Nutrition at Starbucks, Part I. The scatterplot below shows the relationship between the number of calories and amount of carbohydrates (in grams) Starbucks food menu items contain. 21 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.

knitr::include_graphics("https://raw.githubusercontent.com/maharjansudhan/DATA606/master/7.JPG")

  1. Describe the relationship between number of calories and amount of carbohydrates (in grams) that Starbucks food menu items contain.

Answer: According to the graph, as the calories increase, there is an increase in carbs also.

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

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

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

Answer: So, that people can know if they are consuming very low carbs and have to change diet to intake more carbs or consume less carbs if they are intaking more.

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

Answer: No, it doesn’t meet the condition because as the calories increase the carbs increase.

7.26 Body measurements, Part III. Exercise 7.15 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:

  # to calculate slope
  m <-  0.67 * (9.41/10.37)
  m
## [1] 0.6079749
  # to calculate intercept
  b <- 171.14 - m * 107.2
  b
## [1] 105.9651

Here, m = 0.6079 and b = 105.96 Therefore, the equation is \[ \hat{y} = 105.97 + 0.61 * x \]

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

Answer: Here, when shoulder girth is at 0 we can get heigt 105.97 cm. Each additional cm in shoulder girth the equation predicts an additional 0.61 cm in height.

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

Answer:

R2 <- 0.67 ^2
R2
## [1] 0.4489

Therefore, R^2 = 0.4489 which means there is around 45% of variability 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.

Answer:

height <- b + m * 100
height
## [1] 166.7626

According to the calculation, the height can be predicted as 166.76 cm

  1. The student from part (d) is 160 cm tall. Calculate the residual, and explain what this residual means.

Answer:

residual <- 160 - height
residual
## [1] -6.762581

The residual is -6.76. Hence, a negative residual means the student’s height is -6.76 cm less than the expected 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?

Answer: According to the graph on question 7.15, the model is based on the dataset which has the lowest shoulder girth of around 80s cms. So, there is no possibility that we can predict the accurate height of a child who has 56 cm of shoulder girth.

7.30 Cats, Part I. 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. Estimate Std. Error t value Pr(>|t|) (Intercept) -0.357 0.692 -0.515 0.607 body wt 4.034 0.250 16.119 0.000 s = 1.452 R^2 = 64.66% R^2adj = 64.41%

  1. Write out the linear model.

Answer: \[ \hat{heart weight} = -0.357 + 4.034 * body weight \]

  1. Interpret the intercept.

Answer: According to the equation, if the body weight is 0, the heart weight is -0.357 g which is not possible. So, in order to have some heart weight a cat should have some weight.

  1. Interpret the slope.

Answer: The slope value of 4.034 indicates that for each additional kg of body weight there will be additional 4.034 gm of heart weight.

  1. Interpret R^2.

Answer: R^2 = 64.66% means, 64.66% of the variability in heart weight is explained by body weight.

  1. Calculate the correlation coefficient.

Answer:

corr_coeff <- sqrt(64.66/100)
corr_coeff
## [1] 0.8041144

The correlation coefficient is 0.8041

7.40 Rate my professor. 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 e???ectiveness 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.24 The scatterplot below shows the relationship between these variables, and also provided is a regression output for predicting teaching evaluation score from beauty score.

                    Estimate        Std. Error      t value       Pr(>|t|)

(Intercept) 4.010 0.0255 157.21 0.0000 beauty 0.0322 4.13 0.0000

  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.

Answer:

# calculate slope
slope <- (4.010-3.9983)/(0-(-0.0883))
slope
## [1] 0.1325028

Slope is 0.1325

  1. Do these data provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive? Explain your reasoning.

Answer: According to the given information, yes it can be approved that slope of the relationship between teaching evaluation and beauty is positive. Since, we have positive slope which means there is a positive correlation and the p-value is very small that states that the null hypothesis might be close to zero.

  1. List the conditions required for linear regression and check if each one is satisfied for this model based on the following diagnostic plots.
knitr::include_graphics("https://raw.githubusercontent.com/maharjansudhan/DATA606/master/7.40.JPG")

Answer:

Linearity :- According to the graph, the data appear to be linear. There is no curve.

Constant variance :- According to the graph, the points seem evenly spread. There are no pattern which means there is a constant variance.

Normally Distributed Residuals :- According to the graph, it has a slight left skew but looks fairly Normal in the QQ plot and Histogram.