Learn R Programming

Epi (version 2.63)

Statistical Analysis in Epidemiology

Description

Functions for demographic and epidemiological analysis in the Lexis diagram, i.e. register and cohort follow-up data. In particular representation, manipulation, rate estimation and simulation for multistate data - the Lexis suite of functions, which includes interfaces to 'mstate', 'etm' and 'cmprsk' packages. Contains functions for Age-Period-Cohort and Lee-Carter modeling and a function for interval censored data. Has functions for extracting and manipulating parameter estimates and predicted values (ci.lin and its cousins), as well as a number of epidemiological data sets.

Copy Link

Version

Install

install.packages('Epi')

Monthly Downloads

8,621

Version

2.63

License

GPL-2

Maintainer

Bendix Carstensen

Last Published

March 20th, 2026

Functions in Epi (2.63)

Lexis.diagram

Plot a Lexis diagram
NArray

Set up an array of NAs, solely from the list of dimnames
N2Y

Create risk time ("Person-Years") in Lexis triangles from population count data.
N.dk

Population size in Denmark
M.dk

Mortality in Denmark 1974 ff.
Ns

Natural splines - (cubic splines linear beyond outermost knots) with convenient specification of knots and possibility of centering, detrending and clamping.
LexisScarf

Generate a knitting pattern for a tube-shaped scarf with Lexis lines
Life.lines

Compute dates/ages for life lines in a Lexis diagram
Lexis.lines

Draw life lines in a Lexis diagram.
Lexis2msm

Convert a Lexis obejct to a data set suitable for input to the msm:msm function.
Termplot

A wrapper for termplot that optionally (but by default) exponentiates terms, and plot them on a common log-scale. Also scales x-axes to the same physical scale.
apc.frame

Produce an empty frame for display of parameter-estimates from Age-Period-Cohort-models.
addCov

Add covariates (typically clinical measurements) taken at known times to a Lexis object.
S.typh

Salmonella Typhimurium outbreak 1996 in Denmark.
Y.dk

Population risk time in Denmark
Relevel

Reorder and combine levels of a factor
ROC

Function to compute and draw ROC-curves.
addDrug

Expand a Lexis object with information of drug exposure based on purchase dates and -amounts
apc.LCa

Fit Age-Period-Cohort models and Lee-Carter models with effects modeled by natural splines.
apc.fit

Fit an Age-Period-Cohort model to tabular data.
blcaIT

Bladder cancer mortality in Italian males
ccwc

Generate a nested case-control study
bdendo

A case-control study of endometrial cancer
ci.Crisk

Compute cumulative risks and expected sojourn times from models for cause-specific rates.
brv

Bereavement in an elderly cohort
bootLexis

Create a bootstrap sample of persons (as identified by lex.id) from a Lexis object
births

Births in a London Hospital
cal.yr

Functions to convert character, factor and various date objects into a number, and vice versa.
ci.cum

Compute cumulative sum of estimates.
boxes.MS

Draw boxes and arrows for illustration of multistate models.
detrend

Projection of a model matrix on the orthogonal complement of a trend or curvature.
diet

Diet and heart data
contr.cum

Contrast matrices
clogistic

Conditional logistic regression
cutLexis

Cut follow-up at a specified date for each person.
crr.Lexis

Fit a competing risks regression model (Fine-Gray model) using a Lexis object)
ci.lin

Compute linear functions of parameters with standard errors and confidence limits, optionally transforming to a different scale.
ci.pd

Compute confidence limits for a difference of two independent proportions.
effx

Function to calculate effects
ci.eta

Linear predictor (eta) from a formula, coefficients, vcov and a prediction frame.
foreign.Lexis

Create a data structures suitable for use with packages mstate or etm.
ftrend

Fit a floating trend to a factor in generalized linear model
ewrates

Rates of lung and nasal cancer mortality, and total mortality.
fit.mult

Fits a multiplicative relative risk model to interval censored data.
effx.match

Function to calculate effects for individually matched case-control studies
erl

Compute survival functions from rates and expected residual lifetime in an illness-death model as well as years of life lost to disease.
fit.add

Fit an additive excess risk model to interval censored data.
float

Calculate floated variances
fit.baseline

Fit a piecewise contsnt intesity model for interval censored data.
expand.data

Function to expand data for regression analysis of interval censored data.
legendbox

Draw a box with text explaining the numbers in and between boxes from boxes.MS and boxes.Lexis
in.span

Is x in the column span of matrix A and what columns are linearly dependent?
gmortDK

Population mortality rates for Denmark in 5-years age groups.
lep

An unmatched case-control study of leprosy incidence
apc.lines

Plot APC-estimates in an APC-frame.
hivDK

hivDK: seroconversion in a cohort of Danish men
lgrep

Convenience versions of grep
lls

Functions to manage and explore the workspace
gen.exp

Generate covariates for drug-exposure follow-up from drug purchase records.
harm

Create a basis of harmonic functions.
ncut

Function to group a variable in intervals.
nice

Nice breakpoints for axes on plots
matshade

Plot confidence intervals as shaded areas around lines.
mh

Mantel-Haenszel analyses of cohort and case-control studies
mcutLexis

Cut follow-up at multiple event dates and keep track of order of events
merge.Lexis

Merge a Lexis object with a data frame
mat2pol

Plot columns of a matrix as stacked areas.
lungDK

Male lung cancer incidence in Denmark
mortDK

Population mortality rates for Denmark in 1-year age-classes.
mod.Lexis

Fit intensity models to follow-up data in Lexis objects
plot.Lexis

Lexis diagrams
paths.Lexis

Generate paths traveled through a Lexis multistate model data frame.
occup

A small occupational cohort
overlap.Lexis

Check if records in a Lexis object represent overlapping epochs
nickel

A Cohort of Nickel Smelters in South Wales
pc.lines

Plot period and cohort effects in an APC-frame.
plot.apc

Plot the estimates from a fitted Age-Period-Cohort model
pctab

Create percentages in a table
plotEst

Plot estimates with confidence limits (forest plot)
plotCIF

Plotting Aalen-Johansen curves for competing events
pr

Diabetes prevance as of 2010-01-01 in Denmark
poisreg

Family Object for Poisson Regression
projection.ip

Projection of columns of a matrix.
rcutLexis

A function to cut follow-up at intermediate event times.
rm.tr

Remove transitions from a Lexis object.
rateplot

Functions to plot rates from a table classified by age and calendar time (period)
simLexis

Simulate a Lexis object representing follow-up in a multistate model.
splitLexis

Split follow-up time in a Lexis object
plotevent

Plot Equivalence Classes
cbind.Lexis

Combining a Lexis objects with data frames or other Lexis objects
entry.Lexis

Time series and other methods for Lexis objects
stack.Lexis

Functions to facilitate analysis of multistate models.
steno2

Clinical trial: Steno2 baseline and follow-up.
thoro

Thorotrast Study
testisDK

Testis cancer incidence in Denmark, 1943--1996
stat.table

Tables of summary statistics
timeBand

Extract time band data from a split Lexis object
summary.Lexis

Summarize transitions and risk time from a Lexis object
subset.Lexis

Subsetting Lexis (and stacked.Lexis) objects
stattable.funs

Special functions for use in stat.table
xcutLexis

Cut follow-up in a Lexis object by event date(s) while preserving the original states.
twoby2

Analysis of a two by two table
unLexis

Remove Lexis attributes from a Lexis object.
transform.Lexis

Transform a Lexis (or stacked.Lexis) object
timeScales

The time scales of a Lexis object
DMepi

Epidemiological rates for diabetes in Denmark 1996--2015
Epi

Epi: Functions for manipulation and statistical analysis of epidemiological data
BrCa

Clinical status, relapse, metastasis and death in 2982 women with breast cancer.
B.dk

Births in Denmark by year and month of birth and sex
AaJ

The Aalen-Johansen estimator of state probabilities from a multistate Lexis object.
DMlate

The Danish National Diabetes Register.
DMconv

Conversion to diabetes
Icens

Fits a regression model to interval censored data.
Lexis

Create a Lexis object of follow-up
LCa.fit

Fit Lee-Carter-type models for rates to arbitrarily shaped observations of rates in a Lexis diagram.