prec_rate: Sample size or precision for a rate

Description Usage Arguments Details Value References See Also Examples

View source: R/descriptive_stats.R

Description

prec_rate returns the sample size or the precision for the provided rate

Usage

1
2
3
prec_rate(r, x = NULL, conf.width = NULL, conf.level = 0.95,
  method = c("score", "vs", "exact", "wald"),
  tol = .Machine$double.eps^0.25)

Arguments

r

rate or rate ratio.

x

number of events

conf.width

precision (the full width of the conficende interval)

conf.level

confidence level

method

The method to use to calculate precision. Exactly one method may be provided. Methods can be abbreviated.

tol

numerical tolerance used in root finding, the default providing (at least) four significant digits

Details

Exactly one of the parameters r, conf.width must be passed as NULL, and that parameter is determined from the other.

The score, variance stabilizing (vs), exact, and wald method are implemented to calculate the rate and the precision. For few events x (<5), the exact method is recommended.

If more than one method is specified or the method is miss-specified, the 'score' method will be used.

uniroot is used to solve n for the score and exact method. Agresti-coull can be abbreviated by ac.

Value

Object of class "presize", a list of arguments (including the computed one) augmented with method and note elements.

References

Barker, L. (2002) A Comparison of Nine Confidence Intervals for a Poisson Parameter When the Expected Number of Events is 5, The American Statistician, 56:2, 85-89, DOI: 10.1198/000313002317572736

See Also

poisson.test

Examples

1
2
3
4
5
prec_rate(2.5, x = 20, met = "score")
prec_rate(2.5, x = 20, met = "exact")
# vs and wald have the same conf.width, but different lwr and upr
prec_rate(2.5, x = 20, met = "wald")
prec_rate(2.5, x = 20, met = "vs")

a-lenz/presize documentation built on May 17, 2019, 7:44 a.m.