dastd
Directly standardised rates
dastd(x, n, strat, grp = NULL, std, ref = NULL, per = 1, level = 0.95)The rate each group would have with the stratum make-up (age bands, say) of a standard population: the sum over strata of the standard’s weights times the group’s stratum rates. The interval is Fay and Feuer’s gamma interval; the ratio of two standardised rates has a log-normal interval and their difference a normal one.
Parameters
Section titled “Parameters”xThe events: numbers from 0; or a
clprelist fromclprep().nThe exposure of each row: positive numbers.
stratThe stratum of each row: labels.
grpNULL(one group) or the group of each row: labels. Each group has one row per stratum.stdThe standard population (or weights) of each stratum: numbers from 0 with a positive sum, named by stratum or in the order of the strata (a factor’s levels, or the sorted labels).
refThe reference group: a label or a position; the first group by default.
perThe rates and differences are given per
perunits ofn(1e5 for rates per 100,000, 100 for percentages): one positive number.levelThe confidence level of the intervals: one number strictly between 0 and 1.
Returns
Section titled “Returns”An object of class dastd, a list: rates (group, x the
events, rate, lo, hi, var the variance of the rate), cmp (one
row per group but the reference: group, ratio, lo, hi, diff,
dlo, dhi), ref, per and level.
References
Section titled “References”Fay, M. P. and Feuer, E. J. (1997). Confidence intervals for directly standardized rates: a method based on the gamma distribution. Statistics in Medicine, 16(7), 791-801.
Examples
Section titled “Examples”d <- data.frame(age = rep(c("18-29", "30-49", "50+"), 2), grp = rep(c("A", "B"), each = 3), x = c(30, 22, 5, 41, 30, 12), n = c(5000, 9000, 6000, 3000, 8000, 7000))dastd(d$x, d$n, d$age, d$grp, std = c(30, 45, 25), per = 1e4)Generated from the R help page: dastd in the R reference.