Module 7
1.1
Y = a + bX + e
x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10)
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)
model1 <- lm(y ~ x)
summary(model1)
1.2
coef(model1)
Intercept (a) = 14.82lope (b) = 3.74
Regression Equation: Y = 14.82 + 3.74X
For every unit increment in the independent variable x, y increases about 3.74 unit compare this with unit regression in the earlier case.
2.
The model for predicting eruption duration (discharge) based on waiting time (waiting) is:
discharge = a + b(waiting) + e
data(faithful)
model2 <- lm(eruptions ~ waiting, data = faithful)
summary(model2)
2.2
coef(model2)
Results:
Intercept (a) = –1.874
Slope (b) = 0.0756
Estimated Regression Equation:
discharge = –1.874 + 0.0756(waiting)
2.3
predict(model2, data.frame(waiting = 80))
Predicted discharge duration: 4.17
If the waiting time since the last eruption is 80 minutes, the eruption of the length is expected to be about 4.17 min. This confirms the existence of a positive relationship (after long waits long eruptions).
3
input <- mtcars[, c("mpg", "disp", "hp", "wt")]
model3 <- lm(mpg ~ disp + hp + wt, data = input)
summary(model3)
Results:
Intercept = 37.11
disp = –0.00094
hp = –0.0312
wt = –3.80
Regression Equation:
mpg = 37.11 – 0.00094(disp) – 0.0312(hp) – 3.80(wt)
The coefficients show that the weight (wt.) has the most serious negative effect upon miles/gallon. Thus the greater the weight of the car more serious the fall in miles per gallon. Horse-power (hp) and displacement also have negative effects on M. P. G. but not in so serious an extent. Hence the more satisfactory equation gives a better idea of the manner in which the various independent variables may together produce an effect on fuel consumption.
4.
library(ISwR)
plot(metabolic.rate ~ body.weight, data = rmr)
model4 <- lm(metabolic.rate ~ body.weight, data = rmr)
abline(model4, col = "red")
predict(model4, data.frame(body.weight = 70))
Results:
Predicted metabolic rate for 70 kg ≈ 1710 kcal/day
The regression equation shows a marked positive relation between body weight and basal metabolism.With the increase in body weight shows increase in basal metabolism. A person with a body weight of about 70 Kilos is expected to have a basal metabolism of about 1710 Kcal/day which is unobjectionable for the larger bodies require greater energy in order to maintain their various functions.
Overall takeaway
in all the examples, the regression equations give a definite idea of how one or more of the predictors have influenced the variations of the dependent variable. The use of R made it possible to examine the coefficients, make predictions, and give an idea of the real relation of the relationships shown in the data.
Comments
Post a Comment