Plots the output of p_surface as an interactive
three-dimensional surface. Two rendering engines are supported:
"rgl" (default, interactive window) and "plotly"
(HTML widget, ideal for R Markdown / Quarto documents).
Usage
plot_p_surface(
surface,
engine = c("rgl", "plotly"),
alpha = 0.05,
col = NULL,
show_boundary = TRUE
)Arguments
- surface
A list returned by
p_surface.- engine
Character; either
"rgl"(default) or"plotly". Determines the rendering backend.- alpha
Significance level. A horizontal plane at \(p = \alpha\) is overlaid on the surface. Default: 0.05.
- col
Color palette for the surface. If
NULL(default), a built-in palette is used.- show_boundary
Logical; if
TRUE(default), the intersection curve between the surface and the \(\alpha\)-plane is drawn.
Details
The 3D surface shows the p-value as a function of both effect size (\(d\)) and sample size (\(n\)). The \(\alpha\)-plane visualizes the conventional significance threshold. The intersection curve marks the boundary between "significant" and "non-significant" regions.
For engine = "rgl", the rgl package must be
installed. For engine = "plotly", the plotly
package must be installed. Both are listed in Suggests.
Examples
# Compute surface (non-interactive part)
surface <- p_surface(d = seq(-2, 2, 0.1), n = seq(5, 200, 5))
str(surface, max.level = 1)
#> List of 6
#> $ d : num [1:41] -2 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 ...
#> $ n : num [1:40] 5 10 15 20 25 30 35 40 45 50 ...
#> $ p : num [1:41, 1:40] 0.0111 0.0132 0.0158 0.0191 0.0232 ...
#> $ d_crit: num [1:40] 1.242 0.715 0.554 0.468 0.413 ...
#> $ alpha : num 0.05
#> $ grid :'data.frame': 1640 obs. of 5 variables:
#> ..- attr(*, "out.attrs")=List of 2
# Interactive visualization (only in interactive sessions)
if (interactive()) {
# rgl engine (interactive window)
plot_p_surface(surface)
# plotly engine (HTML widget)
plot_p_surface(surface, engine = "plotly")
}