To
find the least-squares regression model, use the lm() command. From that
result, we can find the standard error.
We
will use the cholesterol data from Section 14.1, Table 1.
Age <- c(25, 25, 28, 32, 32, 32, 38, 42, 48, 51, 51, 58, 62, 65)
Total_Cholesterol <- c(180, 195, 186, 180, 210, 197, 239, 183, 204, 221, 243, 208, 228, 269)
Find
the least-squares regression model and save it as an object. Use the confint()
command on the regression object to get the confidence interval.
lm_object <- lm(Total_Cholesterol ~ Age)
confint(lm_object,conf.level=0.95)
## 2.5 % 97.5 %
## (Intercept) 113.6955793 189.011737
## Age 0.5455416 2.252587
We
are 95% confidence that the mean increase in total cholesterol for each
additional year of life is between 0.5455 mg/dL and 2.2526 mg/dL.