by kgwgk · 2y ago · 0 comments
Does another measure give substantially different results?
As the user fskfsk.... says in another comment, here the constant term explains a lot of the variance so that the slope terms contains less information, that is not available using your definition or idea of R^2
Different from what?
According to wikipedia:
The most general definition of the coefficient of determination is R^2 = 1 - SS_res / SS_tot ( = 1 - 0.2475 / 0.25 = 0.01 in this case)
Edit to clarify the definition above:
SS_res is the sum of squares of residuals (also called the residual sum of squares) ∑( y_i - predicted_i )^2
SS_tot is the total sum of squares (proportional to the variance of the data) ∑( y_i - ∑y_i/N )^2
The population variance is the sum of the Between Group Variance and the Within Group Variance weighted by the number of elements in each group.
> data <- data.frame(state = rep(c(0, 1), each=20), pref = c(rep(0, 11), rep(1, 9), rep(0, 9), rep(1, 11)))
> summary(lm(pref ~ state, data = data))$r.squared
0.01