Learn R Programming

⚠️There's a newer version (1.6.6.1) of this package.Take me there.

rstpm2: An R package for link-based survival models

NOTE: versions 1.4.1 and 1.4.2 of rstpm2 included a critical bug in the predict function for type in "hr", "hdiff", "meanhr" or "marghr".

Introduction

This package provides link-based survival models that extend the Royston-Parmar models, a family of flexible parametric models. There are two main classes included in this package:

A. The class stpm2 is an R version of stpm2 in Stata with some extensions, including:

  1. Multiple links (log-log, -probit, -logit);

  2. Left truncation and right censoring (with experimental support for interval censoring);

  3. Relative survival;

  4. Cure models (where we introduce the nsx smoother, which extends the ns smoother);

  5. Predictions for survival, hazards, survival differences, hazard differences, mean survival, etc;

  6. Functional forms can be represented in regression splines or other parametric forms;

  7. The smoothers for time can use any transformation of time, including no transformation or log(time).

B. Another class pstpm2 is the implementation of the penalised models and corresponding penalized likelihood estimation methods. The main aim is to represent another way to deal with non-proportional hazards and adjust for potential continuous confounders in functional forms, not limited to proportional hazards and linear effect forms for all covariates. Functional forms can be represented in penalized regression splines (all mgcv smoothers ) or other parametric forms.

Some examples

The default for the parametric model is to use the Royston Parmar model, which uses a natural spline for the transformed baseline for log(time) with a log-log link.

require(rstpm2)
data(brcancer)
fit <- stpm2(Surv(rectime,censrec==1)~hormon,data=brcancer,df=3)
plot(fit,newdata=data.frame(hormon=0),type="hazard")

The default for the penalised model is similar, using a thin-plate spline for the transformed baseline for log(time) with a log-log link. The advantage of the penalised model is that there is no need to specify the knots or degrees of freedom for the baseline smoother.

fit <- pstpm2(Surv(rectime,censrec==1)~hormon,data=brcancer)
plot(fit,newdata=data.frame(hormon=0),type="hazard")

Copy Link

Version

Install

install.packages('rstpm2')

Monthly Downloads

8,470

Version

1.6.2

License

GPL-2 | GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Mark Clements

Last Published

March 8th, 2023

Functions in rstpm2 (1.6.2)

legendre.quadrature.rule.200

Legendre quadrature rule for n=200.
lines.stpm2

S3 methods for lines
colon

Colon cancer.
cox.tvc

Test for a time-varying effect in the coxph model
gsm.control

Defaults for the gsm call
gsm

Parametric and penalised generalised survival models
incrVar

Utility that returns a function to increment a variable in a data-frame.
gsm_design

Extract design information from an stpm2/gsm object and newdata for use in C++
grad

gradient function (internal function)
eform.stpm2

S3 method for to provide exponentiated coefficents with confidence intervals.
popmort

Background mortality rates for the colon dataset.
numDeltaMethod

Calculate numerical delta method for non-linear predictions.
plot-methods

plots for an stpm2 fit
predict.nsx

Evaluate a Spline Basis
predict-methods

Predicted values for an stpm2 or pstpm2 fit
nsx

Generate a Basis Matrix for Natural Cubic Splines (with eXtensions)
predictnl-methods

~~ Methods for Function predictnl ~~
nsxD

Generate a Basis Matrix for the first derivative of Natural Cubic Splines (with eXtensions)
markov_sde

Predictions for continuous time, nonhomogeneous Markov multi-state models using Aalen's additive hazards models.
markov_msm

Predictions for continuous time, nonhomogeneous Markov multi-state models using parametric and penalised survival models.
simulate-methods

Simulate values from an stpm2 or pstpm2 fit
predictnl

Estimation of standard errors using the numerical delta method.
update-methods

Methods for Function update
stpm2-class

Class "stpm2" ~~~
vuniroot

Vectorised One Dimensional Root (Zero) Finding
tvcCoxph-class

Class "tvcCoxph"
residuals-methods

Residual values for an stpm2 or pstpm2 fit
smoothpwc

Utility to use a smooth function in markov_msm based on piece-wise constant values
rstpm2-internal

Internal functions for the rstpm2 package.
pstpm2-class

Class "pstpm2"
brcancer

German breast cancer data from Stata.
bhazard

Placemarker function for a baseline hazard function.
aft

Parametric accelerated failure time model with smooth time functions
aft_integrated-class

Class "stpm2" ~~~
Rstpm2-package

Flexible parametric survival models.
aft_mixture

Parametric accelerated failure time model with smooth time functions
coef<-

Generic method to update the coef in an object.
aft_integrated

Parametric accelerated failure time model with smooth time functions
aft-class

Class "stpm2" ~~~
aft_mixture-class

Class "stpm2" ~~~