prec_rate {presize} | R Documentation |
Sample size or precision for a rate
Description
prec_rate
returns the sample size or the precision for the provided
rate.
Usage
prec_rate(
r,
x = NULL,
conf.width = NULL,
conf.level = 0.95,
method = c("score", "vs", "exact", "wald"),
...
)
Arguments
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. |
Details
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.
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 \le
5,
The American Statistician, 56:2, 85-89,
doi:10.1198/000313002317572736
See Also
Examples
# 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")