knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" ) library(popEpi)
The purpose of popEpi is to facilitate computing certain epidemiological statistics where population data is used. Current main attractions:
the lexpand
function allows users to split their subject-level follow-up data into sub-intervals along age, follow-up time and calendar time,
merge corresponding population hazard information to those intervals,
and to aggregate the resulting data if needed.
data(sire) sr <- sire[1,] print(sr)
x <- lexpand(sr, birth = bi_date, entry = dg_date, exit = ex_date, status = status %in% 1:2, fot = 0:5, per = 1994:2000) print(x)
data(popmort) x <- lexpand(sr, birth = bi_date, entry = dg_date, exit = ex_date, status = status %in% 1:2, fot = 0:5, per = 1994:2000, pophaz = popmort) print(x)
a <- lexpand(sr, birth = bi_date, entry = dg_date, exit = ex_date, status = status %in% 1:2, fot = 0:5, per = 1994:2000, aggre = list(fot, per)) print(a)
One can make use of the sir
function to estimate indirectly standardised incidence or
mortality ratios (SIRs/SMRs). The data can be aggregated by lexpand
or by other means.
While sir
is simple and flexible in itself, one may also use sirspline
to fit
spline functions for the effect of e.g. age as a continuous variable on SIRs.
data(popmort) data(sire) c <- lexpand( sire, status = status %in% 1:2, birth = bi_date, exit = ex_date, entry = dg_date, breaks = list(per = 1950:2013, age = 1:100, fot = c(0,10,20,Inf)), aggre = list(fot, agegroup = age, year = per, sex) ) se <- sir( coh.data = c, coh.obs = 'from0to1', coh.pyrs = 'pyrs', ref.data = popmort, ref.rate = 'haz', adjust = c('agegroup', 'year', 'sex'), print = 'fot') se
The survtab
function computes observed, net/relative and cause-specific
survivals as well as cumulative incidence functions for Lexis
data.
Any of the supported survival time functions can be
easily adjusted by any number of categorical variables if needed.
One can also use survtab_ag
for aggregated data. This means the data does
not have to be on the subject-level to compute survival time function estimates.
library(Epi) data(sibr) sire$cancer <- "rectal" sibr$cancer <- "breast" sr <- rbind(sire, sibr) sr$cancer <- factor(sr$cancer) sr <- sr[sr$dg_date < sr$ex_date, ] sr$status <- factor(sr$status, levels = 0:2, labels = c("alive", "canD", "othD")) x <- Lexis(entry = list(FUT = 0, AGE = dg_age, CAL = get.yrs(dg_date)), exit = list(CAL = get.yrs(ex_date)), data = sr, exit.status = status) st <- survtab(FUT ~ cancer, data = x, breaks = list(FUT = seq(0, 5, 1/12)), surv.type = "cif.obs") st
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.