Skip to contents

Computes an exact Poisson confidence interval for a count rate.

Usage

ci_poisson(x, n, conf_level = 0.95)

Arguments

x

Vector (or sum) of observed counts, e.g. all counts falling in one exposure bin

n

Number of units the counts were accumulated over (e.g. the number of observations in the bin); the rate being estimated is sum(x) / n

conf_level

Confidence level

Value

Named numeric vector (lower, upper) for the rate sum(x) / n, with confidence level stored as an attribute.

Details

The count-response analogue of ci_clopper_pearson(), used by the quantile-binned summary layer (see er_plot_add_quantiles()) and er_vpc_add_observed()/er_vpc_add_simulated() when response_type = "count" is explicitly declared. Unlike ci_t() (the default, opt-in-required approximation used when a count response auto-detects or is declared "continuous"), this interval is exact and never produces a negative lower bound. Uses the standard exact ("Garwood") Poisson interval, derived from the chi-squared/gamma relationship; if the total count is 0, the lower bound is 0.

Examples

ci_poisson(3, 10)
#>      lower      upper 
#> 0.06186721 0.87672731 
#> attr(,"conf_level")
#> [1] 0.95