| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/vis.multiple.pt.R |
| 3 |
\name{vis.multiple.pt} |
| 4 |
\alias{vis.multiple.pt} |
| 5 |
\title{Visualise multiple probtrans objects} |
| 6 |
\usage{ |
| 7 |
vis.multiple.pt( |
| 8 |
x, |
| 9 |
from = 1, |
| 10 |
to, |
| 11 |
xlab = "Time", |
| 12 |
ylab = "Probability", |
| 13 |
xlim = NULL, |
| 14 |
ylim = NULL, |
| 15 |
cols, |
| 16 |
lwd, |
| 17 |
labels, |
| 18 |
conf.int = 0.95, |
| 19 |
conf.type = c("log", "plain", "none"), |
| 20 |
legend.title |
| 21 |
) |
| 22 |
} |
| 23 |
\arguments{ |
| 24 |
\item{x}{A list of \code{"probtrans"} objects} |
| 25 |
|
| 26 |
\item{from}{The starting state from which the probabilities are used to plot |
| 27 |
Numeric, as in \code{plot.probtrans}} |
| 28 |
|
| 29 |
\item{to}{(Numeric) destination state} |
| 30 |
|
| 31 |
\item{xlab}{A title for the x-axis; default is \code{"Time"}} |
| 32 |
|
| 33 |
\item{ylab}{A title for the y-axis; default is \code{"Probability"}} |
| 34 |
|
| 35 |
\item{xlim}{The x limits of the plot(s), default is range of time} |
| 36 |
|
| 37 |
\item{ylim}{The y limits of the plot(s); if ylim is specified for |
| 38 |
type="separate", then all plots use the same ylim for y limits} |
| 39 |
|
| 40 |
\item{cols}{A vector specifying colors for the different transitions; |
| 41 |
default is a palette from green to red, when type=\code{"filled"} (reordered |
| 42 |
according to \code{ord}, and 1 (black), otherwise} |
| 43 |
|
| 44 |
\item{lwd}{The line width, see \code{\link{par}}; default is 1} |
| 45 |
|
| 46 |
\item{labels}{Character vector labelling each element of x (e.g. label |
| 47 |
for a reference patient) - so labels = c("Patient 1", "Patient 2")} |
| 48 |
|
| 49 |
\item{conf.int}{Confidence level (\%) from 0-1 for probabilities, |
| 50 |
default is 0.95 (95\% CI). Setting to 0 removes the CIs.} |
| 51 |
|
| 52 |
\item{conf.type}{Type of confidence interval - either "log" or "plain" . See |
| 53 |
function details for details.} |
| 54 |
|
| 55 |
\item{legend.title}{Character - title of legend} |
| 56 |
} |
| 57 |
\value{ |
| 58 |
A ggplot object. |
| 59 |
} |
| 60 |
\description{ |
| 61 |
Helper function allowing to visualise state probabilities for |
| 62 |
different reference patients/covariates. Multiple \code{"probtrans"} objects |
| 63 |
are thus needed. |
| 64 |
} |
| 65 |
\examples{ |
| 66 |
|
| 67 |
library(ggplot2) |
| 68 |
|
| 69 |
data("aidssi") |
| 70 |
head(aidssi) |
| 71 |
si <- aidssi |
| 72 |
|
| 73 |
# Prepare transition matrix |
| 74 |
tmat <- trans.comprisk(2, names = c("event-free", "AIDS", "SI")) |
| 75 |
|
| 76 |
# Run msprep |
| 77 |
si$stat1 <- as.numeric(si$status == 1) |
| 78 |
si$stat2 <- as.numeric(si$status == 2) |
| 79 |
|
| 80 |
silong <- msprep( |
| 81 |
time = c(NA, "time", "time"), |
| 82 |
status = c(NA, "stat1", "stat2"), |
| 83 |
data = si, keep = "ccr5", trans = tmat |
| 84 |
) |
| 85 |
|
| 86 |
# Run cox model |
| 87 |
silong <- expand.covs(silong, "ccr5") |
| 88 |
c1 <- coxph(Surv(time, status) ~ ccr5WM.1 + ccr5WM.2 + strata(trans), |
| 89 |
data = silong) |
| 90 |
|
| 91 |
# 1. Prepare patient data - both CCR5 genotypes |
| 92 |
WW <- data.frame( |
| 93 |
ccr5WM.1 = c(0, 0), |
| 94 |
ccr5WM.2 = c(0, 0), |
| 95 |
trans = c(1, 2), |
| 96 |
strata = c(1, 2) |
| 97 |
) |
| 98 |
|
| 99 |
WM <- data.frame( |
| 100 |
ccr5WM.1 = c(1, 0), |
| 101 |
ccr5WM.2 = c(0, 1), |
| 102 |
trans = c(1, 2), |
| 103 |
strata = c(1, 2) |
| 104 |
) |
| 105 |
|
| 106 |
# 2. Make msfit objects |
| 107 |
msf.WW <- msfit(c1, WW, trans = tmat) |
| 108 |
msf.WM <- msfit(c1, WM, trans = tmat) |
| 109 |
|
| 110 |
# 3. Make probtrans objects |
| 111 |
pt.WW <- probtrans(msf.WW, predt = 0) |
| 112 |
pt.WM <- probtrans(msf.WM, predt = 0) |
| 113 |
|
| 114 |
# Plot - see vignette for more details |
| 115 |
vis.multiple.pt( |
| 116 |
x = list(pt.WW, pt.WM), |
| 117 |
from = 1, |
| 118 |
to = 2, |
| 119 |
conf.type = "log", |
| 120 |
cols = c(1, 2), |
| 121 |
labels = c("Pat WW", "Pat WM"), |
| 122 |
legend.title = "Ref patients" |
| 123 |
) |
| 124 |
|
| 125 |
} |
| 126 |
\author{ |
| 127 |
Edouard F. Bonneville \email{[email protected]} |
| 128 |
} |