Learn R Programming

berryFunctions (version 1.4)

ci: calculate confidence interval around mean

Description

calculate the ends of the confidence interval around mean using t.test

Usage

ci(dat, lev = 0.95, digits = 3)

Arguments

dat
vector with the data to use.
lev
numeric. confidence level. DEFAULT: 0.95
digits
integer. Number of digits rounded to in output. DEFAULT: 3

Value

  • A dataframe with the lower and upper confidence interval, as well as the level used.

Details

Remember that CIs are used when insecurities about the inference from a sample to a general population need quantification, not for hypothesis testing. If two confidence intervals overlap, the difference between the two means still may be significantly different.

References

For newbies: Charles Wheelan: naked statistics - stripping the dread from the data, 2013, Norton, ISBN 978-0-393-07195-5. For statisticians: any of your favorite statistics books should cover confidence intervalls ;-) http://en.wikipedia.org/wiki/Confidence_interval Wolfe R, Hanley J (Jan 2002). "If we're so different, why do we keep overlapping? When 1 plus 1 doesn't make 2" http://www.ecmaj.ca/content/166/1/65.full.pdf Goldstein, H.; Healey, M.J.R. (1995). "The graphical presentation of a collection of means". Journal of the Royal Statistical Society http://www.jstor.org/stable/view/2983411

See Also

t.test , cie

Examples

Run this code
yourdata <- c(5:8,3,14)
ci(yourdata)          # confidence interval with the default confidence level (95%)
ci(yourdata, 0.99)    # specified with a different confidence level 
ci(yourdata, 0.99, 4) # returns 4 decimal places
ci(yourdata,,2)       # rounds to 2 decimal places with default level
ci(yourdata)[1,1]     # returns lower boundary of the interval as a numeric
ci(yourdata)[1,2]     # returns upper boundary of the interval as a numeric
ci                    # shows the function itself

Run the code above in your browser using DataLab