## please see examples of function 'gsb'.
## --------------------------------------
## --------------------------------------
## alternative plots can be created for example
## with package 'ggplot2'.
# \donttest{
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"))
# }
Run the code above in your browser using DataLab