Chapter 7 - Introduction to Linear Regression Practice: 7.23, 7.25, 7.29, 7.39 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 con- tain. Since Starbucks only lists the number of calories on the display items, we are interested in predicting the amount of crabs a menu item has based on its calorie content.
There seems to be a positive linear relationship between the number of calories and amount of carbohydrates.
Explanatory: Calories Response: Carbs
For someone that counts calories, they might want to know how much carbs they are in taking.
Linearity looks good based on the other two graphs.
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 shoulder girth: 107.20 SD shoulder girth: 10.37 Mean height: 171.14 SD height: 9.41 Correlation: 0.67
#Y = mx +b
#b = intercept
#m = (sd1/sd2) *r
m = (9.41/10.37)*.67
x= 107.20
y= 171.14
m## [1] 0.6079749
#solve for b (intercept)
yint <- y-(m*x)
yint## [1] 105.9651
The slope is .607 and the intercept is 105.96.
.67^2## [1] 0.4489
44.89% of the variance in height can be explained by shoulder girth.
m*100+yint # (slope * x value) + y intercept = y value## [1] 166.7626
160-166.76## [1] -6.76
The model might not be appropriate for a one year old since the height of someone with 0 cm shoulder girth is 105.97 based on equation.
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.
y = mx+b y = 4.034x - 0.357 (b) Interpret the intercept. If the cat’s body weight is 0, the cat’s heart weight will be negative.
For every 1kg in cat’s body weight, cat’s heart weight will increase by 4.034
64.66% of the cat’s heart weight is explained by the cat’s body weight.
sqrt(64.66)## [1] 8.041144
Many college courses conclude by giving students the opportunity to evaluate the course and the instructor anonymously. However, the use of these student evalu- ations 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 ap- pearance 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.
intercept = 4.01
x = -0.0883
y = 3.9983
slope <- (y - intercept)/x
slope## [1] 0.1325028
The relationship is positive and the p value is close to 0
There isn’t much linearity between the two variables but, the residuals look normal and there is constant variability.