1 may 2012

Monitoring some statistics with "R"

I´ve been practicing after reading a couple of tutorials:
to create a basic function  to monitor some  basic statistics as RMSEP, Bias, SEP, Correlation and RSQ.
 I´ve been doing this with other software`s, so it´s time for “R”. This is the script, please add feedback to improve it.
 monitor2<-function(x,y){
     n<-length(y)
     res<-y-x
     {rmsep<-sqrt(sum((y-x)^2)/n)
     cat("RMSEP:",rmsep,"\n")}
     {(bias<-mean(res))
     cat("Bias :",bias,"\n")}
     {sep<-sd(res)
     cat("SEP  :",sep,"\n")}
     {r<-cor(x,y)
     cat("Corr :",r,"\n")}
     {rsq<-(r^2)
     cat("RSQ  :",rsq,"\n")}
     }

Example:
> x<-c(1:10)
> y<-c(2:11)
> monitor2(x,y)
RMSEP: 1
Bias : 1
SEP  : 0
Corr : 1
RSQ  : 1

No hay comentarios:

Publicar un comentario