# Show p-plot for significant test (the simulation
# has a power of > 88% to return a significant
# effect).
testdata <- rnorm(64, mean = 0.4, sd = 1)
ps <- matrix(data = NA, nrow = 60, ncol = 1)
for (itest in c(2:64)) {
ps[itest] <- t.test(testdata[1:itest])$p.value
}
xs <- c(1:64)
pplot.pvals(xs,ps)
# Show p-plot for non-significant test (simulation
# does not include a true effect).
testdata <- rnorm(64, mean = 0.0, sd = 1)
ps <- matrix(data = NA, nrow = 60, ncol = 1)
for (itest in c(2:64)) {
ps[itest] <- t.test(testdata[1:itest])$p.value
}
xs <- c(1:64)
pplot.pvals(xs,ps)
Run the code above in your browser using DataLab