R2 {DiceEval} | R Documentation |
Coefficient of determination R^{2}
R2(Y, Ypred)
Y |
a real vector with the values of the output |
Ypred |
a real vector with the predicted values at the same inputs |
\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.
D. Dupuy
X <- seq(-1,1,0.1)
Y <- 3*X + rnorm(length(X),0,0.5)
Ypred <- 3*X
print(R2(Y,Ypred))