Learn R Programming

miscTools (version 0.6-22)

rSquared: Calculate R squared value

Description

Calculate R squared value.

Usage

rSquared( y, resid )

Arguments

y

vector of endogenous variables

resid

vector of residuals

Examples

Run this code
# NOT RUN {
   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