View source: R/correlated-ratio.R
correlated_rates | R Documentation |
Function to compute ratios of correlated age-adjusted rates with a confidence interval that accounts for the correlation. This is useful for comparing the rate of a subregion (e.g. a county) with its parent (e.g. its state).
correlated_rates(
df,
region,
agegroup,
events,
person_yrs,
std_pop,
parent = "Parent Region",
base = 1e+05,
level = 95,
dec_rate = 1,
dec_ratio = 2
)
df |
A data frame with columns for region, age group, event counts, and person-years totals as described in the next four arguments |
region |
Subregion for which to calculate adjusted rates. |
agegroup |
Age group or other stratifying variable. |
events |
Number of events. |
person_yrs |
Number of person-years at risk. |
std_pop |
Vector of standard population distribution. Can be totals, proportions, or percentages. |
parent |
Name of parent region. |
base |
Multiplier; e.g. per 100,000 population. |
level |
Confidence level expressed as percentage. |
dec_rate |
Decimal places to round adjusted rates. |
dec_ratio |
Decimal places to round rate ratios. |
A data table with the following fields:
events
Number of events.
person_yrs
Total person-years at risk.
adj_rate
Age-adjusted rate.
adj_rate_stderr
Standard error of age-adjusted rate.
adj_lci
Lower confidence limit of age-adjusted rate per Tiwari (2006)
adj_uci
Upper confidence limit for age-adusted rate per Tiwari (2006)
Tiwari RC et al. (2006) Efficient interval estimation for age-adjusted cancer rates. Statistical Methods in Medical Research 15:547-569. https://www.ncbi.nlm.nih.gov/pubmed/17260923
Tiwari RC et al. (2010) Interval estimation for ratios of correlated age-adjusted rates. Journal of Data Science 8:471-482. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3279758/
# Age-adjusted COPD mortality rates by state with ratio to US rate and confidence intervals, 2016
copd_rates <- correlated_rates(copd, State, agegroup, Deaths, Population,
std_pop = c(23961, 18136, 12315, 4259), parent = "United States")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.