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

3,406

Version

0.7.3

License

MIT + file LICENSE

Maintainer

Andreas Bender

Last Published

March 24th, 2025

Functions in pammtools (0.7.3)

combine_df

Create a data frame from all combinations of data frames
get_cumu_coef

Extract cumulative coefficients (cumulative hazard differences)
get_lhs_vars

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

Competing risks trafo
daily

Time-dependent covariates of the patient data set.
from_to_pairs

Extract transition information from different objects
get_cumulative

Expand time-dependent covariates to functionals
geom_hazard

(Cumulative) (Step-) Hazard Plots.
get_event_types

Exctract event types
get_hazard

Calculate predicted hazard
gg_smooth

Plot smooth 1d terms of gam objects
get_plotinfo

Extract plot information for all special model terms
get_tdc_vars

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

helper function for add_trans_ci
make_time_mat

Create matrix components for cumulative effects
get_sim_ci

Calculate simulation based confidence intervals
get_ped_form

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

Visualize effect estimates for specific covariate combinations
gg_laglead

Plot Lag-Lead windows
get_cumu_eff

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

Plot tensor product effects
get_cumu_hazard

Calculate cumulative hazard
get_cif

Calculate CIF for one cause
geom_stepribbon

Step ribbon plots.
get_term

Extract partial effects for specified model terms
sample_info

Extract information of the sample contained in a data set
rpexp

Draw random numbers from piece-wise exponential distribution.
modus

Calculate the modus
patient

Survival data of critically ill ICU patients
pammtools

pammtools: Piece-wise exponential Additive Mixed Modeling tools.
get_surv_prob

Calculate survival probabilities
get_terms

Extract the partial effects of non-linear model terms
predictSurvProb.pamm

S3 method for pamm objects for compatibility with package pec
gg_re

Plot Normal QQ plots for random effects
get_cut

Obtain interval break points
has_tdc

Checks if data contains timd-dependent covariates
get_tdc_form

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

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

Extract interval information and median/modus values for covariates
get_laglead

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

Plot 1D (smooth) effects
get_intervals

Information on intervals in which times fall
cumulative

Formula specials for defining time-dependent covariates
%>%

Pipe operator
smooth.construct.fdl.smooth.spec

New basis for penalized lag selection
seq_range

Generate a sequence over the range of a vector
sim_pexp

Simulate survival times from the piece-wise exponential distribution
prep_concurrent

Extract information on concurrent effects
split_data_multistate

Split data to obtain recurrent event data in PED format
warn_about_new_time_points.glm

Warn if new t_j are used
warn_about_new_time_points

Warn if new t_j are used
split_data

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

Forrest plot of fixed coefficients
make_X

Create design matrix from a suitable object
int_info

Create start/end times and interval information
staph

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

Extract 1d smooth objects in tidy data format.
simdf_elra

Simulated data with cumulative effects
tidy_smooth2d

Extract 2d smooth objects in tidy format.
tumor

Stomach area tumor data
make_newdata

Construct a data frame suitable for prediction
tidy_re

Extract random effects in tidy data format.
tidy_fixed

Extract fixed coefficient table from model object
sim_pexp_cr

Simulate data for competing risks scenario
pamm

Fit a piece-wise exponential additive model
make_X.scam

Create design matrix from a suitable object
as.data.frame.crps

Transform crps object to data.frame
add_cif

Add cumulative incidence function to data
add_hazard

Add predicted (cumulative) hazard to data set
add_trans_prob

Add transition probabilities
add_trans_ci

Add transition probabilities confidence intervals
add_term

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

Add counterfactual observations for possible transitions
add_tdc

Add time-dependent covariate to a data set
add_surv_prob

Add survival probability estimates
fcumu

A formula special used to handle cumulative effect specifications
as_ped

Transform data to Piece-wise Exponential Data (PED)
dplyr_verbs

dplyr Verbs for ped-Objects
calc_ci

Calculate confidence intervals
compute_cumu_diff

Calculate difference in cumulative hazards and respective standard errors