PHEindicatormethods (version 1.1.5)

phe_smr: Calculate Standardised Mortality Ratios using phe_smr

Description

Calculates standard mortality ratios (or indirectly standardised ratios) with confidence limits using Byar's [1] or exact [2] CI method.

Usage

phe_smr(data, x, n, x_ref, n_ref, refpoptype = "vector", type = "full",
  confidence = 0.95, refvalue = 1)

Arguments

data

data.frame containing the data to be standardised, pre-grouped if multiple SMRs required; unquoted string; no default

x

field name from data containing the observed number of events for each standardisation category (eg ageband) within each grouping set (eg area); unquoted string; no default

n

field name from data containing the populations for each standardisation category (eg ageband) within each grouping set (eg area); unquoted string; no default

x_ref

the observed number of events in the reference population for each standardisation category (eg age band); unquoted numeric vector or field name from data depending on value of refpoptype; no default

n_ref

the reference population for each standardisation category (eg age band); unquoted numeric vector or field name from data depending on value of refpoptype; no default

refpoptype

whether x_ref and n_ref have been specified as vectors or a field name from data; quoted string "field" or "vector"; default = "vector"

type

defines the data and metadata columns to be included in output; can be "value", "lower", "upper", "standard" (for all data) or "full" (for all data and metadata); quoted string; default = "full"

confidence

the required level of confidence expressed as a number between 0.9 and 1 or 90 and 100; numeric; default 0.95

refvalue

the standardised reference ratio, numeric, default = 1

Value

When type = "full", returns a tibble of observed events, expected events, standardised mortality ratios, lower confidence limits, upper confidence limits, confidence level, statistic and method for each grouping set

Notes

User MUST ensure that x, n, x_ref and n_ref vectors are all ordered by the same standardisation category values as records will be matched by position. For numerators >= 10 Byar's method [1] is applied using the byars_lower and byars_upper functions. For small numerators Byar's method is less accurate and so an exact method [2] based on the Poisson distribution is used.

References

[1] Breslow NE, Day NE. Statistical methods in cancer research, volume II: The design and analysis of cohort studies. Lyon: International Agency for Research on Cancer, World Health Organisation; 1987. [2] Armitage P, Berry G. Statistical methods in medical research (4th edn). Oxford: Blackwell; 2002.

See Also

Other PHEindicatormethods package functions: phe_dsr, phe_isr, phe_life_expectancy, phe_mean, phe_proportion, phe_quantile, phe_rate, phe_sii

Examples

Run this code
# NOT RUN {
library(dplyr)
df <- data.frame(indicatorid = rep(c(1234, 5678, 91011, 121314), each = 19 * 2 * 5),
                 year = rep(2006:2010, each = 19 * 2),
                 sex = rep(rep(c("Male", "Female"), each = 19), 5),
                 ageband = rep(c(0,5,10,15,20,25,30,35,40,45,
                                 50,55,60,65,70,75,80,85,90), times = 10),
                 obs = sample(200, 19 * 2 * 5 * 4, replace = TRUE),
                 pop = sample(10000:20000, 19 * 2 * 5 * 4, replace = TRUE))

refdf <- data.frame(refcount = sample(200, 19, replace = TRUE),
                    refpop = sample(10000:20000, 19, replace = TRUE))

df %>%
    group_by(indicatorid, year, sex) %>%
    phe_smr(obs, pop, refdf$refcount, refdf$refpop, type="standard")

## OR

df %>%
    group_by(indicatorid, year, sex) %>%
    phe_smr(obs, pop, refdf$refcount, refdf$refpop, confidence=99.8, refvalue=100)

# }

Run the code above in your browser using DataCamp Workspace