To get the relative RMSE of my predicted model and true values,I used the code
ratio<-prediction1/ISEtrain
rRMSE1<-sqrt(mean((1-ratio)^2))
but I failed , with the output "[1] Inf". What is wrong with my code?
Thank you !
You are getting Inf
because you are dividing by zero.
Following Wikipedia's definition of the normalized RMSE (https://en.wikipedia.org/wiki/Root-mean-square_deviation), you probably want:
sqrt( mean( (prediction1-ISEtrain)^2) ) / ( max(ISEtrain)-min(ISEtrain) )
There are two ways to get relative RMSE (or normalized RMSE):
Divide RMSE by standard deviation of observed values:
sqrt(mean((prediction1 - ISEtrain)^2)) / sd(ISEtrain)
Divide RMSE by difference between max and min of observed values (as David mentioned):
sqrt(mean((prediction1 - ISEtrain)^2)) / diff(range(ISEtrain))
Both methods exist in "hydroGOF"
package and do exactly the same but proper function name to do so is nrmse()
not rmse()
as mentioned previously.
library("hydroGOF")
nrmse(prediction1, ISEtrain, norm = "sd")
nrmse(prediction1, ISEtrain, norm = "maxmin")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With