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.
It appears as though the more calories a drink has, the more grams of carbohydrates the drink has as well.
Explanatory = Calories Response = Carbs (grams)
Fitting a regression line to this data would allow us to comprehend the relationship between these variables.
It appears as though the residuals are relatively normally distributed, therefore we can assume the conditions are required for fitting a least squares line.
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.
Shoulder Girth = explanatory variable (x) Height = response variable (y)
#height stats
sy <- 9.41
y_bar <- 171.14
#shoulder stats
sx <- 10.37
x_bar <- 107.20
r <- 0.67
slope <- r * sy / sx
b0 <- y_bar - x_bar*slope
slope## [1] 0.6079749
b0## [1] 105.9651
height = 105.9651 + (shoulder girth)*(.607)
If shoulder girth is 0, we expect the height to be 105.9651 cm, and with each inch increase of shoulder girth, we expect height to increase 0.6079749 cm.
r*r## [1] 0.4489
height <- 105.9651 + (100)*(.607)
height## [1] 166.6651
The residual is the difference between the actual height and the predicted heigh of the student.
residual <- 166.6651 - 160
residual## [1] 6.6651
It would be innappropriate to be using this linear model because we would be extrapolating on our dataset to include children.
height <- 105.9651 + (57)*(.607)
height## [1] 140.5641
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.
explanatory = body weight response = heart weight
heart weight = -0.357 + (body weight)*(4.034)
As the body weight increases by 1 gram, the heart weight increases by 4.034 grams.
The R^2 = 64.66%, which demonstrates the relationship between the two variables. It shows that they are correlated by 64.66%
r2 <- .6466
sqrt(r2)## [1] 0.8041144
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.
teaching = yintercept + B1*beauty
avg_beauty <- -0.0883
avg_teaching <- 3.9983
y_int <- 4.010
B1 <- (avg_teaching - y_int)/avg_beauty
B1## [1] 0.1325028
Since the regreesion model has a p value that is less than .05, there is convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive
Linearity is satisfied. The data shows a linear trend.
Nearly normal residuals is satisified. The residuals appear to be randomized and follow a normal distribution.
Constant variability is satisified. The variability of points around the least squares line remains roughly constant.
Independent observations is assumed.