Standard error, standard deviations and confidence intervals

I found this website while looking for error bars in R. Well, it seems to explain the confusion between standard error, deviation and confidence intervals.

An here is how I implement it in R.

confidence interval at 95% level

confint <- function(x) { n <- length(x[!is.na(x)]); qt(0.95,n) * sd(x,na.rm = TRUE) / sqrt(n); }

plot confidence intervals with specified values

plot.confint <- function(x,y,xconfint=NULL,yconfint = NULL, lty=NULL, col=par("fg"), lwd=par("lwd"), len=0.03 ) { if (!is.null(yconfint)) { arrows(x,y+yconfint,x,y-yconfint, angle=90, code=3, length=len, col=col, lwd=lwd, lty=lty); } if (!is.null(xconfint)) { arrows(x-xconfint,y,x+xconfint,y, angle=90, code=3, length=len, col=col, lwd=lwd, lty=lty); }

}

Leave a Reply