In cor function , there is a wonderful argument the ” use “(e.g. : use=”na.or.complete” )
I tried to use the same argument with calculating RMSE or bias. It seems that it is not working.I wonder what we could use instead.
RMSE <- function(x, y){
sqrt(mean((x-y)^2))}
RMSE(x,y, use = "na.or.complete")
Error in RMSE(x,y, use = "na.or.complete") :
unused argument(s) (use = "na.or.complete")
The mean function to compute THE RMSE has an
na.rmargument, You can use it like this :The na.rm argument can be used to mimic na.or.complete behavior since in almost cases , using na.or.complete option is equiavlent to remove NA value from the original pairs. For example :
With RMSE
EDIT set very small values to NA
I don’know how you store your data. But I assume you have a data.table with a variable x. You can do something like this :