Monitoring some statistics with "R"
[This article was first published on NIR-Quimiometría, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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
To leave a comment for the author, please follow the link and comment on their blog: NIR-Quimiometría.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.