0

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

Ana
  • 149
  • 3
  • 12
  • 1
    Isn't this just a simple calculation of cases/population/years ? – Allan Cameron May 28 '23 at 15:03
  • You might need to add an `ungroup()` after the summarise function. – nrennie May 28 '23 at 23:27
  • I cannot use group = NULL in the stan_rw command, it requires to include a group, maybe I could create a dummy group where everybody is in the same group and it could work – Ana May 29 '23 at 10:59

0 Answers0