#provide the two expected and observed count to get the ratio of SIRs/SMRs
msSPChelpR::sir_ratio(o1 = 2140, o2 = 3158, e1 = 1993, e2 = 2123)
#calculate lower confidence limit
msSPChelpR::sir_ratio_lci(o1 = 2140, o2 = 3158, e1 = 1993, e2 = 2123, alpha = 0.05)
#calculate upper confidence limit
msSPChelpR::sir_ratio_uci(o1 = 2140, o2 = 3158, e1 = 1993, e2 = 2123, alpha = 0.05)
#functions can be easily used inside dplyr::mutate function
library(dplyr)
test_df <- data.frame(sir_oth = c(1.07, 1.36, 0.96),
sir_smo = c(1.49, 1.81, 1.41),
observed_oth = c(2140, 748, 1392),
expected_oth = c(1993, 550, 1443),
observed_smo = c(3158, 744, 2414),
expected_smo = c(2123, 412, 1711))
test_df %>%
mutate(smo_ratio = sir_ratio(observed_oth, observed_smo, expected_oth, expected_smo),
smo_ratio_lci = sir_ratio_lci(observed_oth, observed_smo, expected_oth, expected_smo),
smo_ratio_uci = sir_ratio_uci(observed_oth, observed_smo, expected_oth, expected_smo))
Run the code above in your browser using DataLab