pplot.pvals {pplot} | R Documentation |
Generate p-plot from a series of p-values
Description
Takes a series of p-values and plots them against the corresponding number of observations included in a test. Adds reference lines at the chosen alpha level (horizontal line) and at the latest point in time the p-plot crosses the significance threshold (if any).
Usage
pplot.pvals(xs,
ps,
xtitle = "Observation",
alpha = 0.05,
n.sig = TRUE,
ylim.p = c(0,1),
pcol.alpha = 125)
Arguments
xs |
Vector of observations that the p values are computed on. |
ps |
vector of p-values. |
xtitle |
Axis title for the x-axis of the p-plot. |
alpha |
Significance threshold to be used for determining oversampling. |
n.sig |
Logical: Show vertical line at last crossing of the significance threshold? |
ylim.p |
Plot limits on the y-axis. |
pcol.alpha |
Transparency of the data points; set to 255 for solid fill. |
Details
pplot.pvals
generates a p-plot from two vectors: xs
containing the sample sizes underlying the test results, and ps
as the resulting p-values.
Value
pplot.pvals()
returns a single integer with the number of oversampled datasets (-1 for a non-significant test at the full sample size).
Author(s)
Roland Pfister
See Also
Examples
# 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)