R2 function

Multiple R-Squared

Multiple R-Squared

Coefficient of determination R2R2

R2(Y, Ypred)

Arguments

  • Y: a real vector with the values of the output
  • Ypred: a real vector with the predicted values at the same inputs

Returns

\codeR2=1SSESSTR2=1SSE/SST \code{R2}= 1 - \frac{SSE}{SST}R2=1-SSE/SST

where SST=(Y(x1)Ypred(x1))2+...+(Y(xn)Ypred(xn))2SST= (Y(x1) - Ypred(x1) )^2+...+(Y(xn) - Ypred(xn) )^2 is the residual sum of squares

and SST=(Y(x1)mean(Y))2+...+(Y(xn)mean(Y))2SST= (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.

Author(s)

D. Dupuy

Examples

X <- seq(-1,1,0.1) Y <- 3*X + rnorm(length(X),0,0.5) Ypred <- 3*X print(R2(Y,Ypred))
  • Maintainer: C. Helbert
  • License: GPL-3
  • Last published: 2023-12-04

Useful links