Graded: 7.24, 7.26, 7.30, 7.40
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.
Describe the relationship between number of calories and amount of carbohydrates (in grams) that Starbucks food menu items contain.
It looks like positive correlation between the number of calories and the amount of carbohydrates,as calories increase, carbohydrates also increasing
In this scenario, what are the explanatory and response variables?
Explanatory variable: Calories on the x axis
Response variable: Carbohydrates on the y axis
Why might we want to fit a regression line to these data?
The regression line will help to predict the carbohydrates for a given number of calories
Do these data meet the conditions required for fitting a least squares line?
Linearity: The scatterplot shows that the data show a moderate to low linear relationship.
Nearly normal Residual: Slightly skewed left.
Constant Variability: There is no constant variability for residuals.
Independent Observation: Observations are independent
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.
#mean and sd of shoulder
mean_shoulder <- 107.20
sd_shoulder <- 10.37
#mean and sd of height
mean_height <- 171.14
sd_height <- 9.41
#correlation
r <- 0.67
#slope
b1 <- r * (sd_height/sd_shoulder)
b0 <- mean_height - (b1*mean_shoulder)
b1
## [1] 0.6079749
b0
## [1] 105.9651
height = b0 + b1 x shoulder_girth
Interpret the slope and the intercept in this context.
Slope: Number of cm increase in height for each increase in shoulder girth.
Intercept: Height in cm at girth of 0 cm.
Calculate R2 of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.
R2 <- 0.67^2
R2
## [1] 0.4489
44.89% of variability in height
height_cm <- 92.29 + 0.738 * 100
height_cm
## [1] 166.09
166.09
height_student <- b0+b1*100
residual <- 160 - height_student
residual
## [1] -6.762581
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.
Write out the linear model.
y = -0.357 + 4.034 * x
Interpret the intercept.
The intercept is -0.357 of y - heart weight, but weight is zero, not a relalistic data
Interpret the slope.
The parameter of slope is 4.034 during the body weight per each kg, when the heart weight increases by 4.034 grams for each 1kg of body weight increase.
Interpret R2.
R2 is 64.66%, the linear model shows 64.66% variation of heart weight
Calculate the correlation coefficient.
R2 <- 0.6466
R <- sqrt(R2)
R
## [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 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. The scatterplot below shows the relationship between these variables, and also provided is a regression output for predicting teaching evaluation score from beauty score.
b0 <- 4.010
x <- -0.0883
y <- 3.9983
b1 <- (y - b0) / x
b1
## [1] 0.1325028
y=b0+b1.x
Do these data provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive? Explain your reasoning.
The scatterplot shows that there is no linear relation between beauty and teaching evaluation
List the conditions required for linear regression and check if each one is satisfied for this model based on the following diagnostic plots.
Linearity: Very weak linear relationship. R^2 satifies to linear condition
Nearly normal residuals: Nearly normal
Constant variability: It looks like constant variability in the data.
Independent observations: Yes,The observations are independent in that this is not time series data.