by justk · 2y ago · 0 comments
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.01I may be reading too much from your comment, but it seems that you relate R^2 to the reduction in the prediction error in each state, so it seems you are thinking about the formula of computing the R^2 as the (average variance in each state)/(total variance), that I think is not correct in general since at least it should require the total variance to be the sum of the variances in each state. If you based your ideas in that formula then your intuition is not correct, that is my point. When I apply R^2 I am thinking in a multivariable linear model with continuous variables, and this is not the case. I should measure this problem by how the entropy change when we apply the information about the state, something like the cross entropy using the total distribution and the distribution by states.