https://github.com/finnishcancerregistry/popepi
Epidemiological analysis for population-based data.
https://github.com/finnishcancerregistry/popepi
adjust-estimates age-adjusting direct-adjusting epidemiology indirect-adjusting r r-package survival
Last synced: about 1 month ago
JSON representation
Epidemiological analysis for population-based data.
- Host: GitHub
- URL: https://github.com/finnishcancerregistry/popepi
- Owner: FinnishCancerRegistry
- License: other
- Created: 2015-09-18T06:15:35.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2025-10-07T13:17:07.000Z (about 1 month ago)
- Last Synced: 2025-10-07T15:20:18.077Z (about 1 month ago)
- Topics: adjust-estimates, age-adjusting, direct-adjusting, epidemiology, indirect-adjusting, r, r-package, survival
- Language: R
- Homepage:
- Size: 11.3 MB
- Stars: 8
- Watchers: 4
- Forks: 7
- Open Issues: 39
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output:
md_document:
variant: markdown_github
---
```{r, echo = FALSE, results='hide', message = FALSE, warning=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
library(popEpi)
```
[](https://cran.r-project.org/package=popEpi)
[](https://app.codecov.io/gh/FinnishCancerRegistry/popEpi?branch=master)
[](https://cran.r-project.org/package=popEpi)
[](https://github.com/FinnishCancerRegistry/popEpi/actions/workflows/R-CMD-check.yaml)
# popEpi: Epidemiology with population data
The purpose of popEpi is to facilitate computing certain epidemiological
statistics where population data is used. Current main attractions:
## Splitting, merging population hazards, and aggregating
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.
```{r lexpand}
data(sire)
sr <- sire[1,]
print(sr)
```
```{r lexpand2}
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)
```
```{r lexpand3}
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)
```
```{r aggre}
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)
```
## SIRs / SMRs
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.
```{r sir}
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
```
## (Relative) survival
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.
```{r survtab}
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
```