plot.probtrans {mstate}R Documentation

Plot method for a probtrans object

Description

Plot method for an object of class 'probtrans'. It plots the transition probabilities as estimated by probtrans.

Usage

## S3 method for class 'probtrans':
plot(x,from=1,
    type=c("stacked","filled","single","separate"),ord,
    cols,xlab="Time",ylab="Probability",ylim,lwd,lty,cex,
    legend,legend.pos,bty="o",...)

Arguments

x Object of class 'probtrans', containing estimated transition probabilities
from The starting state from which the probabilities are used to plot
type One of "stacked" (default), "filled", "single" or "separate"; in case of "stacked", the transition probabilities are stacked and the distance between two adjacent curves indicates the probability, this is also true for "filled", but the space between adjacent curves are filled, in case of "single", the probabilities are shown as different curves in a single plot, in case of "separate", separate plots are shown for the estimated transition probabilities
ord A vector of length equal to the number of states, specifying the order of plotting in case type="stacked" or "filled"
cols A vector specifying colors for the different transitions; default is 1:K (K no of transitions), when type="single", and 1 (black), when type="separate"
xlab A title for the x-axis; default is "Time"
ylab A title for the y-axis; default is "Probability"
ylim The y limits of the plot(s); if ylim is specified for type="separate", then all plots use the same ylim for y limits
lwd The line width, see par; default is 1
lty The line type, see par; default is 1
cex
legend Character vector of length equal to the number of transitions, to be used in a legend; if missing, numbers will be used; this and the legend arguments following are ignored when type="separate"
legend.pos The position of the legend, see legend; default is "topleft"
bty The box type of the legend, see legend
... Further arguments to plot

Value

No return value

Author(s)

Hein Putter H.Putter@lumc.nl

See Also

probtrans

Examples

# transition matrix for illness-death model
tmat <- trans.illdeath()
# data in wide format, for transition 1 this is dataset E1 of
# Therneau & Grambsch (2000)
tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1),
        dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1),
        x1=c(1,1,1,0,0,0),x2=c(6:1))
# data in long format using msprep
tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"),
                data=tg,keep=c("x1","x2"),trans=tmat)
# events
events(tglong)
table(tglong$status,tglong$to,tglong$from)
# expanded covariates
tglong <- expand.covs(tglong,c("x1","x2"))
# Cox model with different covariate
cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans),
        data=tglong,method="breslow")
summary(cx)
# new data, to check whether results are the same for transition 1 as
# those in appendix E.1 of Therneau & Grambsch (2000)
newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3)
msf <- msfit(cx,newdata,trans=tmat)
# probtrans
pt <- probtrans(msf,predt=0)
# default plot
plot(pt,ord=c(2,3,1),lwd=2,cex=0.75)
# filled plot
plot(pt,type="filled",ord=c(2,3,1),lwd=2,cex=0.75)
# single plot
plot(pt,type="single",lwd=2,col=rep(1,3),lty=1:3,legend.pos=c(8,1))
# separate plots
par(mfrow=c(2,2))
plot(pt,type="sep",lwd=2)
par(mfrow=c(1,1))

[Package mstate version 0.2.3 Index]