Multiple R-Squared
Coefficient of determination R2
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 |
R2=1-SSE/SST
where SST= (Y(x1) - Ypred(x1) )^2+...+(Y(xn) - Ypred(xn) )^2 is the residual sum of squares
and SST= (Y(x_{1}) - mean(Y) )^2+...+(Y(x_{n}) - mean(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))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.