get_ci_pois: Calculate a Poisson distribution confidence interval

Description Usage Arguments Details Value References See Also Examples

View source: R/get_ci.R

Description

Calculate a Poisson distribution confidence interval. This function imitates stats::qpois() using stats::qchisq() to allow for the continuous extension of the estimate.

Usage

1
get_ci_pois(interval, x, y = NULL)

Arguments

interval

A scalar between 0 and 1, indicating the width of the interval. For example, use 0.95 to calculate a 95% confidence interval.

x

A numeric vector of positive integers. It can contain the stratum-specific number of events or the observed number of events in the study population.

y

A vector of positive numbers. It can contain the population-time for each stratum or the expected number of events. The default value is NULL.

Details

When working with rates, pass the stratum-specific number of events as x and the population-time for each stratum as y. When working with standardized morbidity/mortality ratios, pass the observed number of events as x and the expected number of events as y. Ensure that the values of x and y are aligned and that the vectors are the same length.

To calculate a confidence interval around count data, pass a vector of counts as x.

This function is used to construct confidence intervals in get_spec_rt().

Value

A data frame with columns lower and upper, which contain the lower and upper limits of a confidence interval, respectively.

References

The STDRATE Procedure

See Also

get_ci_norm(), get_ci_lnorm(), get_ci_gamma()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# calculate a single confidence interval
get_ci_pois(interval = 0.95, x = 49, y = 52) # rate
get_ci_pois(interval = 0.95, x = 11) # count

# use columns of a data frame as inputs
df <- data.frame(x = c(24, 49), y = c(94, 52))

# using dplyr
df %>%
  dplyr::mutate(get_ci_pois(0.95, x, y))

# using base
get_ci_pois(0.95, df$x, df$y)

## End(Not run)

bcgov/bcEpiRate documentation built on Feb. 24, 2022, 4:05 p.m.