Description Matrix of transition probabilities for any time-
inhomogeneous multistate model with finite state space
Maintainer Arthur Allignol <[email protected]>
abortion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
clos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
etmprep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . fourD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lines.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phiPseudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . plot.clos.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
plot.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . plot.etmCIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . print.clos.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . print.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . print.etmCIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sir.cont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . summary.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . summary.etmCIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . tra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . trprob.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xyplot.etm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Pregnancies exposed to coumarin derivatives
Outcomes of pregnancies exposed to coumarin derivatives. The aim is to investigate whether ex-position to coumarin derivatives increases the probability of spontaneous abortions. Apart fromspontaneous abortion, pregnancy may end in induced abortion or live birth, leading to a competingrisks situation. Moreover, data are left-truncated as women usually enter the study several weeksafter conception.
A data frame with 1186 observations on the following 5 variables.
id Identification numberentry Entry times into the cohortexit Event timesgroup Group. 0: control, 1: exposed to coumarin derivativescause Cause of failure. 1: induced abortion, 2: life birth, 3: spontaneous abortion
Meiester, R. and Schaefer, C (2008). Statistical methods for estimating the probability of sponta-neous abortion in observational studies – Analyzing pregnancies exposed to coumarin derivatives. Reproductive Toxicology, 26, 31–35
The function estimates the expected change in length of stay (LOS) associated with an intermediateevent.
An object of class etm. Argument delta.na in must be set to TRUE in orderto use this function.
Logical. Whether to compute the expected change of LOS using alternativeweighting. Default is FALSE.
Logical. Compute the ratio of the expected length-of-stay given instermediateevent status instead of a difference. Default value is FALSE
The approach for evaluating the impact of an intermediate event on the expected change in lengthof stay is based on Schulgen and Schumacher (1996). They suggested to consider the difference ofthe expected subsequent stay given infectious status at time s.
Extensions to the methods of Schulgen and Schumacher and the earlier implementation in thechangeLOS include the possibility to compute the extra length of stay both for competing end-points and the more simple case of one absorbing state, as well as the possibility to compute thisquantity for left-truncated data.
An object of class clos.etm with the following components:
Estimates of E(LOS|Xs = intermediate event) for all observed transition timess, where Xsdenotes the state by time s
Estimates of E(LOS|Xs = initial state) for all observed transition times s.
Weighted average of the difference between phi2.case and phi2.control.
Estimates of E(LOS1(XLOS = discharge)|Xs = intermediate event), where
E(LOS1(XLOS = discharge)|Xs = initial state).
Weighted average of the difference between phi3.case and phi3.control.
Estimates of E(LOS1(XLOS = death)|Xs = intermediate event).
E(LOS1(XLOS = death)|Xs = initial state).
Weights used to compute the weighted averages.
Times at which the weights are computed.
Expected change in LOS using weights.other
Weights corresponding to the conditional waiting time in the intial state givenone experiences the intermediate event.
weights.other Weights corresponding to the conditional waiting time given one does not expe-
Arthur Allignol <[email protected]>, Matthias Wangler, Jan Beyersmann
G Schulgen and M Schumacher (1996). Estimation of prolongation of hospital stay attributable tonosocomial infections. Lifetime Data Analysis 2, 219-240.
J Beyersmann, P Gastmeier, H Grundmann, S Baerwolf, C Geffers, M Behnke, H Rueden, and MSchumacher (2006). Use of Multistate Models to Assess Prolongation of Intensive Care Unit StayDue to Nosocomial Infection. Infection Control and Hospital Epidemiology 27, 493-499.
Allignol A, Schumacher M, Beyersmann J: Estimating summary functionals in multistate modelswith an application to hospital infection data. Computation Stat, 2011; 26: 181-197.
M Wrangler, J Beyersmann and M Schumacher (2006). changeLOS: An R-package for change inlength of hospital stay based on the Aalen-Johansen estimator. R News 6(2), 31–35.
## putting los.data in the long format (see changeLOS)
my.observ <- prepare.los.data(x=los.data)
tr.prob <- etm(my.observ, c("0","1","2","3"), tra, NULL, 0)
## nboot: number of bootstrap samples. Other arguments are as in etm()
boot.clos <- function(data, state.names, tra, cens.name, s = 0, nboot) {
index <- sample(unique(data$id), replace = TRUE)
new.id <- c(new.id, rep(j, length(ind)))
dboot[, which(names(dboot) == "id")]
tr.prob <- etm(dboot, state.names, tra, cens.name, s, cova = FALSE)
se <- sqrt(var(boot.clos(my.observ, c("0","1","2","3"), tra, NULL, 0,
Pseudo Value Regression for the Extra Length-of-Stay
Pseudo Value Regression for the Extra Length-of-Stay
closPseudo(data, state.names, tra, cens.name, s = 0, formula,
data.frame of the form data.frame(id,from,to,time) or (id,from,to,entry,exit)
from: the state from where the transition occurs
to: the state to which a transition occurs
A vector of characters giving the states names.
A quadratic matrix of logical values describing the possible transitions withinthe multistate model.
A character giving the code for censored observations in the column ’to’ of data. If there is no censored observations in your data, put ’NULL’.
Starting value for computing the transition probabilities.
A formula with the covariates at the right of a ~ operator. Leave the left partempty.
Logical. Whether to compute the expected change of LOS using alternativeweighting. Default is FALSE.
Logical. Compute the ratio of the expected length-of-stay given instermediateevent status instead of a difference. Default value is FALSE
Number of cores used if doing parallel computation using the parallel package
The function calculates the pseudo-observations for the extra length-of-stay for each individual. These pseudo-observations can then be used to fit a direct regression model using generalized esti-mating equation (e.g., package geepack).
Computation of the pseudo-observations can be parallelised using the mclapply function of theparallel package. See argument ncores.
An object of class closPseudo with the following components:
a data.frame containing id, computed pseudo values (see details) and the co-variates as specified in the formula
Estimates of excess LoS in the whole sample
Arthur Allignol <[email protected]>
Andersen, P.K, Klein, J.P, Rosthoj, S. (2003). Generalised linear models for correlated pseudo-observations, with applications to multi-state models. Biometrika, 90(1):15–27.
my.icu.pneu <- my.icu.pneu[order(my.icu.pneu$id, my.icu.pneu$start), ]
my.icu.pneu$from[c(1, masque) == 0] <- 1
my.icu.pneu$to2[my.icu.pneu$status == 0] <- "cens"
my.icu.pneu$to2[c(masque, 1) == 0] <- 1
my.icu.pneu$to <- ifelse(my.icu.pneu$to2 %in% c(2, 3), 2,
my.icu.pneu <- my.icu.pneu[, c("id", "start", "stop", "from", "to",
"to2", "age", "sex")]
names(my.icu.pneu)[c(2, 3)] <- c("entry", "exit")
## computation of the pseudo-observations
ps.icu.pneu <- closPseudo(my.icu.pneu, c("0", "1", "2"), tra_ill(), "cens",
fit <- geeglm(ps.e.phi ~ sex + age, id = id, data = ps.icu.pneu$pseudoData,
Computation of the empirical transition matrix
This function computes the empirical transition matrix, also called Aalen-Johansen estimator, ofthe transition probability matrix of any multistate model. The covariance matrix is also computed.
etm(data, state.names, tra, cens.name, s, t = "last",
covariance = TRUE, delta.na = TRUE, modif = FALSE,
data.frame of the form data.frame(id,from,to,time) or (id,from,to,entry,exit)
from: the state from where the transition occurs
to: the state to which a transition occurs
This data.frame is transition-oriented, i.e. it contains one row per transition, andpossibly several rows per patient. Specifying an entry and exit time permits totake into account left-truncation.
A vector of characters giving the states names.
A quadratic matrix of logical values describing the possible transitions withinthe multistate model.
A character giving the code for censored observations in the column ’to’ of data. If there is no censored observations in your data, put ’NULL’.
Starting value for computing the transition probabilities.
Ending value. Default is "last", meaning that the transition probabilities arecomputed over (s, t], t being the last time in the data set.
Logical. Decide whether or not computing the covariance matrix. May be usefulfor, say, simulations, as the variance computation is a bit long. Default is TRUE.
Logical. Whether to export the array containing the increments of the Nelson-Aalen estimator. Default is TRUE.
Logical. Whether to apply the modification of Lai and Ying for small risk sets
Data are considered to arise from a time-inhomogeneous Markovian multistate model with finitestate space, and possibly subject to independent right-censoring and left-truncation.
The matrix of the transition probabilities is estimated by the Aalen-Johansen estimator / empiricaltransition matrix (Andersen et al., 1993), which is the product integral over the time period (s, t] ofI + the matrix of the increments of the Nelson-Aalen estimates of the cumulative transition hazards. The (i, j) − th entry of the empirical transition matrix estimates the transition probability of beingin state j at time t given that one has been in state j at time s.
The covariance matrix is computed using the recursion formula (4.4.19) in Anderson et al. (1993,p. 295). This estimator of the covariance matrix is an estimator of the Greenwood type.
If the multistate model is not Markov, but censorship is entirely random, the Aalen-Johansen esti-mator still consistently estimates the state occupation probabilities of being in state i at time t (Datta& Satten, 2001; Glidden, 2002)
Transition probability estimates. This is a 3 dimension array with the first di-mension being the state from where transitions occur, the second the state towhich transitions occur, and the last one being the event times.
Estimated covariance matrix. Each cell of the matrix gives the covariance be-tween the transition probabilities given by the rownames and the colnames, re-spectively.
Event times at which the transition probabilities are computed. That is all theobserved times between (s, t].
A data.frame giving the possible transitions.
A vector of character giving the state names.
How the censored observation are coded in the data set.
Matrix indicating the number of individuals at risk just before an event
Array containing the number of transitions at each times
A 3d array containing the increments of the Nelson-Aalen estimator.
When modif is true, risk set size for which the indicator function is 1
Transitions into a same state, mathematically superfluous, are not allowed. If transitions into thesame state are detected in the data, the function will stop. Equally, diag(tra) must be set toFALSE, see the example below.
Arthur Allignol, <[email protected]>
Beyersmann J, Allignol A, Schumacher M: Competing Risks and Multistate Models with R (UseR!), Springer Verlag, 2012 (Use R!)
Allignol, A., Schumacher, M. and Beyersmann, J. (2011). Empirical Transition Matrix of Multi-State Models: The etm Package. Journal of Statistical Software, 38.
Andersen, P.K., Borgan, O., Gill, R.D. and Keiding, N. (1993). Statistical models based on countingprocesses. Springer Series in Statistics. New York, NY: Springer.
Aalen, O. and Johansen, S. (1978). An empirical transition matrix for non-homogeneous Markovchains based on censored observations. Scandinavian Journal of Statistics, 5: 141-150.
Gill, R.D. and Johansen, S. (1990). A survey of product-integration with a view towards applicationin survival analysis. Annals of statistics, 18(4): 1501-1555.
Datta, S. and Satten G.A. (2001). Validity of the Aalen-Johansen estimators of stage occupationprobabilities and Nelson-Aalen estimators of integrated transition hazards for non-Markov models. Statistics and Probability Letters, 55(4): 403-411.
Glidden, D. (2002). Robust inference for event probabilities with non-Markov data. Biometrics, 58:361-368.
# Modification for patients entering and leaving a state
# Change on ventilation status is considered
sir.cont <- sir.cont[order(sir.cont$id, sir.cont$time), ]
if (sir.cont$time[i]==sir.cont$time[i-1]) {
sir.cont$time[i-1] <- sir.cont$time[i-1] - 0.5
### Computation of the transition probabilities
tr.prob <- etm(sir.cont, c("0", "1", "2"), tra, "cens", 1)
xyplot(tr.prob, tr.choice=c("0 0", "1 1", "0 1", "0 2", "1 0", "1 2"),
layout=c(2, 3), strip=strip.custom(bg="white",
c("0 to 0", "1 to 1", "0 to 1", "0 to 2", "1 to 0", "1 to 2")))
# Data set modification in order to be used by etm
names(abortion) <- c("id", "entry", "exit", "from", "to")
## computation of the matrix giving the possible transitions
tra <- matrix(FALSE, nrow = 5, ncol = 5)
fit <- etm(abortion, as.character(0:4), tra, NULL, s = 0)
xyplot(fit, tr.choice = c("0 0", "1 1", "0 4", "1 4"),
ci.fun = c("log-log", "log-log", "cloglog", "cloglog"),
strip = strip.custom(factor.levels = c("P(T > t) -- control",
"CIF spontaneous abortion -- control",
Cumulative incidence functions of competing risks
etmCIF is a wrapper around the etm function for facilitating the computation of the cumulativeincidence functions in the competing risks framework.
etmCIF(formula, data, etype, subset, na.action, failcode = 1)
A formula object, that must have a Surv object on the left of ~ operator, anda discrete covariate (or 1) on the right. The status indicator should be 1 (orTRUE) for an event (whatever the type of this event, 0 (or FALSE) for censoredobservations.)
A data.frame in which to interpret the terms of the formula
Competing risks event indicator. When the status indicator is 1 (or TRUE) in theformula, etype describes the type of event, otherwise, for censored observation,the value of etype is ignored
Expression saying that only a subset of the data should be used.
Missing-data filter function. Default is options()$na.action.
Indicates the failure type of interest. Default is one. This option is only relevantfor some options of the plot function.
This function computes the cumulative incidence functions in a competing risks setting using theetm machinery, without having to specify the matrix of possible transitions and using the more usualformula specification with Surv
Returns a list of etm objects (1 per covariate level) plus additional informations:
A matrix giving the name of the covariate (if present) and the levels of thiscovariate.
Arthur Allignol <[email protected]>
cif.ab <- etmCIF(Surv(entry, exit, cause != 0) ~ group, abortion,
plot(cif.ab, ci.type = "bars", pos.ci = 24,
col = c(1, 2), lty = 1, curvlab = c("Control", "Exposed"))
Data transformation function for using etm
The function transforms a data set in the wide format (i.e., one raw per subject) into the long format(i.e., one raw per transition, and possibly several raws per subjects) in a suitable way for using theetm function
etmprep(time, status, data, tra, state.names, cens.name = NULL,
A character vector giving the name of the columns containing the transitiontimes or last follow-up times. The length of time have to be equal to the numberof states, some elements may be NA. See Details.
A character vector giving the name of the columns indicating whether a statehas been visited (0 if not, 1 otherwise).
A data frame in which to look for the columns specified in time and status.
A quadratic matrix of logical values describing the possible transitions withinthe multistate model. The (i, j)th element of tra is TRUE if a transition fromstate i to state j is possible, FALSE otherwise. The diagonal must be set toFALSE.
A vector of characters giving the states names. If missing, state names are set tobe 0:(number of states).
A character string specifying how censored observations will be indicated in thenew data set. Default is NULL, i.e., no censored observation.
A list containing two elements, state and time, giving the starting states andtimes for all individuals. Default is NULL, in which case all individuals areconsidered to start in the initial state at time 0.
A character string specifying in which column of data the user ids are. Defaultis NULL, and the ids will be 1:n.
A character vector indicating the column names of the covariate one might wantto keep in the new data.frame.
This function only works for irreversible acyclic Markov processes. Therefore, the multistate modelwill have initial states, into which no transition are possible. For these, NAs are allowed in timeand status.
The function returns a data.frame suitable for using the etm function. The data frame contains thefollowing components:
Arthur Allignol, <[email protected]>
### creation of fake data in the wild format, following an illness-death model
## a covariate that we want to keep in the new data
newdat <- etmprep(c(NA, "tdisease", "tdeath"),
c(NA, "stat.disease", "stat.death"),
data = dat, tra = tra, cens.name = "cens")
Data from the placebo group of the 4D study. This study aimed at comparing atorvastatin to placebofor patients with type 2 diabetes and receiving hemodialysis in terms of cariovascular events. Theprimary endpoint was a composite of death from cardiac causes, stroke and non-fatal myocardialinfarction. Competing event was death from other causes.
A data frame with 636 observations on the following 7 variables.
id Patients’ id numbersex Patients’ genderage Patients’ agemedication Character vector indicating treatment affiliation. Here only equal to "Placebo"status Status at the end of the follow-up. 1 for the event of interest, 2 for death from other causes
time Survival timetreated Numeric vector indicated whether patients are treated or not. Here always equal to zero
Wanner, C., Krane, V., Maerz, W., Olschewski, M., Mann, J., Ruf, G., Ritz, E (2005). Atorvas-tatin in patients with type 2 diabetes mellitus undergoing hemodialysis. New England Journal ofMedicine, 353(3), 238–248.
Allignol, A., Schumacher, M., Wanner, C., Dreschler, C. and Beyersmann, J. (2010). Understandingcompeting risks: a simulation point of view. Research report.
conf.int = FALSE, level = 0.95, ci.fun = "linear",
character vector of the form c("from to","from to") specifying which tran-sitions should be plotted. By default, all the direct transition probabilities areplotted
Vector of colours. Default is black.
Vector of line type. Default is 1:number of transitions
Logical specifying whether to plot confidence intervals. Default is FALSE.
Level of the confidence interval. Default is 0.95.
Transformation applied to the confidence intervals. It could be different for alltransition probabilities, though if length(ci.fun) != number of transitions,only ci.fun[1] will be used. Possible choices are "linear", "log", "log-log" and"cloglog". Default is "linear".
Colours of the confidence intervals. Default value is the same as col.
Line types for the confidence intervals. Default is 3.
Arthur Allignol, <[email protected]>
Pseudo Value Regression for the Expected Excess Length of Stay
Pseudo value regression for the expected excess length of stay for each landmark time
phiPseudo(data, state.names, tra, cens.name, s = 0, formula, timepoints, ncores = 1)
A vector of characters giving the states names.
A quadratic matrix of logical values describing the possible transitions withinthe multistate model.
A character giving the code for censored observations in the column ’to’ of data. If there is no censored observations in your data, put NULL
Starting time for computing the transition probabilities.
A formula with the covariates at the right of a ~ operator. The left hand side canbe left empty.
Landmark time points at which the pseudo values are computed.
Number of cores used if doing parallel computation using the parallel package
The function calculates the pseudo-observations for the extra length-of-stay at several landmarktime points for each individual. These pseudo-observations can then be used to fit a direct regressionmodel using generalized estimating equation (e.g., package geepack).
Computation of the pseudo-observations can be parallelised using the mclapply function of theparallel package. See argument ncores.
An object of class phiPseudo with the following components:
a data.frame containing id, computed pseudo values (see details) and the co-variates as specified in the formula
Estimates of excess LoS in the whole sample
Arthur Allignol <[email protected]>
Andersen, P.K, Klein, J.P, Rosthoj, S. (2003). Generalised linear models for correlated pseudo-observations, with applications to multi-state models. Biometrika, 90(1):15–27.
Plot method for objects of class clos.etm.
plot(x, xlab = "Time", ylab.e = "Expected LOS",
ylab.w = "Weights", xlim, ylim.e, ylim.w, col.e = c(1, 2), col.w = 1,
lty.e = c(1, 1), lty.w = 1, legend = TRUE, legend.pos, curvlab,
Label for the y-axis in the plot of the expected LOS
Label for the y-axis in the plot of the weights
Limits of the y-axis for the expected LOS plot
Limits of the y-axis for the weights plot
Vector of colours for the plot of expected LOS
Vector of colours for the plot of the weights
Vector of line type for the plot of expected LOS
Vector of line type for the plot of the weights
Logical. Whether to draw a legend for the plot of expected LOS
A vector giving the legend’s position. See for details
Character or expression vector to appear in the legend. Default is c("Intermediate event by time t", "No
Two graphs are drawn. The lower graph displays the expected LOS for patients who have expe-rienced the intermediate event and for those who have not. The upper graph displays the weightsused to compute the weighted average.
Arthur Allignol <[email protected]>, Matthias Wangler
Plot method for an object of class ’etm’. It draws the estimated transition probabilities in a basicscatterplot.
plot(x, tr.choice, xlab = "Time",
ylab = "Transition Probability", col = 1, lty, xlim, ylim,
conf.int = FALSE, level = 0.95, ci.fun = "linear",
legend = TRUE, legend.pos, curvlab, legend.bty = "n", .)
character vector of the form ’c("from to","from to")’ specifying which transi-tions should be plotted. Default, all the transition probabilities are plotted
y-axis label. Default is "Transition Probability"
Vector of line type. Default is 1:number of transitions
Logical. Whether to display pointwise confidence intervals. Default is FALSE.
Level of the conficence intervals. Default is 0.95.
Transformation applied to the confidence intervals. It could be different for alltransition probabilities, though if length(ci.fun) != number of transitions,only ci.fun[1] will be used. Possible choices are "linear", "log", "log-log" and"cloglog". Default is "linear".
Colour of the confidence intervals. Default is col.
Line type of the confidence intervals. Default is 3.
A logical specifying if a legend should be added
A vector giving the legend’s position. See for further details
A character or expression vector to appear in the legend. Default is the name ofthe transitions
Arthur Allignol, <[email protected]>
# Modification for patients entering and leaving a state
sir.cont <- sir.cont[order(sir.cont$id, sir.cont$time), ]
if (sir.cont$time[i]==sir.cont$time[i-1]) {
sir.cont$time[i-1] <- sir.cont$time[i-1] - 0.5
my.etm <- etm(sir.cont,c("0","1","2"),tra,"cens", s = 0)
plot(my.etm, tr.choice = c("0 0"))
Plot function for etmCIF objects. The function plots cumulative incidence curves, possibly withpointwise confidence intervals.
ylab = "Cumulative Incidence", xlab = "Time", col = 1, lty, lwd = 1,
ci.type = c("none", "bars", "pointwise"), ci.fun = "cloglog",
ci.col = col, ci.lty = 3, legend = TRUE, legend.pos, curvlab,
legend.bty = "n", pos.ci = 27, ci.lwd = 3, .)
A numeric vector indicating which CIFs should be plotted. When missing, onlythe CIF of interest is plotted (determined through the failcode argument in
x-axis limits for the plot. By default, c(0, max(time))
Label for y-axis. Default is "Cumulative Incidence"
Label for x-axis. Default is "Time"
Vector describing colours used for the CIF curves. Default is black
"pointwise"). none plots no confidence
interval, bars plots the confidence intervals in the form of a segment for onetime point, and pointwise draws pointwise confidence intervals for the wholefollow-up period.
Transformation used for the confidence intervals. Default is "clolog", and is abetter choice for cumulative incidences. Other choices are "log" and "log-log"
Colour for the pointwise confidence interval curves. Default is same as the CIFcurves
Line type for the confidence intervals. Default is 3
Logical. Whether to draw a legend. Default is TRUE
A vector giving the legend’s position. See for further details
A character or expression vector to appear in the legend. Default is CIF + eventlabel
Box type for the legend. Default is none ("n")
If ci.type = "bars", vector of integers indicating at which time point to putthe confidence interval bars. Default is 27
Thickness of the confidence interval segment (for ci.type = "bars")
The function relies on plot.etm and lines.etm with more or less the same options. Exception isthe drawing of the confidence intervals, for which several displays are possible.
Arthur Allignol <[email protected]>
cif.ab <- etmCIF(Surv(entry, exit, cause != 0) ~ group, abortion,
plot(cif.ab, ci.type = "bars", pos.ci = 24,
col = c(1, 2), lty = 1, curvlab = c("Control", "Exposed"))
Print function for ’clos.etm’ objects
Print method for object of class clos.etm
Arthur Allignol, <[email protected]>
Print method for object of class ’etm’
Print method for objects of class etm.
print(x, covariance = TRUE, whole = TRUE, .)
Whether print the covariance matrix. Default is TRUE
Whether to plot the entire covariance matrix. If set to FALSE, rows and columnscontaining only 0 will be removed for printing.
Further arguments for print or summary.
The function prints a matrix giving the possible transitions, along with the estimates of P (s, t) andcov(P (s, t)).
Arthur Allignol, <[email protected]>
Arthur Allignol <[email protected]>
Ventilation status in intensive care unit patients
Time-dependent ventilation status for intensive care unit (ICU) patients, a random sample from theSIR-3 study.
A data frame with 1141 rows and 6 columns:
from: State from which a transition occurs
And cens stands for censored observations.
This data frame consists in a random sample of the SIR-3 cohort data. It focuses on the effect of ven-tilation on the length of stay (combined endpoint discharge/death). Ventilation status is consideredas a transcient state in an illness-death model.
The data frame is directly formated to be used with the etm function, i.e. it is transition-orientedwith one row per transition.
Beyersmann, J., Gastmeier, P., Grundmann, H., Baerwolff, S., Geffers, C., Behnke, M., Rueden, H.,and Schumacher, M. Use of multistate models to assess prolongation of intensive care unit stay dueto nosocomial infection. Infection Control and Hospital Epidemiology, 27:493-499, 2006.
ci.fun = "linear", level = 0.95, .)
If set to TRUE, a data.frame will be computed for all transitions that are not 0in the empirical transition matrix.
A character vector specifying the transformation to be applied to the pointwiseconfidence intervals. It could be different for each transition probability, thoughif length(ci.fun) !=
will be used. The function displays the transition probabilities in the followingorder: first the direct transitions in alphabetical order, e.g., 0 to 1, 0 to 2, 1 to 2,., then the state occupation probabilities in alphabetical order, e.g., 0 to 0, 1 to1, . The possible transformations are "linear", "log", "log-log" and "cloglog". Default is "linear".
Level of the two-sided confidence intervals. Default is 0.95.
A list of data.frames giving the transition probability and stage occupation probability estimates. List items are named after the possible transition.
Number of individuals at risk of experiencing a transition just before time t
Arthur Allignol <[email protected]>
Summary function for objects of class cifETM
summary(object, ci.fun = "cloglog",
Transformation applied to the pointwise confidence intervals. On of "linear", "log", "log-log",
Level of the confidence intervals. Default is 0.95.
A data.frame per covariate level and competing event
Number of individuals at risk of experiencing a transition just before time t
Arthur Allignol <[email protected]>
Miscellaneous functions that compute the matrix of possible transitions used as argument in the etmfunction.
tra_ill(state.names = c("0", "1", "2"))
state.names = as.character(seq(0, nComp + 1, 1)))
state.names = as.character(seq(0, nComp)))
tra_surv(state.names = c("0", "1"))
A vector of characters giving the states names
For the competing risks models, the number of competing events
These functions compute the matrix of possible transitions that is used as argument in, e.g., theetm function. tra_surv is for the usual survival model, tra_comp for the competing risks model,
tra_ill for the illness-death model and tra_ill_comp for the illness-death model with competingterminal events. By default, state names are from 0 to . . .
A quadratic matrix with TRUE if a transition is possible, FALSE otherwise.
Arthur Allignol <[email protected]>
## competing risks model with 4 competing events non-default state names
tra_comp(4, state.names = c("healthy", "Cardiac problems", "Cancer",
"Rhenal failure", "Other"))
Function to extract transition probabilities and (co)variance
The trprob method is used to extract transition probabilities, while trcov is used to obtain the(co)variance.
A character vector of the form "from to" describing for which transition onewishes to obtain the transition probabilities or covariance estimates. For trprob,
tr.choice must be of length 1, while it can be of length 2 for trcov.
Time points at which one want the estimates. When missing, estimates are ob-tained for all event times.
A vector containing the transition probabilities or covariance estimates either at the time specifiedin timepoints or at all transition times.
Arthur Allignol, <[email protected]>
# Modification for patients entering and leaving a state
# Change on ventilation status is considered
sir.cont <- sir.cont[order(sir.cont$id, sir.cont$time), ]
if (sir.cont$time[i]==sir.cont$time[i-1]) {
sir.cont$time[i-1] <- sir.cont$time[i-1] - 0.5
### Computation of the transition probabilities
fit.etm <- etm(sir.cont, c("0", "1", "2"), tra, "cens", 0)
var.p01 <- trcov(fit.etm, "0 1")
cov.00.01 <- trcov(fit.etm, c("0 0", "0 1"))
trprob(fit.etm, "0 1", c(0, 15, 50, 100))
xyplot method for object of class ’etm’
xyplot function for objects of class etm. Estimates of the transition probabilities are plotted as afunction of time for all the transitions specified by the user.
xyplot(x, data = NULL, tr.choice, col = c(1, 1, 1),
conf.int = TRUE, ci.fun = "linear", level = 0.95, .)
A character vector of the form c("from to", "from to", .) specifying the transi-tion probabilities to be plotted. By default, all the direct transition probabilitiesare displayed.
x-axis label. Default is "Time".
y-axis label. Default is "Estimated transition probability".
Logical. Whether to draw pointwise confidence intervals. Default is TRUE.
A character vector specifying the transformation to be applied to the pointwiseconfidence intervals. It could be different for each transition probability, thoughif length(ci.fun) !=
length(tr.choice), only ci.fun[1] will be
used. The possible transformations are "linear", "log", "log-log" and "cloglog". Default is "linear".
Level of the two-sided confidence intervals. Default is 0.95.
Arthur Allignol, <[email protected]>