Description Usage Arguments Details Value References See Also Examples
Calculate specific rates given a vector containing the frequencies of events and a vector containing the sizes of the defined populations.
1 2 3 4 5 6 7 8 9 |
counts |
A numeric vector containing the frequency of events. |
popn |
A numeric vector containing the size of each defined population. |
scale, power |
Provide either |
output_status |
If |
dist |
A string to indicate the type of probability distribution for the
confidence interval to follow. Can be one of the following: |
interval |
A scalar, between 0 and 1, indicating the width of the
confidence interval. For example, for a 95% confidence interval, use
|
This low-level function assumes that counts and sizes of respective
subpopulations are provided in the same order. It can also be used to
calculate a crude rate if counts
and popn
are scalars and represent the
sum of all counts and the size of the entire population respectively.
To construct confidence intervals for the rate estimates, arguments must be
explicitly supplied to both dist
and interval
.
If output_status = FALSE
and neither dist
or interval
is supplied, a
numeric vector is returned.
Otherwise, a data frame is returned with a column for rate
and up to 4
additional columns:
If output_status = TRUE
, then the column status
is included.
If both dist
and interval
are provided, then the columns interval
,
lower
, and upper
are also included.
The status
column of the output can be interpreted as follows:
"has_NA"
indicates that the numerator and/or denominator of the fraction
was NA.
"denom_0"
indicates that the denominator of the fraction was 0.
"success"
indicates that both the numerator and denominator of the
fraction were valid numbers.
get_ci_norm()
, get_ci_lnorm()
, get_ci_pois()
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:
# using vectors
counts <- c(100, 200, 300, 400, 500)
popn <- c(1000, 5000, 10000, 50000, 100000)
get_spec_rt(counts, popn)
get_spec_rt(counts, popn, scale = 1000)
get_spec_rt(counts, popn, power = 3)
# get output status
get_spec_rt(counts, popn, output_status = TRUE)
# construct confidence intervals for rate estimates
get_spec_rt(counts, popn, dist = "normal", interval = 0.95)
# using a data frame
df <- data.frame(counts, popn)
get_spec_rt(df$counts, df$popn, scale = 100000)
get_spec_rt(df$counts, df$popn, power = 5)
# using dplyr to create a column
df <- df %>%
dplyr::mutate(spec_rate = get_spec_rt(counts, popn, scale = 1000))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.