Learn R Programming

DiceEval (version 1.6.1)

R2: Multiple R-Squared

Description

Coefficient of determination \(R^{2}\)

Usage

R2(Y, Ypred)

Value

$$\code{R2}= 1 - \frac{SSE}{SST}$$

where \(SSE= \sum_{i=1}^{n} (Y(x_{i}) - \hat{Y}(x_{i})^{2}\) is the residual sum of squares

and \(SST= \sum_{i=1}^{n} (Y(x_{i}) - \bar{Y} )^{2}\) is the total sum of squares.

Note that the order of the input argument is important.

Arguments

Y

a real vector with the values of the output

Ypred

a real vector with the predicted values at the same inputs

Author

D. Dupuy

Examples

Run this code
X	<- seq(-1,1,0.1)
Y	<- 3*X + rnorm(length(X),0,0.5)
Ypred	<- 3*X
print(R2(Y,Ypred))

Run the code above in your browser using DataLab