library(scales)
library(ggplot2)

## sample size
n1 <- 8
n2 <- 16
n3 <- 32
n4 <- 64

## iterations m <- 500
yfig <- vector()
xfig <- vector()
facetfig <- data.frame()

bda1 = data.frame(matrix(rnorm(400), nrow=100))

for (j in c(n1, n2, n3, n4)) {
for (i in 1:m) {
bda2 = bda1[sample(nrow(bda1), j), ]
pa <- oneway.test(values ~ ind, stack(bda2))$p.value
xfig[i] <- pa
bda3 <- subset(bda2, select = – X1)
bda3$colMax <- apply(bda3, 1, function(x) max(x))
bda3$X1 <- bda2$X1
pt <- t.test(bda3$X1, bda3$colMax, paired=TRUE)$p.value
yfig[i] <- pt
}
facetfig <- rbind(facetfig,cbind.data.frame(N=rep(j, m), xfig, yfig))
}
p <- ggplot (facetfig, aes(x=xfig, y=yfig)) + geom_point(shape=16, size=4)
p + facet_grid(. ~ N, labeller = label_both) +
theme(strip.text = element_text(face = “bold”, size = 24), strip.background = element_rect(fill = “lightblue”)) +
annotate(“rect”, ymin = 0, ymax = 0.05, xmin = 0.05, xmax = 1, alpha=.1, fill=”blue”) +
scale_x_log10(labels=trans_format(“log10”, math_format(10^.x))) +
scale_y_log10(labels=trans_format(“log10”, math_format(10^.x))) +
geom_hline(yintercept = .05) + geom_vline(xintercept = .05) +
labs(y=”p value for best-dose t-test”, x=”p value for all-dose ANOVA”) +
theme(axis.title = element_text(size = 24),
axis.line = element_line(colour = “black”), panel.grid.minor = element_blank(),
panel.grid.major = element_blank(), axis.text = element_text(size = 20))