get_ci_gamma: Calculate a gamma distribution confidence interval

Description Usage Arguments Details Value References See Also Examples

View source: R/get_ci.R

Description

Derive an approximate gamma distribution confidence interval using stats::qchisq().

Usage

1
get_ci_gamma(interval, estimate, weights, variance, method = "tcz06")

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.

estimate

A numeric vector containing the point estimates.

weights

A list of numeric vectors where each vector contains the weights of each strata in the directly standardized rate calculation.

variance

A numeric vector containing the variances.

method

A string to indicate which method to use to calculate the confidence interval. The default is "tcz06", which refers to the method proposed by Tiwari, Clegg, and Zou (2006). Use "ff97" for a more conservative (wider) confidence interval, as proposed by Fay and Feuer (1997).

Details

This function assumes that the values of the input arguments estimate, weights, and variance are aligned and that they are the same length.

This function is used to construct confidence intervals in get_ds_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_pois()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
# calculate a single confidence interval
e_1 <- 0.015
w_1 <- c(
  3.7e-05, 2.2e-05, 2.0e-05, 1.2e-05, 2.3e-05,
  7.0e-05, 3.8e-05, 6.0e-05, 1.7e-05, 2.6e-05
)
v_1 <- 1e-06

get_ci_gamma(interval = 0.95, estimate = e_1, weights = list(w_1), variance = v_1)
get_ci_gamma(interval = 0.9, estimate = e_1, weights = list(w_1), variance = v_1, method = "ff97")

# calculate confidence intervals around multiple estimates
e_2 <- 0.004
w_2 <- c(
  3.4e-06, 2.0e-06, 1.8e-06, 1.1e-06, 2.1e-06,
  6.3e-06, 3.5e-06, 5.4e-06, 1.5e-06, 2.3e-06
)
v_2 <- 1e-08

get_ci_gamma(
  interval = 0.9, estimate = c(e_1, e_2),
  weights = list(w_1, w_2), variance = c(v_1, v_2)
)

## End(Not run)

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