Provides interactive three-dimensional visualization of
p-value surfaces for single-sample t-tests. Enables simultaneous
exploration of effect size, sample size, and significance level,
making the continuous nature of p-values and the moderating effect
of sample size visually apparent. Includes both interactive ('rgl',
'plotly') and static (persp()) rendering options. The p-value
surface is based on the approach of Infanger and Schmidt-Trucksäss
(2019)

p3d is an R package for computing and visualizing the three-dimensional p-value surface of a single-sample t-test. The p-value is expressed as a function of both effect size (Cohen's d) and sample size (n).
Traditional p-value visualizations are two-dimensional and show the effect of only one parameter at a time. p3d visualizes the p-value simultaneously across effect size and sample size. It addresses questions such as:
# From CRAN (coming soon)
install.packages("p3d")
# Development version from GitHub
# install.packages("remotes")
remotes::install_github("ahmetkutuk1/p3d")
library(p3d)
# Compute a 3D p-value surface
surface <- p_surface(d = seq(-2, 2, 0.1), n = seq(5, 200, 5))
# Interactive 3D visualization (plotly engine)
plot_p_surface(surface, engine = "plotly")
# Static 3D perspective (base R)
plot_p_static(surface)
# 2D p-value curve (for comparison)
curve_30 <- p_curve_2d(d = seq(-2, 2, 0.1), n = 30)
head(curve_30)
| Function | Purpose |
|---|---|
p_surface(d, n, alpha) |
Compute the 3D p-value surface |
p_curve_2d(d, n, alpha) |
Compute a 2D p-value curve (fixed n) |
plot_p_surface(surface, engine) |
Interactive 3D visualization (rgl / plotly) |
plot_p_static(surface) |
Static 3D perspective (base R) |
For a single-sample t-test, the p-value is:
$$p(d, n) = 2 \left[ 1 - F_{t(n-1)}(d \sqrt{n}) \right]$$
where $F_{t(n-1)}$ is the cumulative distribution function of the t-distribution with $n-1$ degrees of freedom.
The critical effect size at level $\alpha$ is:
$$d_{\text{crit}}(n) = \frac{F^{-1}_{t(n-1)}(1 - \alpha/2)}{\sqrt{n}}$$
The p-value is a continuous measure of evidence, yet in practice it is often reduced to a binary decision: "p < 0.05 is significant, p ≥ 0.05 is not." This dichotomous thinking contributes to the reproducibility crisis in science.
p3d aims to weaken the visual basis of this dichotomous thinking by visualizing the p-value over a two-dimensional parameter space. The significance boundary is a curve, not a point.
p_surface() computes a 60,100-cell grid in 0.02 seconds (approximately 3 million p-values per second). Memory usage is under 3 MB.
Please use GitHub Issues for bug reports and feature requests.
GPL-3 © Ahmet Kutuk