Section 35 CI of Estimates


35.1 95% Confidence Interval of the Mean

\[ \Huge CI_{0.95}(\bar{y_i}) = \bar{y_i} \pm t_{0.025, df} \sqrt\frac{MSE}{n}\]

35.2 R code

fm <- lm(SBP ~ Group, data=BP)

summary(fm)
sigma <- summary(fm)$sigma

anova(fm)
MSE <- anova(fm)[2,3]

n <- sum(BP$Group=='A')
SE <- sqrt(MSE/n)

tstat <- qt(p = 0.025, df = n, lower.tail = FALSE)

Group <- unique(BP$Group)
Mean <- predict(fm, newdata = Group)
LCL <- Mean - tstat*SE
UCL <- Mean + tstat*SE