msfit_generic {ebmstate}R Documentation

Compute subject-specific transition hazards.

Description

This function computes subject-specific or overall cumulative transition hazards for each of the possible transitions in the multi-state model. This help page is an adaptation of the mstate::msfit help page.

Usage

msfit_generic(object, ...)

## Default S3 method:
msfit_generic(
  object,
  newdata,
  variance = TRUE,
  vartype = c("aalen", "greenwood"),
  trans,
  ...
)

## S3 method for class 'coxrfx'
msfit_generic(object, newdata, trans, ...)

Arguments

object

An object describing the fit of a multi-state Cox model.

...

Further arguments

newdata

A data frame in ‘long format’. See details.

variance

A logical value indicating whether the (co-)variances of the subject-specific transition hazards should be computed.

vartype

A character string specifying the type of variances to be computed (so only needed if variance=TRUE).

trans

Transition matrix describing the states and transitions in the multi-state model. See trans in mstate::msprep for more detailed information.

Details

The purpose of msfit_generic is to be able to use mstate::msfit on model fit objects of class coxrfx (i.e. objects generated by CoxRFX). This can now be done with msfit_generic.coxrfx, which introduces minor modifications to mstate::msfit. In particular, it precludes msfit from computing the (co-)variances of transition hazard estimators, as this computation relies on asymptotic results for the fixed effects Cox model (see de Wreede et al, 2010, section 2.3.2). The method msfit_generic.default corresponds to the original mstate::msfit function. The data frame given as newdata input needs to have one row for each transition in the multi-state model, and one column for each covariate. An additional column strata (numeric) is needed to describe for each transition to which stratum it belongs. The name has to be strata, even if in the original coxph call another variable was used. See msfit for more details.

Value

An 'msfit' object. See mstate::msfit for details. If the S3 method msfit_generic.coxrfx is called, the returned object will be of class c(msfit,coxrfx); otherwise, it will be of class msfit.

Author(s)

Rui Costa, adapting the work of L. de Wreede, M. Fiocco and H. Putter in the mstate package.

References

de Wreede LC, Fiocco M, and Putter H (2010). The mstate package for estimation and prediction in non- and semi-parametric multi-state and competing risks models. Computer Methods and Programs in Biomedicine 99, 261–274.

See Also

mstate::msfit; mstate::msprep; mstate::plot.msfit.

Examples

# Compute cumulative hazard rates
# under a (pre-estimated) empirical Bayes Cox
# model.

#load simulated data (illness-death model,
#500 patients) and estimated empirical
# Bayes Cox model
data("mstate_data_sample")
data("coxrfx_object_sample")

# Make objects 'surv' and 'Z'
# with the data used in the estimation

#outcome data
surv<-coxrfx_object_sample$surv

#covariate data
Z<-coxrfx_object_sample$Z

# Build a data frame 'patient_data'
# with the covariate values for which 
# cumulative hazards are to be computed
# (patient 1 covariate values in this case).
# 'patient_data' must have one row for each
# transition in the model 
# and the same columns as 'Z'. The assignment
# of transitions to strata (made in the 'strata'
# column) must follow the original model in
# 'coxrfx_object_sample'.

patient_data<-mstate_data_sample[mstate_data_sample$id==1,
   ,drop=FALSE][rep(1,3),]
patient_data$strata<-patient_data$trans<-1:3
patient_data<-mstate::expand.covs(patient_data,
   covs=names(patient_data)[!names(patient_data)%in%
   c("id","from","to","trans","Tstart","Tstop","time",
   "to","trans","Tstart","Tstop","time","status",
   "strata")],append=TRUE)

# compute cumulative hazards
msfit_object<-msfit_generic(coxrfx_object_sample,
                            patient_data,
                            coxrfx_object_sample$tmat)

# show estimates
print(msfit_object)

[Package ebmstate version 0.1.4 Index]