1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/plot.Hist.R
3\name{plot.Hist}
4\alias{plot.Hist}
5\title{Box-arrow diagrams for multi-state models.}
6\usage{
7\method{plot}{Hist}(x, nrow, ncol, stateLabels, arrowLabels,
8  arrowLabelStyle = "symbolic", arrowLabelSymbol = "lambda",
9  changeArrowLabelSide, tagBoxes = FALSE, startCountZero = TRUE, oneFitsAll,
10  margin, cex, verbose = FALSE, ...)
11}
12\arguments{
13\item{x}{An object of class \code{Hist}.}
14
15\item{nrow}{the number of graphic rows}
16
17\item{ncol}{the number of graphic columns}
18
19\item{stateLabels}{Vector of names to appear in the boxes (states).
20Defaults to attr(x,"state.names").  The boxes can also be individually
21labeled by smart arguments of the form \code{box3.label="diseased"}, see
22examples.}
23
24\item{arrowLabels}{Vector of labels to appear in the boxes (states). One for
25each arrow.  The arrows can also be individually labeled by smart arguments
26of the form \code{arrow1.label=paste(expression(eta(s,u)))}, see examples.}
27
28\item{arrowLabelStyle}{Either "symbolic" for automated symbolic arrow
29labels, or "count" for arrow labels that reflect the number of transitions
30in the data.}
31
32\item{arrowLabelSymbol}{Symbol for automated symbolic arrow labels. Defaults
33to "lambda".}
34
35\item{changeArrowLabelSide}{A vector of mode logical (TRUE,FALSE) one for
36each arrow to change the side of the arrow on which the label is placed.}
37
38\item{tagBoxes}{Logical. If TRUE the boxes are numbered in the upper left
39corner. The size can be controlled with smart argument boxtags.cex. The
40default is boxtags.cex=1.28.}
41
42\item{startCountZero}{Control states numbers for symbolic arrow labels and
43box tags.}
44
45\item{oneFitsAll}{If \code{FALSE} then boxes have individual size, depending
46on the size of the label, otherwise all boxes have the same size dependent
47on the largest label.}
48
49\item{margin}{Set the figure margin via \code{par(mar=margin)}. Less than 4
50values are repeated.}
51
52\item{cex}{Initial cex value for the state and the arrow \code{labels}.}
53
54\item{verbose}{If TRUE echo various things.}
55
56\item{\dots}{Smart control of arguments for the subroutines text (box
57label), rect (box), arrows, text (arrow label). Thus the three dots can be
58used to draw individual boxes with individual labels, arrows and arrow
59labels. E.g. arrow2.label="any label" changes the label of the second arrow.
60See examples.}
61}
62\description{
63Automated plotting of the states and transitions that characterize a multi
64states model.
65}
66\note{
67Use the functionality of the unix program `dot'
68http://www.graphviz.org/About.php via R package Rgraphviz to obtain more
69complex graphs.
70}
71\examples{
72
73
74## A simple survival model
75
76SurvFrame <- data.frame(time=1:10,status=c(0,1,1,0,0,1,0,0,1,0))
77SurvHist <- with(SurvFrame,Hist(time,status))
78plot(SurvHist)
79plot(SurvHist,box2.col=2,box2.label="experienced\\nR user")
80plot(SurvHist,
81     box2.col=2,
82     box1.label="newby",
83     box2.label="experienced\\nR user",
84     oneFitsAll=FALSE,
85     arrow1.length=.5,
86     arrow1.label="",
87     arrow1.lwd=4)
88
89## change the cex of all box labels:
90plot(SurvHist,
91     box2.col=2,
92     box1.label="newby",
93     box2.label="experienced\\nR user",
94     oneFitsAll=FALSE,
95     arrow1.length=.5,
96     arrow1.label="",
97     arrow1.lwd=4,
98     label.cex=1)
99
100## change the cex of single box labels:
101plot(SurvHist,
102     box2.col=2,
103     box1.label="newby",
104     box2.label="experienced\\nR user",
105     oneFitsAll=FALSE,
106     arrow1.length=.5,
107     arrow1.label="",
108     arrow1.lwd=4,
109     label1.cex=1,
110     label2.cex=2)
111
112
113## The pbc data set from the survival package
114library(survival)
115data(pbc)
116plot(with(pbc,Hist(time,status)),
117     stateLabels=c("randomized","transplant","dead"),
118     arrowLabelStyle="count")
119
120## two competing risks
121comprisk.model <- data.frame(time=1:3,status=1:3)
122CRHist <- with(comprisk.model,Hist(time,status,cens.code=2))
123plot(CRHist)
124plot(CRHist,arrow1.label=paste(expression(eta(s,u))))
125
126plot(CRHist,box2.label="This\\nis\\nstate 2",arrow1.label=paste(expression(gamma[1](t))))
127plot(CRHist,box3.label="Any\\nLabel",arrow2.label="any\\nlabel")
128
129## change the layout
130plot(CRHist,
131     box1.label="Alive",
132     box2.label="Dead\\n cause 1",
133     box3.label="Dead\\n cause 2",
134     arrow1.label=paste(expression(gamma[1](t))),
135     arrow2.label=paste(expression(eta[2](t))),
136     box1.col=2,
137     box2.col=3,
138     box3.col=4,
139     nrow=2,
140     ncol=3,
141     box1.row=1,
142     box1.column=2,
143     box2.row=2,
144     box2.column=1,
145     box3.row=2,
146     box3.column=3)
147
148## more competing risks
149comprisk.model2 <- data.frame(time=1:4,status=1:4)
150CRHist2 <- with(comprisk.model2,Hist(time,status,cens.code=2))
151plot(CRHist2,box1.row=2)
152
153## illness-death models
154illness.death.frame <- data.frame(time=1:4,
155				  from=c("Disease\\nfree",
156                                      "Disease\\nfree",
157                                      "Diseased",
158                                      "Disease\\nfree"),
159				  to=c("0","Diseased","Dead","Dead"))
160IDHist <- with(illness.death.frame,Hist(time,event=list(from,to)))
161plot(IDHist)
162
163## illness-death with recovery
164illness.death.frame2 <- data.frame(time=1:5,
165from=c("Disease\\nfree","Disease\\nfree","Diseased","Diseased","Disease\\nfree"),
166to=c("0","Diseased","Disease\\nfree","Dead","Dead"))
167IDHist2 <- with(illness.death.frame2,Hist(time,event=list(from,to)))
168plot(IDHist2)
169
170## 4 state models
171x=data.frame(from=c(1,2,1,3,4),to=c(2,1,3,4,1),time=1:5)
172y=with(x,Hist(time=time,event=list(from=from,to=to)))
173plot(y)
174
175## moving the label of some arrows
176
177d <- data.frame(time=1:5,from=c(1,1,1,2,2),to=c(2,3,4,3,4))
178h <- with(d,Hist(time,event=list(from,to)))
179plot(h,
180tagBoxes=TRUE,
181stateLabels=c("Remission\\nwithout\\nGvHD",
182    "Remission\\nwith\\nGvHD",
183    "Relapse",
184    "Death\\nwithout\\nrelapse"),
185arrowLabelSymbol='alpha',
186arrowlabel3.x=35,
187arrowlabel3.y=53,
188arrowlabel4.y=54,
189arrowlabel4.x=68)
190
191##'
192}
193\author{
194Thomas A Gerds \email{tag@biostat.ku.dk}
195}
196\seealso{
197\code{\link{Hist}}\code{\link{SmartControl}}
198}
199\keyword{survival}
200
201