nrmse is a function that allows the user to calculate the normalized root
mean square error (NRMSE) as absolute value between predicted
and observed values using different type of normalization methods.
It further allows the NRMSE calculation on the scale of the untransformed
indicator, which is advisable for a comparison across indicators.
nrmse( pred, obs, method = "sd", transformation = "none", trans_function = "none" )
A vector of predicted values.
A vector of observed values.
A character string indicating the value to be used for the normalization of the RMSE.
The default is the standard deviation. Alternatively, you can choose the
The type of transformation applied to the observations
prior to the analysis. Choose one of the following:
The function returns a single NRMSE value (expressed as absolute value). In case the number of positions with non-missing values in both pred and obs is less then 2, NA is returned with a message.
The for most common normalization methods are implemented here:
- the **mean**: NRMSE = RMSE / mean(obs) - the **standard deviation**: NRMSE = RMSE / sd(obs) - the **difference between maximum and minimum**: NRMSE = RMSE / (max(obs)-min(obs) - the **interquartile range**; NRMSE = RMSE / (Q1-Q3), i.e. the difference between the 25th and 75th percentile of observations
Missing values in obs and pred are removed before the computation proceeds, and only those positions with non-missing values in both pred and obs are considered in the computation.
obs <- c(10, 14, 20) pred <- c(9, 12, 13) # Calculating the sd-based NRMSE for untransformed data nrmse(pred, obs)#>  0.8429272# Calculating the iq-based NRMSE for log(x+0.001) transformed data nrmse(pred, obs, method = "iq", transformation = "other", trans_function = "exp(x)-0.001")#>  1.153703