Section 37 R2


37.1 Coefficient of Determination (R2)


\[ \large R^2 = \frac{Treatment \space SS}{Total \space SS} = 1 - \frac{Residual \space SS}{Total \space SS}\]


R-squared quantifies the proportion of variance that is explained by the explanatory variable(s) in a linear regression model. It is a measure of predictive power of the model.

We can also compute the estiamte of R2 from the ANOVA table.

If R-squared is high (close to one) then this indicates that the grouping variable explains (describes) a lot of the variation in the data i.e. that there is a high signal-to-noise ratio.

37.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

R2 <- summary(fm)$r.squared