Calculates a 95 percent confidence interval for a rate difference. Uses Kirkwood and Sterne's formula for a rate difference, p241 of 2nd Ed. I think this could be re-written to work better so that it takes a data.frame as an input and compares against a given baseline.

rate_difference(numerator1, denominator1, numerator2, denominator2)

Arguments

numerator1

The numerator for the first level for comparison (e.g. the unexposed group)

denominator1

The denominator for the first level for comparison

numerator2

The numerator for the second level for comparison (e.g. the exposed group)

denominator2

The denominator for the second level for comparison

Value

A dataframe with columns for rate difference, upper and lower confidence intervals

Examples

rate_difference(33, 355, 24, 518) # matches output from p241 K&S, 2nd Ed
#>          rd         lci        uci
#> 1 0.0466257 0.009889584 0.08336182