[R] Calculation of r squared from a linear regression
daniel at umd.edu
Tue Jun 15 10:23:36 CEST 2010
Hi, as pointed out previously, the problem is in using the canned routine
(lm) without including an intercept term. Here is a working, generic example
with commented code.
#Create X matrix with intercept
#Run canned regression
#Canned and hand computed fitted values
#Are they all equal?
#This already implies that the R-squared is equal
#Compute R-squared by hand
#Is this equal to the R-squared from the canned routine?
View this message in context: http://r.789695.n4.nabble.com/Calculation-of-r-squared-from-a-linear-regression-tp2251438p2255537.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help