###############################################################################
#                                                                             #
#   Reproducible files to the paper 'Pitfalls of hypothesis tests             #
#   and model selection on bootstrap samples: causes and consequences in      #
#   biometrical applications'  (2014)                                         #
#   by Janitza, Binder and Boulesteix                                         #
#                                                                             #
#   Contact: S. Janitza <janitza@ibe.med.uni-muenchen.de>                     #
#                                                                             #
#   File for reproducing Figure 6 (Part 2)                                    #
#                                                                             #
###############################################################################


# uncomment the following line and set the working directory where the R objects are stored
# setwd("...") 


# create Figure 6: setting with weak effects (save e.g. as pdf of size 6x3.5)

# load relevant R objects
load("CV_setting_uncor_weak_p200.Rda")
load("CV_setting_uncor_weak_p1000.Rda")
load("CV_setting_uncor_weak_p5000.Rda")

par(mfrow = c(1, 3), mar = c(9, 4, 2, 0.1), oma = c(0, 0, 0, 0), cex.lab = 1, cex.axis = 1)

lablist <- c("original", "bootstrap (overlap)", "bootstrap (no overlap)", "subsample")

boxplot(CV_setting_uncor_weak_p200, xaxt = "n", ylab = "Optimal number of boosting steps", main = "p = 200", ylim = c(0, 700))
axis(1, at = seq(1, 4, by=1), labels = FALSE)
text(seq(0.2, 3.2, by = 1), -225, labels = lablist, srt = 45, pos = 1, xpd = TRUE, cex = 0.9)

boxplot(CV_setting_uncor_weak_p1000, xaxt = "n", ylab = "", main = "p = 1000", ylim = c(0, 700))
axis(1, at = seq(1, 4, by=1), labels = FALSE)
text(seq(0.2, 3.2, by = 1), -225, labels = lablist, srt = 45, pos = 1, xpd = TRUE, cex = 0.9)

boxplot(CV_setting_uncor_weak_p5000, xaxt = "n", ylab = "", main = "p = 5000", ylim = c(0, 700))
axis(1, at = seq(1, 4, by=1), labels = FALSE)
text(seq(0.2, 3.2, by = 1), -225, labels = lablist, srt = 45, pos = 1, xpd = TRUE, cex = 0.9)



# setting with medium effects (not shown in the paper)

# load relevant R objects
load("CV_setting_uncor_medium_p200.Rda")
load("CV_setting_uncor_medium_p1000.Rda")
load("CV_setting_uncor_medium_p5000.Rda")

par(mfrow = c(1, 3), mar = c(9, 4, 2, 0.1), oma = c(0, 0, 0, 0), cex.lab = 1, cex.axis = 1)

lablist <- c("original", "bootstrap (overlap)", "bootstrap (no overlap)", "subsample")

boxplot(CV_setting_uncor_medium_p200, xaxt = "n", ylab = "Optimal number of boosting steps", main = "p = 200", ylim = c(0, 700))
axis(1, at = seq(1, 4, by=1), labels = FALSE)
text(seq(0.2, 3.2, by = 1), -225, labels = lablist, srt = 45, pos = 1, xpd = TRUE, cex = 0.9)

boxplot(CV_setting_uncor_medium_p1000, xaxt = "n", ylab = "", main = "p = 1000", ylim = c(0, 700))
axis(1, at = seq(1, 4, by=1), labels = FALSE)
text(seq(0.2, 3.2, by = 1), -225, labels = lablist, srt = 45, pos = 1, xpd = TRUE, cex = 0.9)

boxplot(CV_setting_uncor_medium_p5000, xaxt = "n", ylab = "", main = "p = 5000", ylim = c(0, 700))
axis(1, at = seq(1, 4, by=1), labels = FALSE)
text(seq(0.2, 3.2, by = 1), -225, labels = lablist, srt = 45, pos = 1, xpd = TRUE, cex = 0.9)

