Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

conf.interval

Confidence interval for mean or median


Description

Calculates confidence interval for the mean or median of a distribution with unknown population variance

Usage

conf.interval(x, cl = 0.95, stat = "mean", std.error = TRUE)

Arguments

x

Vector to calculate confidence interval for

cl

Percent confidence level (default = 0.95)

stat

Statistic (mean or median)

std.error

Return standard error (TRUE/FALSE)

Value

lci Lower confidence interval value

uci Upper confidence interval value

mean If stat = "mean", mean value of distribution

mean Value of the mean or median

conf.level Confidence level used for confidence interval

std.error If std.error = TRUE standard error of distribution

Author(s)

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Examples

x <- runif(100)
 cr <- conf.interval(x, cl = 0.97) 
 print(cr)

 d <- density(x)
 plot(d, type="n", main = "PDF with mean and 0.97 confidence interval")
   polygon(d, col="cyan3")
   abline(v=mean(x, na.rm = TRUE), lty = 2)
   segments( x0=cr[["lci"]], y0=mean(d$y), x1=cr[["uci"]], 
             y1=mean(d$y), lwd = 2.5, 
             col = "black")
 	legend("topright", legend = c("mean", "CI"), 
 	       lty = c(2,1), lwd = c(1,2.5))

spatialEco

Spatial Analysis and Modelling Utilities

v1.3-6
GPL-3
Authors
Jeffrey S. Evans [aut, cre], Melanie A. Murphy [ctb], Karthik Ram [ctb]
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.