I'm using the surveil
R package to calculate incidence rates
https://cran.rstudio.com/web/packages/surveil/vignettes/surveil-demo.html
library(surveil)
library(dplyr)
library(ggplot2)
library(knitr)
tx.msa <- msa %>%
group_by(Year, Race) %>%
summarise(Count = sum(Count),
Population = sum(Population))
fit <- stan_rw(tx.msa,
time = Year,
group = Race,
iter = 1500,
chains = 2 #, for speed only; use default chains=4
)
Result summaries can be accessed using fit$summary
But I cannot find out how to calculate the mean incidence rate of the whole period under study, not year by year, it is usually reported as just one number e.g. 2.17/100.000