Learn R Programming

pammtools: Piece-Wise Exponential Additive Mixed Modeling Tools

Installation

Install from CRAN or GitHub using:

# CRAN
install.packages("pammtools")
# Development version
remotes::install_github("adibender/pammtools")

Overview

pammtools facilitates the estimation of Piece-wise exponential Additive Mixed Models (PAMMs) for time-to-event data. PAMMs can be represented as generalized additive models and can therefore be estimated using GAM software (e.g. mgcv), which, compared to other packages for survival analysis, often offers more flexibility w.r.t. to the specification of covariate effects (e.g. non-linear, time-varying effects, cumulative effects, etc.). The package supports single-event analysis, left-truncation, recurrent events, competing risks and multi-state models.

To get started, see the Articles section.

Copy Link

Version

Install

install.packages('pammtools')

Monthly Downloads

4,924

Version

0.8.1

License

MIT + file LICENSE

Maintainer

Andreas Bender

Last Published

August 25th, 2026

Functions in pammtools (0.8.1)

add_trans_prob

Add transition probabilities
get_cumu_coef

Extract cumulative coefficients (cumulative hazard differences)
get_cumu_eff

Calculate (or plot) cumulative effect for all time-points of the follow-up
get_coefs

Extract model coefficients on the scale of the design matrix
get_lhs_vars

Extract variables from the left-hand-side of a formula
from_to_pairs

Extract transition information from different objects
geom_hazard

(Cumulative) (Step-) Hazard plots.
get_cumulative

Expand time-dependent covariates to functionals
get_laglead

Construct or extract data that represents a lag-lead window
get_plotinfo

Extract plot information for all special model terms
get_Vp

Extract the (Bayesian) covariance matrix of the model coefficients
get_sim_ci

Calculate simulation based confidence intervals
geom_stepribbon

Step ribbon plots.
get_ped_form

Extract variables from the left-hand-side of a formula
get_event_types

Extract event types
get_hazard

Point hazard predictor (backend primitive)
get_intervals

Information on intervals in which times fall
gg_laglead

Plot lag-lead windows
gg_re

Plot Normal QQ plots for random effects
gg_slice

Plot 1D (smooth) effects
get_tdc_vars

Extract variables from the left-hand-side of a formula
get_smooth_terms

Enumerate plottable univariate smooth terms of a fitted model
get_surv_prob

Calculate survival probabilities
get_term

Extract the partial effect of a single smooth curve
get_cumu_hazard

Calculate cumulative hazard
get_cut

Obtain interval break points
get_term_legacy

Extract a partial effect for models without a $smooth component
gg_partial

Visualize effect estimates for specific covariate combinations
get_tdc_form

Extract variables from the left-hand-side of a formula
get_cif

Calculate CIF for one cause
get_terms

Extract the partial effects of univariate smooth model terms
gg_fixed

Forrest plot of fixed coefficients
gg_tensor

Plot tensor product effects
ic_pred_cache

Build the subject-by-interval prediction grid used for IC imputation
hazard_ci

Analytic hazard with confidence interval (coefficient models)
gg_state_occupation

Plot state occupation probabilities
interval_censored

Detect, parse and transform interval-censored survival data
int_info

Create start/end times and interval information
gg_smooth

Plot smooth 1d terms of gam objects
pamm_ic_cr

Fit a competing-risks PAMM to interval-censored data via multiple imputation
has_tdc

Checks if data contains time-dependent covariates
make_X

Create design matrix from a suitable object
impute_ic_cr

Draw event times and causes for interval-censored competing-risks subjects
make_newdata

Construct a data frame suitable for prediction
nest_tdc

Create nested data frame from data with time-dependent covariates
pamm_ic_pooling

Pooling of multiple-imputation PAMM fits
impute_ic_times

Draw event times for interval-censored subjects from the conditional hazard
nuclear

Time until nuclear power plant construction in different regions.
modus

Calculate the modus
make_X.scam

Create design matrix from a suitable object
parse_by_level

Parse the factor level from a factor-by smooth label
pammtools

pammtools: Piece-wise exponential additive mixed modeling tools.
predictSurvProb.pamm

S3 method for pamm objects for compatibility with package pec
%>%

Pipe operator
pamm

Fit a piece-wise exponential additive model
print.pamm_ic

Fit a PAMM to interval-censored data via multiple imputation
prep_concurrent

Extract information on concurrent effects
reconstruct_intlen

Reconstruct intlen from time variable and stored cut points
ped_info

Extract interval information and median/modus values for covariates
pool_pamm_fits

Pool a list of (stripped) imputation fits into a pooled summary object
patient

Survival data of critically ill ICU patients
reconstruct_cutpoints

Ensure all breakpoints are present in newdata for cumulative calculations
seq_range

Generate a sequence over the range of a vector
resolve_terms

Resolve requested terms against the model's plottable smooths
rpexp

Draw random numbers from piece-wise exponential distribution.
sim_hazard

Draw hazard trajectories from a model's sampling distribution
simdf_elra

Simulated data with cumulative effects
sample_coefs

Draw coefficients from their approximate posterior distribution
sim_pexp

Simulate survival times from the piece-wise exponential distribution
sim_pexp_cr

Simulate data for competing risks scenario
smooth.construct.fdl.smooth.spec

New basis for penalized lag selection
tidy_fixed

Extract fixed coefficient table from model object
tidy_smooth2d

Extract 2d smooth objects in tidy format.
tidy_re

Extract random effects in tidy data format.
split_data

Function to transform data without time-dependent covariates into piece-wise exponential data format
warn_about_new_time_points

Warn if new t_j are used
smooth_term_rows

Turn a single mgcv smooth into zero or more curve specifications
split_data_multistate

Split data to obtain recurrent event data in PED format
tidy_smooth

Extract 1d smooth objects in tidy data format.
cumulative

Formula specials for defining time-dependent covariates
strip_pamm_fit

Slim down a fitted PAMM for storage inside a pamm_ic object
staph

Time until staphylococcus aureaus infection in children, with possible recurrence
stop_if_undergrouped_for_cumulation

Guard against silently-wrong cumulative results from mis-grouped newdata
warn_about_new_time_points.glm

Warn if new t_j are used
tumor

Stomach area tumor data
sample_info

Extract information of the sample contained in a data set
add_surv_prob

Add survival probability estimates
add_trans_ci

Add transition probabilities confidence intervals
add_tdc

Add time-dependent covariate to a data set
add_hazard

Add predicted (cumulative) hazard to data set
as.data.frame.crps

Transform crps object to data.frame
add_counterfactual_transitions

Add counterfactual observations for possible transitions
add_term

Embeds the data set with the specified (relative) term contribution
add_inspections

Turn exact event times into interval-censored observations
add_cif

Add cumulative incidence function to data
calc_ci

Calculate confidence intervals
compute_cumu_diff

Calculate difference in cumulative hazards and respective standard errors
dplyr_verbs

dplyr verbs for ped-objects
as_ped_cr

Competing risks trafo
daily

Time-dependent covariates of the patient data set.
as_ped

Transform data to piece-wise exponential data (PED)
combine_df

Create a data frame from all combinations of data frames
make_time_mat

Create matrix components for cumulative effects
fcumu

A formula special used to handle cumulative effect specifications