Error Bar %title% Confidence Interval

Category:R ref: http://www.cyclismo.org/tutorial/R/confidence.html

values = iris$Sepal.Length

n = length(values)
m = mean(values)
s = sd(values)

error = qt(0.975,df=n-1)*s/sqrt(n)
lower_limit = m - error
upper_limit = m + error

plot(density(values))
abline( v = c(lower_limit, upper_limit), col="red" )
values = iris$Sepal.Length

n = length(values)
m = mean(values)
s = sd(values)

error = qnorm(0.975)*s/sqrt(n)
lower_limit = m - error
upper_limit = m + error

plot(density(values))
abline( v = c(lower_limit, upper_limit), col="red" )
Homepage
Comments

Hide Comments