Learn R Programming

TreatmentSelection (version 2.1.1)

plot.trtsel: plot risk curves, treatment effect curves or cdf of risk for a trtsel object.

Description

Plots a treatment selection marker. Estimated "risk curves" and "treatment effect curves" are plotted. An object of class "trtsel" must first be created using the function "trtsel" by supplying a data.frame containing marker, treatment, and event status information.

Usage

# S3 method for trtsel
plot(x, bootstraps = 500, plot.type = c("treatment effect",
  "risk", "cdf", "selection impact"), ci = c("default", "horizontal",
  "vertical", "none"), alpha = 0.05, fixed.values = NULL, offset = 0.01,
  conf.bands = TRUE, conf.bandsN = 100, trt.names = c("Treatment",
  "    No \nTreatment"), xlab = NULL, ylab = NULL, xlim = NULL,
  ylim = NULL, main = NULL, show.marker.axis = TRUE, ...)

Arguments

x

An object of class "trtsel", created by using the function "trtsel."

bootstraps

Number of bootstrap replicates for creating confidence intervals and bands. Default value is 500. Set bootstraps=0 if no confidence intervals or bands are desired.

plot.type

Type of plot to produce. Options are "risk" (default) for risk curves which show risk of adverse event as a function of marker and treatment, "treatment effect" for the treatment effect curve which shows the difference in marker-specific risk of adverse event with vs. without treatment, "cdf" for the cumulative distribution function of the treatment effect, or "selection impact" to show a plot of the estimated event rate if different proportions of the population are treated. Cdf plots cannot be generated for a discrete marker.

ci

Indication of whether horizontal or vertical confidence intervals are desired. Character string of either "horizontal" (default) or "vertical." For a discrete marker only vertical confidence bands can be produced. See note below for more information.

alpha

(1-alpha)*100% confidence intervals are calculated. Default value is alpha = 0.05 which yields 95% CI's.

fixed.values

A numeric vector indicating fixed values on the x- or y-axes at which bootstrap confidence intervals are provided. If "fixed.values" are provided, point-wise confidence intervals will be printed (i.e. conf.bands will be taken as FALSE). Only applies to a continuous marker.

offset

If confidence intervals are to be plotted for specified fixed.values, offset is the amount of distance to offset confidence intervals so that they do not overlap on the plot. The default value is 0.01. Only applies to a continuous marker.

conf.bands

Indication of whether pointwise confidence intervals are shown for the curve(s). TRUE (default) or FALSE. If "fixed.values" are input, this option is ignored and no confidence bands are produced.

conf.bandsN

If conf.bands = TRUE, the number of points along the x- or y-axis at which to calculate the pointwise confidence intervals. The default is 100.

trt.names

A vector of length 2 indicating the names for the two treatment options, T= 1 and T = 0, respectively, for the plot legend. This option is only used when plot.type="risk". The default value is c("Treatment", "No Treatment").

xlab

A label for the x-axis. Default values depend on plot.type.

ylab

A label for the y-axis. Default values depend on plot.type.

xlim

The limits for the x-axisof the plot, in the form c(x1,x2)

ylim

The limits for the y-axis of the plot, in the form c(y1,y2)

main

The main title for the plot.

show.marker.axis

For risk curve plots with a continuous marker, should an axis showing marker values be displayed? default is TRUE.

N/A

Value

Generates a plot. In addition, if the function call is assigned to a variable (as in "myplot <- plot(mytrtsel)"), plot.trtsel returns a list composed of:

plot

ggplot object containing the printed plot.

ci.bounds

A data.frame containing the bounds of the bootstrap-based confidence intervals, along with the fixed.values they are centered around, if applicable.

See Also

trtsel for creating trtsel objects, evaluate.trtsel for evaluating marker performance, calibrate.trtsel for assessing model calibration, and compare.trtsel to compare two trtsel object.

Examples

Run this code
# NOT RUN {

data(tsdata)

###########################
## Create trtsel objects 
###########################

trtsel.Y1 <- trtsel(event ~ Y1*trt, 
                   treatment.name = "trt", 
                   data = tsdata, 
                   study.design = "RCT",
                   default.trt = "trt all")




##########################
## Use the plot function 
##########################

# Plot risk curves
plot(trtsel.Y1, main = "Marker Y1", 
     plot.type = "risk", bootstraps = 10, #set higher in practice
     trt.names=c("trt","no trt"))
     
# Now with confidence intervals around fixed.values 
 plot(trtsel.Y1, main = "Marker Y1",
                        plot.type = "risk", ci = "horizontal", 
                        fixed.values = c(.2, .5), 
                        offset = .01, bootstraps = 10,
                        trt.names=c("trt","no trt"))
                        
# Plot treatment effect curves
#with confidence intervals around fixed.values
plot(trtsel.Y1, main = "Marker Y1", 
                       plot.type = "treatment effect",
                       ci = "vertical", conf.bands = FALSE,
                       fixed.values = c(10, 20), bootstraps = 10)

# }

Run the code above in your browser using DataLab