mercredi 26 septembre 2012

simple way to compute rmse root mean square error in R

calculer rmse ("racine" de l'erreur moyenne quadratique) avec R.

rmse=function(obs,pred)
{
    diff=obs-pred
    diff=diff[!is.na(diff)]  #to remove NA values
    return (sqrt(mean((diff)^2)))
}

save the commands above in a file named rmse.r
To call this function:
       considering that obs is the array of observed values, pred is the array of predicted values
do

source("rmse.r")
rmsErr= rmse(obs,pred)