6 may. 2012

Improving script_001: “Monitor”

After having a look to this video: http://www.screenr.com/UxH8 from rtwotutorials, and reading some tutorials, I decided to modified the script from the previous post: Practicing Script with “ R”: Monitor ,
 in order to make it more robust .
If there are NA values in our X and Y variables, the results for all the statistics will be NA (see also the video: http://www.screenr.com/loS8), that is not nice, so it´s better to write a warning and stop the analysis to check our data set.
So the new script is:
         print("There are NA values in X or Y, remove these samples for calculation")
 cat("Bias :",bias,"\n")}
 cat("SEP  :",sep,"\n")}
 cat("Corr :",r,"\n")}
 cat("RSQ  :",rsq,"\n")}

After having some samples with NA values (not reference value for that sample or not predicted value) the output will be:
"There are NA values in X or Y, remove these samples for calculation"

If not it will continue with the calculations:

RMSEP: 0.4373108
Bias : 0.03814815
SEP  : 0.4439425
Corr : 0.4864254
RSQ  : 0.2366097
Possible improvements I think right now:

The function gives me the position of the samples with NA values, so location is easier
 that the function removes these samples and the calculations can be done without them.


No hay comentarios:

Publicar un comentario