standardize.rate: Standardize proportions and absolute risks to a given age...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/standardize.rate.R

Description

Standardize proportions and absolute risks to a given age distribution

Usage

1
2
3
standardize.rate(x, age = "agegroups", exposure, by,
  standardize.to = "ref.level", data, method = "gamma", level = 0.95,
  crude = TRUE, ...)

Arguments

x

List of names of variable names used to calculate the rates. Each element of the list contains the names of two variables in the dataset: the first variable contains the number of events and the second variable contains the number of subjects or person years.

age

Name of categorical age variable.

exposure

Name of the exposure variable for rate ratios.

by

Vector of names of further categorical strata variables

standardize.to

what population to use for standardization.

data

Data set which contains all the variables

method

Character. The method for calculating confidence intervals. If "gamma" use gamma distribution (see Fay et al.). If "wald" or "wald-log" use normal or log-normal approximation.

level

Confidence level

crude

Logical. If TRUE calculate crude rates too.

...

Not (yet) used

Details

Standardize proportions and absolute risks to a given age distribution

Value

Data table with standardized rates (and crude rates if asked for)

Author(s)

Thomas A. Gerds <[email protected]>

See Also

standardize.prodlim standardize.proportion epitools::ageadjust.direct

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(riskRegression)
set.seed(84)
n=160
d <- data.table(e1=rpois(n,lambda=9),
                rt1=rpois(n,lambda=1880),
                e2=rpois(n,lambda=123),
                rt2=rpois(n,lambda=80000))
d[,agegroups:=factor(rep(c("40-50","45-50","50-55","55-60","60-65","65-70","70-75","75-80"),n/8))]
d[,sex:=factor(rep(c("f","m"),c(n/2,n/2)))]
d[,year:=rep(2001:2010,n/10)]
D=d[,.(e1=sum(e1),rt1=sum(rt1),e2=sum(e2),rt2=sum(rt2)),by=c("sex","agegroups")]
D[sex=="m",e1:=e1+rpois(.N,lambda=as.numeric(agegroups)*17)]
D[sex=="m",rt1:=rt1-rpois(.N,lambda=as.numeric(agegroups)*1600)]
standardize.rate(x=list(c("e1","rt1")),
                 age="agegroups",exposure="sex",data=D,standardize.to="f")
standardize.rate(x=list(c("e1","rt1")),
                 age="agegroups",exposure="sex",data=D,standardize.to="m")
standardize.rate(x=list(c("e1","rt1")),
                 age="agegroups",exposure="sex",data=D,standardize.to="mean")
standardize.rate(x=list("rate1"=c("e1","rt1"),"rate2"=c("e2","rt2")),
                 age="agegroups",exposure="sex",data=d,by="year")

tagteam/heaven documentation built on Feb. 21, 2019, 10:05 p.m.