| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/plot.msfit.R |
| 3 |
\name{plot.msfit} |
| 4 |
\alias{plot.msfit} |
| 5 |
\title{Plot method for an msfit object} |
| 6 |
\usage{ |
| 7 |
\method{plot}{msfit}( |
| 8 |
x, |
| 9 |
type = c("single", "separate"), |
| 10 |
cols, |
| 11 |
xlab = "Time", |
| 12 |
ylab = "Cumulative hazard", |
| 13 |
ylim, |
| 14 |
lwd, |
| 15 |
lty, |
| 16 |
legend, |
| 17 |
legend.pos = "right", |
| 18 |
bty = "n", |
| 19 |
use.ggplot = FALSE, |
| 20 |
xlim, |
| 21 |
scale_type = "fixed", |
| 22 |
conf.int = 0.95, |
| 23 |
conf.type = "none", |
| 24 |
... |
| 25 |
) |
| 26 |
} |
| 27 |
\arguments{ |
| 28 |
\item{x}{Object of class \code{"msfit"}, containing estimated cumulative transition |
| 29 |
intensities for all transitions in a multi-state model} |
| 30 |
|
| 31 |
\item{type}{One of \code{"single"} (default) or \code{"separate"}; in case |
| 32 |
of \code{"single"}, all estimated cumulative hazards are drawn in a single |
| 33 |
plot, in case of \code{"separate"}, separate plots are shown for the |
| 34 |
estimated transition intensities} |
| 35 |
|
| 36 |
\item{cols}{A vector specifying colors for the different transitions; |
| 37 |
default is 1:K (K no of transitions), when type=\code{"single"}, and 1 |
| 38 |
(black), when type=\code{"separate"}} |
| 39 |
|
| 40 |
\item{xlab}{A title for the x-axis; default is \code{"Time"}} |
| 41 |
|
| 42 |
\item{ylab}{A title for the y-axis; default is \code{"Cumulative hazard"}} |
| 43 |
|
| 44 |
\item{ylim}{The y limits of the plot(s); if ylim is specified for |
| 45 |
type="separate", then all plots use the same ylim for y limits} |
| 46 |
|
| 47 |
\item{lwd}{The line width, see \code{\link{par}}; default is 1} |
| 48 |
|
| 49 |
\item{lty}{The line type, see \code{\link{par}}; default is 1} |
| 50 |
|
| 51 |
\item{legend}{Character vector of length equal to the number of transitions, |
| 52 |
to be used in a legend; if missing, these will be taken from the row- and |
| 53 |
column-names of the transition matrix contained in \code{x$trans}. Also used |
| 54 |
as titles of plots for type=\code{"separate"}} |
| 55 |
|
| 56 |
\item{legend.pos}{The position of the legend, see \code{\link{legend}}; |
| 57 |
default is \code{"topleft"}} |
| 58 |
|
| 59 |
\item{bty}{The box type of the legend, see \code{\link{legend}}} |
| 60 |
|
| 61 |
\item{use.ggplot}{Default FALSE, set TRUE for ggplot version of plot} |
| 62 |
|
| 63 |
\item{xlim}{Limits of x axis, relevant if use_ggplot = T} |
| 64 |
|
| 65 |
\item{scale_type}{"fixed", "free", "free_x" or "free_y", see scales argument |
| 66 |
of facet_wrap(). Only relevant for use_ggplot = T.} |
| 67 |
|
| 68 |
\item{conf.int}{Confidence level (\%) from 0-1 for the cumulative hazard, |
| 69 |
default is 0.95. Only relevant for use_ggplot = T} |
| 70 |
|
| 71 |
\item{conf.type}{Type of confidence interval - either "log" or "plain" . See |
| 72 |
function details of \code{plot.probtrans} for details} |
| 73 |
|
| 74 |
\item{\dots}{Further arguments to plot} |
| 75 |
} |
| 76 |
\value{ |
| 77 |
No return value |
| 78 |
} |
| 79 |
\description{ |
| 80 |
Plot method for an object of class \code{"msfit"}. It plots the estimated |
| 81 |
cumulative transition intensities in the multi-state model. |
| 82 |
} |
| 83 |
\examples{ |
| 84 |
|
| 85 |
# transition matrix for illness-death model |
| 86 |
tmat <- trans.illdeath() |
| 87 |
# data in wide format, for transition 1 this is dataset E1 of |
| 88 |
# Therneau & Grambsch (2000) |
| 89 |
tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), |
| 90 |
dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), |
| 91 |
x1=c(1,1,1,0,0,0),x2=c(6:1)) |
| 92 |
# data in long format using msprep |
| 93 |
tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), |
| 94 |
data=tg,keep=c("x1","x2"),trans=tmat) |
| 95 |
# events |
| 96 |
events(tglong) |
| 97 |
table(tglong$status,tglong$to,tglong$from) |
| 98 |
# expanded covariates |
| 99 |
tglong <- expand.covs(tglong,c("x1","x2")) |
| 100 |
# Cox model with different covariate |
| 101 |
cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans), |
| 102 |
data=tglong,method="breslow") |
| 103 |
summary(cx) |
| 104 |
# new data, to check whether results are the same for transition 1 as |
| 105 |
# those in appendix E.1 of Therneau & Grambsch (2000) |
| 106 |
newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3) |
| 107 |
msf <- msfit(cx,newdata,trans=tmat) |
| 108 |
# standard plot |
| 109 |
plot(msf) |
| 110 |
# specifying line width, color, and legend |
| 111 |
plot(msf,lwd=2,col=c("darkgreen","darkblue","darkred"),legend=c("1->2","1->3","2->3")) |
| 112 |
# separate plots |
| 113 |
par(mfrow=c(2,2)) |
| 114 |
plot(msf,type="separate",lwd=2) |
| 115 |
par(mfrow=c(1,1)) |
| 116 |
|
| 117 |
# ggplot version - see vignette for details |
| 118 |
library(ggplot2) |
| 119 |
plot(msf, use.ggplot = TRUE) |
| 120 |
|
| 121 |
} |
| 122 |
\seealso{ |
| 123 |
\code{\link{msfit}} |
| 124 |
} |
| 125 |
\author{ |
| 126 |
Hein Putter \email{[email protected]} |
| 127 |
|
| 128 |
Edouard F. Bonneville \email{[email protected]} |
| 129 |
} |
| 130 |
\keyword{hplot} |