Encoding: UTF-8
Type: Package
Version: 1.3.3
Date: 2025-08-11
Title: Analyzing Survival Data from an Illness-Death Model
Depends: R (≥ 2.8.1),survival,base
Description: Contains functions for data preparation, prediction of transition probabilities, estimating semi-parametric regression models and for implementing nonparametric estimators for other quantities. See Meira-Machado and Roca-Pardiñas (2011) <doi:10.18637/jss.v038.i03>.
License: GPL-3
LazyLoad: yes
LazyData: yes
NeedsCompilation: no
Packaged: 2025-08-18 11:57:23 UTC; AEFH
Maintainer: Gustavo Soutinho <gustavosoutinho@sapo.pt>
Repository: CRAN
Date/Publication: 2025-08-19 08:40:12 UTC
RoxygenNote: 7.3.2
Author: Luis Meira-Machado ORCID iD [aut], Javier Roca-Pardinas ORCID iD [aut], Artur Araujo ORCID iD [ctb], Gustavo Soutinho ORCID iD [ctb, cre]

Analyzing survival data from an illness-death model

Description

p3state.msm provides functions for estimating semi-parametric regression models but also to implement nonparametric estimators for the transition probabilities. The methods can also be used in progressive three-state models. In progressive three-state models, estimators for other quantities such as the bivariate distribution function (for the sequentially ordered events) are also given.

Details

Package: p3state.msm
Type: Package
Version: 1.3.2
Date: 2023-01-19
License: GPL-3
LazyLoad: yes
LazyData: yes

Author(s)

Luis Meira-Machado, Javier Roca Pardinas roca@uvigo.es
and Artur Araújo artur.stat@gmail.com
Maintainer: Luis Meira-Machado lmachado@math.uminho.pt

References

Crowley J., Hu M. (1977). Covariance analysis of heart transplant survival data. Journal of the American Statistical Association, 72(357), 27-36. doi:10.2307/2286902

Meira-Machado L., De Una-Alvarez J., Cadarso-Suarez C. (2006). Nonparametric estimation of transition probabilities in a non-Markov illness-death model. Lifetime Data Analysis, 12(3), 325-344. doi:10.1007/s10985-006-9009-x

de Una-Alvarez J., Meira-Machado L. (2008). A simple estimator of the bivariate distribution function for censored gap times. Statistics & Probability Letters, 78(15), 2440-2445. doi:10.1016/j.spl.2008.02.031

Meira-Machado L., Roca-Pardinas J. (2011). p3state.msm: Analyzing Survival Data from an Illness-Death Model. Journal of Statistical Software, 38(3), 1-18. doi:10.18637/jss.v038.i03


Bivariate distribution function

Description

Computation of the bivariate distribution function.

Usage

Biv(object, time1, time2)

Arguments

object

Component datafr of an object of class p3state.

time1

The first time for obtaining estimates for the transition probabilities, bivariate distribution function. NULL is equivalent to 0.

time2

The second time for obtaining estimates for the bivariate distribution function.

Value

Returns a single value.

Author(s)

Luis Meira-Machado, Javier Roca-Pardinas and Artur Araújo

References

Meira-Machado L., Roca-Pardinas J. (2011). p3state.msm: Analyzing Survival Data from an Illness-Death Model. Journal of Statistical Software, 38(3), 1-18. doi:10.18637/jss.v038.i03

See Also

p3state

Examples

data(heart2)
res.p3state<-p3state(heart2)
Biv(res.p3state,time1=30,time2=300)

Regression dataset

Description

Returns the input data in a different format. Provides the adequate dataset for implementing regression models.

Usage

data.creation.reg(data)

Arguments

data

A data.frame with at least 5 variables: times1 (time of the intermediate event/censoring time), delta (indicator of transition to the intermediate event), times2 (time to the final event/censoring time), time (times1 + times2) and status (censoring indicator: "dead"=1,"alive"=0). The remaining variables in the data.frame are left for the covariates.

Value

A data.frame in a counting process format.

Author(s)

Luis Meira-Machado, Javier Roca-Pardinas and Artur Araújo

References

Meira-Machado L., Roca-Pardinas J. (2011). p3state.msm: Analyzing Survival Data from an Illness-Death Model. Journal of Statistical Software, 38(3), 1-18. doi:10.18637/jss.v038.i03


More Stanford heart transplant data

Description

This contains the Stanford heart transplant data in a different format. The main data set is in (heart). Survival of patients on the waiting list for the Stanford heart transplant program.

Usage

data(heart2)

Format

A data frame with 103 observations on the following 8 variables.

times1

Time of transplant/censoring time.

delta

Transplant indicator.

times2

Time to death since the transplant/censoring time.

time

times1 + times2

status

Censoring indicator: dead=1, alive=0.

age

Age-48 years.

year

Year of acceptance; in years after 1 Nov 1967.

surgery

Prior bypass surgery; 1=yes.

References

Crowley J., Hu M. (1977). Covariance analysis of heart transplant survival data. Journal of the American Statistical Association, 72(357), 27-36. doi:10.2307/2286902


Inference in progressive multi-state models with three states

Description

This function provides nonparametric estimates in progressive multi-state models with three states (illness-death model and three-state model). Also fits semi-parametric Cox models in a multi-state framework (one for each transition).

Usage

p3state(data, coxdata=NULL, formula=NULL, regression=NULL)

Arguments

data

A data.frame in which to interpret the variables named in the covariates. A data frame with at least 5 variables: times1 (time of the intermediate event/censoring time), delta (indicator of transition to the intermediate event), times2 (time to the final event/censoring time), time (times1 + times2) and status (censoring indicator: "dead"=1, "alive"=0). The remaining variables in the data.frame are left for the covariates.

coxdata

Data set in a counting process data-structure. This data set can be obtained using data.creation.reg. If NULL the main function p3state will automatically create this dataset every time it is called.

formula

A formula giving the vector of covariates. For example formula=~age+sex

.

regression

A logical variable indicating whether you want the regression model.

Details

Multi-state models may be considered a generalization of survival analysis where survival is the ultimate outcome of interest but where intermediate (transient) states are identified. The influence of the intermediate events on survival may be investigated through the effect of the time-dependent covariate (using the Cox regression model with time-dependent covariates; TDCM). However, these covariates can also be re-expressed as a multi-state model with states based on the values of the covariate (typically coded as 1=yes; 0=no). If all subjects observe the intermediate event then the time-dependent covariate makes it possible to use the progressive three-state model. Otherwise makes it feasible to use an illness-death model. In these models, issues of interest include the estimation of transition probabilities and assessing the effects of individual risk factors.

Value

Returns a list of the following items:

descriptives

Vector with observed transitions between states.

datafr

data.frame to be used for obtaining the nonparametric estimates and for plotting purposes.

tdcm

Object of class ‘coxph’ with the fit of the Cox model with time-dependent covariates.

msm12

Object of class ‘coxph’ with the fit of the Cox model for transition from state 1 to state 2.

msm13

Object of class ‘coxph’ with the fit of the Cox model for transition from state 1 to state 3 (only for the progressive three-state model).

cmm23

Object of class ‘coxph’ with the fit of the Cox Markov model for transition from state 2 to state 3.

tma

Object of class ‘coxph’ with the fit of a Cox model for testing the Markov assumption.

Author(s)

Luis Meira-Machado, Javier Roca-Pardinas and Artur Araújo

References

Meira-Machado L., De Una-Alvarez J., Cadarso-Suarez C. (2006). Nonparametric estimation of transition probabilities in a non-Markov illness-death model. Lifetime Data Analysis, 12(3), 325-344. doi:10.1007/s10985-006-9009-x

de Una-Alvarez J., Meira-Machado L. (2008). A simple estimator of the bivariate distribution function for censored gap times. Statistics & Probability Letters, 78(15), 2440-2445. doi:10.1016/j.spl.2008.02.031

Meira-Machado L., Roca-Pardinas J. (2011). p3state.msm: Analyzing Survival Data from an Illness-Death Model. Journal of Statistical Software, 38(3), 1-18. doi:10.18637/jss.v038.i03

Examples

data(heart2)
res.p3state <- p3state(heart2, formula=~age+year+surgery)
summary(res.p3state)

##Only regression
summary(res.p3state, model="TDCM")
summary(res.p3state, model="CMM")

##without regression
summary(res.p3state, time1=20, time2=200)

##Both
summary(res.p3state, estimate=TRUE, time1=20, time2=200, model="CMM")

##Just for illustration purposes we create a new subset by restricting 
##the original data set from those subjects experiencing the transplant
## (progressive three-state model)
p <- which((heart2$delta==0 & heart2$status==0) | heart2$delta==1)
exampledata <- heart2[p,]
res2.p3state <- p3state(exampledata)
summary(res2.p3state)

Transition probabilities

Description

Computation of the transition probabilities.

Usage

pLIDA(object, time1, time2,tp=NULL)

Arguments

object

Component datafr of an object of class p3state.

time1

The first time for obtaining estimates for the transition probabilities, bivariate distribution function. NULL is equivalent to 0.

time2

The second time for obtaining estimates for the bivariate distribution function.

tp

Optional argument: tp="all" (default value) to obtain all the transition probabilities p11, p12 and p22; tp="p11" to obtain only p11; tp="p12" to obtain only p12; tp="p22" to obtain only p22.

Value

Returns a single value if argument tp equals "p11", "p12", or "p22". Returns a list if argument tp equals "all".

Author(s)

Luis Meira-Machado, Javier Roca-Pardinas and Artur Araújo

References

Meira-Machado L., Roca-Pardinas J. (2011). p3state.msm: Analyzing Survival Data from an Illness-Death Model. Journal of Statistical Software, 38(3), 1-18. doi:10.18637/jss.v038.i03

See Also

p3state

Examples

data(heart2)
res.p3state<-p3state(heart2)
pLIDA(res.p3state,time1=30,time2=300)

Plot method for p3state objects

Description

Produces various plots related to the p3state model, including transition probabilities, marginal distributions, and bivariate distribution functions.

Usage

## S3 method for class 'p3state'
plot(
  x,
  plot.trans = NULL,
  plot.marginal = NULL,
  plot.bivariate = NULL,
  time1,
  time2,
  xlab,
  ylab,
  zlab,
  col,
  col.biv = NULL,
  ...
)

Arguments

x

An object of class p3state.

plot.trans

Character or logical; specifies which transition probabilities to plot. Options include "P11", "P12", "P22", "P23", or "all". Defaults to NULL (no plot).

plot.marginal

Logical; whether to plot marginal distributions. Defaults to NULL.

plot.bivariate

Logical; whether to plot the bivariate distribution function. Defaults to NULL.

time1

Numeric; start time for the plot. Defaults to 0 if missing.

time2

Numeric; end time for the plot. Defaults to the maximum observed time.

xlab

Character; label for the x-axis. Defaults to "Time" if missing.

ylab

Character; label for the y-axis. Optional.

zlab

Character; label for the z-axis in 3D plots. Optional.

col

Color(s) used for plots. Optional.

col.biv

Color specification for bivariate contour plots. Optional.

...

Additional graphical parameters passed to plotting functions.

Value

Invisibly returns NULL. Plots are drawn as side effects.

Examples

## Not run: 
# Suponha que 'fit' é um objeto p3state ajustado
plot(fit, plot.trans = "P11")
plot(fit, plot.marginal = TRUE)
plot(fit, plot.bivariate = TRUE)

## End(Not run)


Summary Methods for an p3state Object

Description

Provides results for an object of class ‘p3state’. It gives the estimated transition probabilities, bivariate distribution of the gap times and marginal distribution of the second gap time (the last two only available for the progressive three-state model). Also provides the results for the fit of semi-parametric Cox regression models.

Usage

## S3 method for class 'p3state'
summary(object, model = NULL, covmat = NULL,
estimate = NULL, time1 = NULL, time2 = NULL, ...)

Arguments

object

An object of class ‘p3state’.

model

A character string specifying which model(s) to fit. Possible values are "TDCM", "CMM" and "CSMM". If NULL none of the regression models will be implemented.

covmat

Return the variance-covariance matrices? By default covmat=FALSE.

estimate

If TRUE nonparametric estimates are given. These include: transition probabilities, bivariate distribution function and marginal distribution of the second time (the last two only for the progressive three-state model).

time1

The first time for obtaining estimates of the transition probabilities, bivariate distribution function. NULL is equivalent to 0.

time2

The second time for obtaining estimates of the bivariate distribution function.

...

Further arguments for summary.

Value

No value is returned.

Author(s)

Luis Meira-Machado, Javier Roca-Pardinas and Artur Araújo

References

Meira-Machado L., Roca-Pardinas J. (2011). p3state.msm: Analyzing Survival Data from an Illness-Death Model. Journal of Statistical Software, 38(3), 1-18. doi:10.18637/jss.v038.i03

See Also

p3state

Examples

data(heart2)
res.p3state<-p3state(heart2, formula=~age+year)
summary(res.p3state,model="CMM",time1=20,time2=100)