crude_rate | R Documentation |
Crude or age-specific rates.
crude_rate(df, events, person_yrs, base = 1e+05, level = 95, decimals = 1)
df |
A data frame. |
events |
Number of events. |
person_yrs |
Number of person-years at risk. |
base |
Multiplier; e.g. per 100,000 population. |
level |
Confidence level expressed as percentage. |
decimals |
Decimal places to round results. |
A data table with the following fields:
events
Number of events.
person_yrs
Total person-years at risk.
rate
Crude (unadjusted) rate.
rate_stderr
Standard error of rate.
rate_lci
Lower confidence limit for rate.
rate_uci
Upper confidence limit for rate.
Confidence limits for crude rates are computed using the method of Garwood (1936).
Garwood F (1936) Fiducial limits for the Poisson distribution, Biometrika 28:437-442.
# US cancer rates by year
library(dplyr)
cancer %>%
group_by(Year) %>%
summarize(across(c(n, pop), sum)) %>%
group_modify(~ crude_rate(.x, n, pop))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.