Learn R Programming

TPmsm (version 1.1.0)

plot.TPCmsm: plot method for a TPCmsm object

Description

plot method for an object of class 'TPCmsm'. It draws the estimated transition probabilities in a basic scatterplot.

Usage

## S3 method for class 'TPCmsm':
plot(x, plot.type="t", tr.choice, xlab, ylab, col, lty, xlim, ylim,
conf.int=FALSE, ci.col, ci.lty, legend=TRUE, legend.pos, curvlab,
legend.bty="n", ...)

Arguments

x
An object of class 'TPCmsm'.
plot.type
A character string specifying the type of plot. If 't' the scatterplot of transition probability versus time is plotted. If 'c' the scatterplot of transition probability versus covariate is plotted.
tr.choice
Character vector of the form 'c("from to", "from to")' specifying which transitions should be plotted. Default, all the transition probabilities are plotted.
xlab
x-axis label.
ylab
y-axis label.
col
Vector of colour.
lty
Vector of line type. Default is 1:number of transitions.
xlim
Limits of x-axis for the plot.
ylim
Limits of y-axis for the plot.
conf.int
Logical. Whether to display pointwise confidence bands. Default is FALSE.
ci.col
Colour of the confidence bands. Default is col.
ci.lty
Line type of the confidence bands. Default is 3.
legend
A logical specifying if a legend should be added.
legend.pos
A vector giving the legend's position. See legend for further details.
curvlab
A character or expression vector to appear in the legend. Default is the name of the transitions.
legend.bty
Box type for the legend. By default no box is drawn.
...
Further arguments for plot.

Value

  • No value is returned.

encoding

UTF-8

References

Meira-Machado L., de Uña-Álvarez J. and Datta S. Conditional Transition Probabilities in a non-Markov Illness-death Model. Discussion Papers in Statistics and Operation Research n 11/03, 2011. Department of Statistics and Operations Research, University of Vigo (ISSN: 1888-5756, Deposito Legal VG 1402 - 2007). This file can be downloaded from: http://webs.uvigo.es/depc05/reports/12_05.pdf

See Also

legend, plot.default.

Examples

Run this code
# set the number of threads
nth <- threadsTP(2)

# Create survTP object
data(heartTP)
heartTP_obj <- with( heartTP, survTP(time1, event1, Stime, event, age=age) )

# Compute IPCW conditional transition probabilities with confidence band
TPCmsm_obj <- transIPCW(heartTP_obj, s=57, t=310, x=c(0, 15), conf=TRUE, n.boot=100,
method.boot="percentile", method.est=2)

# Build time plots
tr.choice <- dimnames(TPCmsm_obj$est)[[3]]
par.orig <- par( c("mfrow", "cex") )
par( mfrow=c(2,3) )
for ( i in seq_len( length(tr.choice) ) ) {
	plot(TPCmsm_obj, plot.type="t", tr.choice=tr.choice[i], conf.int=TRUE, legend=TRUE, main=tr.choice[i],
	col=seq_len( length(TPCmsm_obj$x) ), lty=1, xlab="", ylab="", curvlab=c("Age = 0", "Age = 15"))
}
par(mfrow=c(1, 1), cex=1.2)
title(xlab="Time", ylab="Transition probability", line=3)
par(par.orig)

# Build covariate plots without colors and without confidence band
plot(TPCmsm_obj, plot.type="c", xlab="Age")

# Build covariate plots with colors and without confidence band
plot(TPCmsm_obj, plot.type="c", col=seq_len(5), lty=1, xlab="Age")

# Build covariate plots with confidence band
tr.choice <- dimnames(TPCmsm_obj$est)[[3]]
par.orig <- par( c("mfrow", "cex") )
par( mfrow=c(2,3) )
for ( i in seq_len( length(tr.choice) ) ) {
	plot(TPCmsm_obj, plot.type="c", tr.choice=tr.choice[i], conf.int=TRUE, legend=FALSE, main=tr.choice[i],
	xlab="", ylab="")
}
par(mfrow=c(1, 1), cex=1.2)
title( xlab="Age", ylab=paste("P(", TPCmsm_obj$s, ", ", TPCmsm_obj$t, "| Age)", sep=""), line=3)
par(par.orig)

# restore the number of threads
threadsTP(nth)

Run the code above in your browser using DataLab