@@ -86,22 +86,27 @@ plotBetaDiff <- function(parY, # parameters of experimental arm
86
86
upper = Stop_cut # Calculate probability of Stop, if difference was at most `Stop_cut`.
87
87
)
88
88
89
- Go_label <- paste(" Probability of Go is" , round(Go_auc $ value * 100 , digits = 2 ), " %" )
90
- Stop_label <- paste(" Probability of Stop is" , round(Stop_auc $ value * 100 , digits = 2 ), " %" )
91
- plot_title <- paste(" According to Beta difference density" , Go_label , " and" , Stop_label )
92
-
93
- pbetadiff_plot <- ggplot2 :: ggplot(data = data , mapping = aes(x = grid , y = density )) +
94
- ggplot2 :: geom_line(colour = " #888888" ) +
95
- xlab(" Difference between treatment" ) +
96
- ggplot2 :: ylab(quote(f(x ))) +
97
- ggplot2 :: ggtitle(plot_title )
89
+ Go_label <- paste(" probability of Go is" , round(Go_auc $ value * 100 , digits = 2 ), " %" )
90
+ Stop_label <- paste(" probability of Stop is" , round(Stop_auc $ value * 100 , digits = 2 ), " %" )
91
+ plot_title <- paste(" According to Beta difference density" , Go_label , " and\n " , Stop_label )
98
92
99
93
if (shade == TRUE ) {
100
- pbetadiff_plot <- pbetadiff_plot +
101
- ggplot2 :: geom_area(data = data [data $ Go == TRUE , ], fill = " #009E73" ) +
102
- ggplot2 :: geom_area(data = data [data $ Stop == TRUE , ], fill = " #D55E00" )
94
+ pbetadiff_plot <- ggplot2 :: ggplot(data = data , aes(x = grid , y = density )) +
95
+ ggplot2 :: geom_line(colour = " #888888" ) +
96
+ geom_area(data = data [data $ grid < Stop_cut ,], fill = " #D55E00" ,
97
+ mapping = aes(x = ifelse(grid < 0.2 & grid < 0.5 , grid , 0 ))) +
98
+ geom_area(data = data [data $ grid > Go_cut ,], fill = " #009E73" ,
99
+ mapping = aes(x = ifelse(grid > 0.3 , grid , 0 ))) +
100
+ xlab(" Difference between treatment" ) +
101
+ ggplot2 :: ylab(quote(f(x ))) +
102
+ ggplot2 :: ggtitle(plot_title )
103
+ } else {
104
+ pbetadiff_plot <- ggplot2 :: ggplot(data = data , aes(x = grid , y = density )) +
105
+ ggplot2 :: geom_line(colour = " #888888" ) +
106
+ xlab(" Difference between treatment" ) +
107
+ ggplot2 :: ylab(quote(f(x ))) +
108
+ ggplot2 :: ggtitle(plot_title )
103
109
}
104
-
105
110
if (note == TRUE ) {
106
111
pbetadiff_plot <- pbetadiff_plot +
107
112
ggplot2 :: annotate(" text" , x = - 0.5 , y = 4.25 , label = Go_label , colour = " #009E73" ) +
0 commit comments