Chapter 7 - Introduction to Linear Regression Graded: 7.24, 7.26, 7.30, 7.40
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.
It is a Straight band relationship of curved trend with positive relationship. If amount of calories increase, the carbohydrates will be increased proportionly.
In this case, the calories is in a relationship to explain or to predict changes in the values of carbohydrates, so the explanatory variable is Calories at x axis, and response variable is Carbohydrates at y axis.
We might be interested in predicting the number of carbohydrates in a particular food item based on the number of calories.
We can set up the equation to predict amount of carbohydrates based on particular food item of caories. This method can estimate the uncertainty in the slope and y-intercept for a regression line.
Linearity: The data are shown in linear, but the variability of the data around the line increases with larger values of x.
Nearly normal residuals: The residuals distribution appears nearly normal.
Constant variability: It is not a constant variability, because the variability of thedata around the line increases with larger values of x. The variability of points around the least square line must remain roughly constant.
Independent observations: The menu item is presumably independent observation, but just involve starbucks only.
It does not satisfy the conditions of linerity and constant variability, so it not fit a least squares line.
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.
Linear regression assumes:
y = β0 + β1*x
b1 = (Sh / Sg)* R (β1 by b1 as defined)
#Mean height,
y <- 171.14
#Mean shoulder girth,
x <- 107.2
#Correlation,
R <- 0.67
#SD height,
Sh <- 9.41
#SD shoulder girth,
Sg <- 10.37
b1 <- (Sh / Sg)*R
b1
## [1] 0.6079749
b0 <- y - (b1*x)
b0
## [1] 105.9651
y = 105.96 + 0.608 x
The intercerpt of height is 105.96 when shoulder girth is 0, the height will be increase by shoulder girth increasing according to 0.608.
R <- 0.67
R2 <- R^2
R2
## [1] 0.4489
The availability of height is around 0.45 for the linear model.
girth <- 100
height <- b0 + b1*girth
height
## [1] 166.7626
the height by using the model is 166.
# height (100), y1 = 166
# e = y0 - y1
e <- 160 - 166
e
## [1] -6
This was close to estimate of -6
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.
y = -0.357 + 4.034 * x
When body weight is 0, the intercept is -0.357 of y - heart weight, but it is impossible the body weight to be 0, it is non sense of this result.
The parameter of slope is 4.034 during the body weight per each kg.
R^2 is 64.66 % which describe how closely the data cluster around the linear fit.
R is correlation coefficient,
R <- sqrt(0.6466)
R
## [1] 0.8041144
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.
# b0 = 4.010
# y = 4.010 + b1*x
y <- 3.9983
x <- -0.0883
b1 <- (y-4.010)/x
b1
## [1] 0.1325028
In the assumption H0: b0 =0, the p-value show it is 0.000, it is evidence that the beauty score are not 0 and it is positive.
Linearity: It is a weak trend in scatterplot. Only R^2 relate to linear condition.
Nearly normal residuals: the residuals distribution are nearly normal.
Constant variability: The scatterplot of the residuals show that it is constant variability.
Independent observations: Assuming independence due to no clear evidence.