Debian Codegraph @

man/plot.probtrans.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/plot.probtrans.R
3 \name{plot.probtrans}
4 \alias{plot.probtrans}
5 \title{Plot method for a probtrans object}
6 \usage{
7 \method{plot}{probtrans}(
8 x,
9 from = 1,
10 type = c("filled", "single", "separate", "stacked"),
11 ord,
12 cols,
13 xlab = "Time",
14 ylab = "Probability",
15 xlim,
16 ylim,
17 lwd,
18 lty,
19 cex,
20 legend,
21 legend.pos = "right",
22 bty = "n",
23 xaxs = "i",
24 yaxs = "i",
25 use.ggplot = FALSE,
26 conf.int = 0.95,
27 conf.type = c("log", "plain", "none"),
28 label,
29 ...
30 )
31 }
32 \arguments{
33 \item{x}{Object of class 'probtrans', containing estimated transition
34 probabilities}
35
36 \item{from}{The starting state from which the probabilities are used to plot}
37
38 \item{type}{One of \code{"stacked"} (default), \code{"filled"},
39 \code{"single"} or \code{"separate"}; in case of \code{"stacked"}, the
40 transition probabilities are stacked and the distance between two adjacent
41 curves indicates the probability, this is also true for \code{"filled"}, but
42 the space between adjacent curves are filled, in case of \code{"single"},
43 the probabilities are shown as different curves in a single plot, in case of
44 \code{"separate"}, separate plots are shown for the estimated transition
45 probabilities}
46
47 \item{ord}{A vector of length equal to the number of states, specifying the
48 order of plotting in case type=\code{"stacked"} or \code{"filled"}}
49
50 \item{cols}{A vector specifying colors for the different transitions;
51 default is a palette from green to red, when type=\code{"filled"} (reordered
52 according to \code{ord}, and 1 (black), otherwise}
53
54 \item{xlab}{A title for the x-axis; default is \code{"Time"}}
55
56 \item{ylab}{A title for the y-axis; default is \code{"Probability"}}
57
58 \item{xlim}{The x limits of the plot(s), default is range of time}
59
60 \item{ylim}{The y limits of the plot(s); if ylim is specified for
61 type="separate", then all plots use the same ylim for y limits}
62
63 \item{lwd}{The line width, see \code{\link{par}}; default is 1}
64
65 \item{lty}{The line type, see \code{\link{par}}; default is 1}
66
67 \item{cex}{Character size, used in text; only used when
68 type=\code{"stacked"} or \code{"filled"}}
69
70 \item{legend}{Character vector of length equal to the number of transitions,
71 to be used in a legend; if missing, numbers will be used; this and the
72 legend arguments following are ignored when type="separate"}
73
74 \item{legend.pos}{The position of the legend, see \code{\link{legend}};
75 default is \code{"topleft"}}
76
77 \item{bty}{The box type of the legend, see \code{\link{legend}}}
78
79 \item{xaxs}{See \code{\link{par}}, default is "i", for type=\code{"stacked"}}
80
81 \item{yaxs}{See \code{\link{par}}, default is "i", for type=\code{"stacked"}}
82
83 \item{use.ggplot}{Default FALSE, set TRUE for ggplot version of plot}
84
85 \item{conf.int}{Confidence level (\%) from 0-1 for probabilities,
86 default is 0.95 (95\% CI). Setting to 0 removes the CIs.}
87
88 \item{conf.type}{Type of confidence interval - either "log" or "plain" . See
89 function details for details.}
90
91 \item{label}{Only relevant for type = "filled" or "stacked", set to
92 "annotate" to have state labels on plot, or leave unspecified.}
93
94 \item{\dots}{Further arguments to plot}
95 }
96 \value{
97 No return value
98 }
99 \description{
100 Plot method for an object of class 'probtrans'. It plots the transition
101 probabilities as estimated by \code{\link{probtrans}}.
102 }
103 \details{
104 Regarding confidence intervals: let \eqn{p} denote a predicted probability,
105 \eqn{\sigma} its estimated standard error,
106 and \eqn{z_{\alpha/2}} denote the critical value of the standard normal
107 distribution at confidence level \eqn{1 - \alpha}.
108
109 The confidence interval of type "plain" is then
110 \deqn{p \pm z_{\alpha/2} * \sigma}
111
112 The confidence interval of type "log", based on the Delta method, is then
113 \deqn{\exp(\log(p) \pm z_{\alpha/2} * \sigma / p)}
114 }
115 \examples{
116
117 # transition matrix for illness-death model
118 tmat <- trans.illdeath()
119 # data in wide format, for transition 1 this is dataset E1 of
120 # Therneau and Grambsch (2000)
121 tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1),
122 dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1),
123 x1=c(1,1,1,0,0,0),x2=c(6:1))
124 # data in long format using msprep
125 tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"),
126 data=tg,keep=c("x1","x2"),trans=tmat)
127 # events
128 events(tglong)
129 table(tglong$status,tglong$to,tglong$from)
130 # expanded covariates
131 tglong <- expand.covs(tglong,c("x1","x2"))
132 # Cox model with different covariate
133 cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans),
134 data=tglong,method="breslow")
135 summary(cx)
136 # new data, to check whether results are the same for transition 1 as
137 # those in appendix E.1 of Therneau and Grambsch (2000)
138 newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3)
139 msf <- msfit(cx,newdata,trans=tmat)
140 # probtrans
141 pt <- probtrans(msf,predt=0)
142 # default plot
143 plot(pt,ord=c(2,3,1),lwd=2,cex=0.75)
144 # filled plot
145 plot(pt,type="filled",ord=c(2,3,1),lwd=2,cex=0.75)
146 # single plot
147 plot(pt,type="single",lwd=2,col=rep(1,3),lty=1:3,legend.pos=c(8,1))
148 # separate plots
149 par(mfrow=c(2,2))
150 plot(pt,type="sep",lwd=2)
151 par(mfrow=c(1,1))
152
153 # ggplot version - see vignette for details
154 library(ggplot2)
155 plot(pt, ord=c(2,3,1), use.ggplot = TRUE)
156
157 }
158 \seealso{
159 \code{\link{probtrans}}
160 }
161 \author{
162 Hein Putter \email{[email protected]}
163
164 Edouard F. Bonneville \email{[email protected]}
165 }
166 \keyword{hplot}