Skip to contents

ci() calculates the confidence interval around observed values given a coefficient of variation (CV).

Usage

ci(x, cv, dist = c("lognormal", "normal"), level = 0.95)

Arguments

x

A numeric vector of positive measured values.

cv

A positive scalar: coefficient of variation (e.g., 0.10 for 10%).

dist

A character scalar indicating the distributional assumption used to compute the confidence interval. Must be one of:

  • "normal": assumes measurement errors are normally distributed. The confidence interval will be symmetric around the observed value.

  • "lognormal": assumes measurement errors follow a log-normal distribution. This results in an asymmetric confidence interval, which is often more appropriate for strictly positive and right-skewed measurements (e.g., biomarker concentrations).

level

Confidence level as a proportion (e.g., 0.95 for 95%). Default is 0.95.

Value

A matrix with two columns (lower, upper) and one row per element of x.

Examples

# Lognormal assumption is often more appropriate for strictly positive
# and right-skewed measurements (e.g., biomarker concentrations).
ci(c(100, 200), 0.10, dist = "lognormal", level = 0.95)
#>          lower   upper
#> [1,]  82.24159 121.593
#> [2,] 164.48318 243.186

# Normal assumption
ci(c(100, 200), 0.10, dist = "normal", level = 0.95)
#>          lower    upper
#> [1,]  80.40036 119.5996
#> [2,] 160.80072 239.1993