rate_ratio: Confidence intervals for the rate ratios

View source: R/incidence_rates_utils.R

rate_ratioR Documentation

Confidence intervals for the rate ratios

Description

Calculate rate ratio with confidence intervals for rate objects or observations and person-years.

Usage

rate_ratio(x, y, crude = FALSE, SE.method = TRUE)

Arguments

x

a rate-object, vector of two; rate and standard error or observed and person-years.

y

a rate-object, vector of two; rate and standard error or observed and person-years.

crude

set TRUE to use crude rates; default is FALSE.

SE.method

default TRUE; if x and y are vectors of observed and person-years, this must be changed to FALSE.

Details

Calculate rate ratio of two age standardized rate objects (see ⁠[rate]⁠). Multiple rates for each objects is supported if there are an equal number of rates. Another option is to set x and y as a vector of two.

  1. rate and its standard error, and set SE.method = TRUE.

  2. observations and person-year, and set SE.method = FALSE.

See examples.

Value

A vector length of three: rate_ratio, and lower and upper confidence intervals.

Author(s)

Matti Rantanen

See Also

⁠[rate]⁠

Other rate functions: rate()

Examples


# two rate ratios; silly example with female rectal / breast cancer
## mortality rates
data("sire", package = "popEpi")
data("sibr", package = "popEpi")

BL <- list(per = 2000:2005)

re <- lexpand(sire, birth = "bi_date", entry = "dg_date", exit = "ex_date",
              status = status == 1, breaks = BL, aggre = list(per))
br <- lexpand(sibr, birth = "bi_date", entry = "dg_date", exit = "ex_date",
              status = status == 1, breaks = BL, aggre = list(per))

r_re <- rate(re, obs = "from0to1", pyrs = "pyrs")
r_br <- rate(br, obs = "from0to1", pyrs = "pyrs")

rate_ratio(r_re, r_br, SE.method = TRUE)


# manually set rates (0.003 and 0.005) and SEs (0.001 and 0.002)
# so that x = y = c('rate', 'SE')
rate_ratio(x= c(0.003, 0.001), y= c(0.005, 0.002), SE.method = TRUE)

# observed numbers (10 and 20) and person-years (30000 and 40000):
rate_ratio(x = c(10, 30000), y = c(20, 40000), SE.method = FALSE)


popEpi documentation built on April 4, 2025, 2:51 a.m.