plot.gsbMainOut {gsbDesign} | R Documentation |
Plot methods
Description
Methods for plotting the results of gsb()
.
Usage
## S3 method for class 'gsbMainOut'
plot(x,
what=c("all", "cumulative all",
"both", "cumulative both",
"sample size", "success", "futility",
"success or futility", "indeterminate", "cumulative success",
"cumulative futility", "cumulative success or futility",
"cumulative indeterminate", "boundary",
"std.boundary","delta.grid","patients"),
range.delta = "default",
stages = "default",
delta.grid = TRUE,
color = TRUE,
smooth = 100,
contour = TRUE,
export = FALSE,
path = tempdir(),
sliced = FALSE,
range.control="default", ...)
## S3 method for class 'gsbSimulation'
plot(x,...)
## S3 method for class 'gsbDesign'
plot(x,...)
Arguments
x |
object of appropriate class. |
what |
a |
range.delta |
a |
stages |
a |
delta.grid |
|
color |
|
smooth |
a |
contour |
|
export |
|
path |
|
sliced |
|
range.control |
a |
... |
further arguments passed to or from other methods. |
Value
Returns an object of class "trellis"
Author(s)
Florian Gerber <florian.gerber@math.uzh.ch>, Thomas Gsponer
References
uses the R-package 'lattice'.
See Also
Examples
## please see examples of function 'gsb'.
## --------------------------------------
## --------------------------------------
## alternative plots can be created for example
## with package 'ggplot2'.
des <- gsbDesign(nr.stages=2,
patients=10,
sigma=10,
criteria.success=c(0,0.8, 7, 0.5),
criteria.futility=c(2,0.8),
prior.difference="non-informative")
sim <- gsbSimulation(truth=c(-10,20,60),
type.update="treatment effect")
x <- gsb(des,sim)
## get data.frame with operating characteristics
datgraph <- x$OC
## prepare for plot
sub <- c("success", "futility", "success or futility")
datgraph2 <- subset(datgraph,datgraph$type %in% sub)
datgraph2$type <- as.factor(paste(datgraph2$type))
datgraph2$value[datgraph2$type=="cumulative success or futility"] <-
1-datgraph2$value[datgraph2$type=="cumulative success or futility"]
levels(datgraph2$type) <- c("1)cumulative futility" ,"3)cumulative success","2)indeterminate")
datgraph2$type=as.factor(paste(datgraph2$type))
levels(datgraph2$type) <- c("cumulative futility" ,"indeterminate","cumulative success")
datgraph2 <- datgraph2[order(datgraph2$delta),]
## plots
library(ggplot2)
p1 <- qplot(delta,value,geom="blank",color=type,facets=.~stage,data=datgraph2,
xlab=expression(delta))
p1+geom_line(size=1.5)+scale_color_manual(values = c("cumulative futility" = "dark red",
"indeterminate" = "orange", "cumulative success" = "dark green"))
p2=p1+geom_area(aes(x = delta,y=value,fill=type))
p2+scale_fill_manual(values = c("cumulative futility" = "dark red",
"indeterminate" = "orange", "cumulative success" = "dark green"))