RMA {DiceEval} | R Documentation |
Relative Maximal Absolute Error
Description
Relative Maximal Absolute Error
Usage
RMA(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 |
Value
The RMA
criterion represents the maximum of errors between exact values and predicted one:
RMA = \max_{1\leq i\leq n} \frac{| Y \left( x_{i}\right)-\hat{Y} \left( x_{i}\right)|}
{\sigma_{Y}}
where Y
is the output variable, \hat{Y}
is the fitted model and
\sigma_Y
denotes the standard deviation of Y
.
The output of this function is a list with the following components:
max.value |
the value of the |
max.data |
an integer |
index |
a vector containing the data sorted according to the value of the errors |
error |
a vector containing the corresponding value of the errors |
Author(s)
D. Dupuy
See Also
other validation criteria as MAE
or RMSE
.
Examples
X <- seq(-1,1,0.1)
Y <- 3*X + rnorm(length(X),0,0.5)
Ypred <- 3*X
print(RMA(Y,Ypred))
# Illustration on Branin function
Branin <- function(x1,x2) {
x1 <- x1*15-5
x2 <- x2*15
(x2 - 5/(4*pi^2)*(x1^2) + 5/pi*x1 - 6)^2 + 10*(1 - 1/(8*pi))*cos(x1) + 10
}
X <- matrix(runif(24),ncol=2,nrow=12)
Z <- Branin(X[,1],X[,2])
Y <- (Z-mean(Z))/sd(Z)
# Fitting of a Linear model on the data (X,Y)
modLm <- modelFit(X,Y,type = "Linear",formula=Y~X1+X2+X1:X2+I(X1^2)+I(X2^2))
# Prediction on a grid
u <- seq(0,1,0.1)
Y_test_real <- Branin(expand.grid(u,u)[,1],expand.grid(u,u)[,2])
Y_test_pred <- modelPredict(modLm,expand.grid(u,u))
Y_error <- matrix(abs(Y_test_pred-(Y_test_real-mean(Z))/sd(Z)),length(u),length(u))
contour(u, u, Y_error,45)
Y_pred <- modelPredict(modLm,X)
out <- RMA(Y,Y_pred)
for (i in 1:dim(X)[1]){
points(X[out$index[i],1],X[out$index[i],2],pch=19,col='red',cex=out$error[i]*10)
}