Chapter 7 - Introduction to Linear Regression
* Practice: 7.23, 7.25, 7.29, 7.39
* Graded: 7.24, 7.26, 7.30, 7.40
mean.shoulder <- 107.20
sd.shoulder <- 10.37
mean.height <- 171.14
sd.height <- 9.41
R.hs <- 0.67
# slope
b1 <- R.hs * (sd.height / sd.shoulder)
b1
## [1] 0.6079749
b0 <- mean.height - b1 * mean.shoulder
b0
## [1] 105.9651
The slope is 0.6079749 – This means that for every 10 cm increase in soulder girth, there will be an aditional 6.08cm to the height. But not all values makes sense as we plug them into linear regression equation. e.g. a person with a shoulder width 0cm (hypothetically) still indicates a height of 105.965 which doesn’t makes sense.
r.squared <- R.hs^2
r.squared
## [1] 0.4489
This indicates that 0.4489 of the variation found in this data is explinaed by the linear model – explained by the soulder girth width.
random.student.s <- 100
student.height <- b0 + (b1 * random.student.s)
student.height
## [1] 166.7626
residual <- 160 - student.height
residual
## [1] -6.762581
This means that this model overestimated the actual value by -6.7625805
\[\hat{y} = -0.357 + 4.034 * body.weight\]
Expected heart rate of a cat with 0 kg of body weight is -0.357, This doesn’t make sense. The regression will only return meaningful value when the inputs are in the range.
For each additional kg increase in body weight, we expect an additional 4.034 grams in the heart weight of a cat.
Body weight explains 64.66% of the variability in the heart weight of a cat.
0.8041144
b1 <- (3.9983 - 4.010) / (-0.0883)
b1
## [1] 0.1325028
There maybe a near zero slope level. But the data suggests there is correlation between beauty and teaching evaluation. The p-value in the summary chart suggests that we shoudl reject the H0 (there is no correlation).
In short, We can perform the linear regression.