
Last chance! 50% off unlimited learning
Sale ends in
Calculate R squared value.
rSquared( y, resid )
vector of endogenous variables
vector of residuals
Arne Henningsen
data( "Electricity", package = "Ecdat" )
reg <- lm( cost ~ q + pl + pk + pf, Electricity )
rSquared( Electricity$cost, reg$residuals )
summary( reg )$r.squared # returns the same value
Run the code above in your browser using DataLab