powered by
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