View source: R/descriptive_stats.R
| prec_rate | R Documentation |
prec_rate returns the sample size or the precision for the provided
rate.
prec_rate(
r,
x = NULL,
conf.width = NULL,
conf.level = 0.95,
method = c("score", "vs", "exact", "wald"),
...
)
r |
rate or rate ratio. |
x |
number of events. |
conf.width |
precision (the full width of the confidence interval).
Should not exceed 5 times |
conf.level |
confidence level. |
method |
The method to use to calculate precision. Exactly one method may be provided. Methods can be abbreviated. |
... |
other arguments to uniroot (e.g. |
Exactly one of the parameters r or 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.
Object of class "presize", a list of arguments (including the computed one) augmented with method and note elements.
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
poisson.test
# confidence interval width for a rate of 2.5 events per unit and 20 events, # using the score method prec_rate(2.5, x = 20, met = "score") # number of events to yield a CI width of 2.243 for a rate of 2.5 events per # unit and 20 events, using the score method prec_rate(2.5, conf.width = 2.243, met = "score") # confidence interval width for a rate of 2.5 events per unit and 20 events, # using the exact method 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 = "vs") prec_rate(2.5, x = 20, met = "wald")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.