View source: R/standardize.rate.R
dsr | R Documentation |
Function to Compute confidence interval for directly standardized rates and rate ratios
dsr(
count1,
pop1,
count0,
pop0,
stdpop,
conf.level = 0.95,
method = "gamma",
crude = TRUE
)
count1 |
counts for group 1 (e.g. exposed) |
pop1 |
number of subjects of person-years in group 1 |
count0 |
counts for group 1 (e.g. exposed) |
pop0 |
number of subjects of person-years in group 0 |
stdpop |
number of subjects of person-years in stdpop population |
conf.level |
confidence level of confidence intervals |
method |
method for calculating confidence intervals |
crude |
logical. if |
Function to Compute confidence interval for directly standardized rates and rate ratios for sparse data. Method implemented include gamma confidence intervals (for DSR), exact confidence intervals (for crude rates), the inverse of the F distribution (for DSR ratio) and some Wald confidence interval (also on log-scale) for comparison purpose.
List with crude and standardized rates and rate ratios.
Paul F Blanche <pabl@sund.ku.dk> and Thomas A. Gerds <tag@biostat.ku.dk>
Fay, Michael P., and Eric J. Feuer. "Confidence intervals for directly standardized rates: a method based on the gamma distribution." Statistics in Medicine 16.7 (1997): 791-801.
Fay, Michael P. "Approximate confidence intervals for rate ratios from directly standardized rates with sparse data." Communications in Statistics-Theory and Methods 28.9 (1999): 2141-2160.
Fay, Michael P., et al. "Estimating average annual percent change for disease rates without assuming constant change." Biometrics 62.3 (2006): 847-854.
Fay, Michael P., Michael A. Proschan, and Erica Brittain. Combining one-sample confidence procedures for inference in the two-sample case. Biometrics 71.1 (2015): 146-156.
Interesting other approaches that avaoid inconsistency between exact CI and p-values are implemented in exactci and exact2x2, see
Fay, Michael P. "Two-sided exact tests and matching confidence intervals for discrete data." R journal 2.1 (2010): 53-58.
epitools::ageadjust.direct
library(riskRegression)
library(data.table)
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)]
dsr(count1=D[sex=="m",e1], pop1=D[sex=="m",rt1],
count0=D[sex=="f",e1], pop0=D[sex=="f",rt1],
stdpop=D[sex=="f",rt1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.