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.
Describe the relationship between number of calories and amount of carbohydrates (in grams) that Starbucks food menu items contain. There is a positive relationship between calories and carbs.
In this scenario, what are the explanatory and response variables? Carbs are the explanatory (Independent) variable, and calories are the response (dependent) variable.
Why might we want to fit a regression line to these data? To better see the trend of the data.
Do these data meet the conditions required for fitting a least squares line? Yes, the data shows a linear trend, the residuals are nearly normal, there is constant variability/homoscedasticity, and there are independent observations of the 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. The scatterplot below shows the relationship between height and shoulder girth (over deltoid muscles), both measured in centimeters.
\begin{center} \end{center}
Describe the relationship between shoulder girth and height. There is a positive relationship between shoulder girth and height.
How would the relationship change if shoulder girth was measured in inches while the units of height remained in centimeters? The relationship would still be positive, and the trend line would remain the same. It would scale the same way as it’s displayed.
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.
mean_shoulder = 107.20
sd_shoulder = 10.37
mean_hgt = 171.14
sd_hgt = 9.41
R = 0.67
slope = R * (sd_hgt/sd_shoulder)
slope
## [1] 0.6079749
intercept = slope * -mean_shoulder + mean_hgt
intercept
## [1] 105.9651
Y = mX + b Height_prediction = 0.6079749 * Shoulder_girth + 105.9651
Interpret the slope and the intercept in this context. For every incriment of 1cm in shoulder girth, height increases by 0.6079749cm, which adds to the intercept which gives one a base height of 105.9651cm, if, there is no shoulder girth.
Calculate \(R^2\) of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.
R_squared <- R^2
R_squared
## [1] 0.4489
This means that the model indicates 44.89% of height variation.
Shoulder_girth = 100
Height_prediction = 0.6079749 * Shoulder_girth + 105.9651
Height_prediction
## [1] 166.7626
160 - Height_prediction
## [1] -6.76259
This residual implies the difference between the actual and predicted height. In this case, our value of -6.76259 means that the model overpredicted the height.
No–this is because 56cm is outside of the range of values from the original dataset, which is what the model is based on. 56cm is nearly half of the minimum shoulder girth.
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}
heart_weight = 4.034 * mean(cats$Bwt) - 0.357
Interpret the intercept. -0.357kg is the base heart weight.
Interpret the slope. For every 1kg increase of body_weight, the weight of the heart increases by 4.034kg.
Interpret \(R^2\). This model indicates that body_weight accounts for 64.66% of the variability in heart_weight.
Calculate the correlation coefficient.
sqrt(0.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}
slope = (3.9983 - 4.010)/(-0.0883)
slope
## [1] 0.1325028
According to these data points comparing teaching evaluations and beauty, its not obvious that there is a positive relationship. The data is scattered in a pattern that does not take an obvious shape.
Linearity: The data distributed as a scatterplot should indicate a relationship–here it is not so obvious.
Independent Observations: Observations that are independent, or, that have no effect on each other. Because the data was collected by student evaluations, these results are independent.
Nearly Normal Residuals: How the data is distributed–according to the histogram, we can see this data follows a normal distribution.
Constant Variability: Also known as homoscedasticity. This means the variances along the line of best fit remain similar as we move along the line. Looking at the residuals plot, we can see there is homoscedasticity, since the variances are all close together and following the trendline very closely.