plot_interaction_surface: Plot Interaction Conditional Power Surface/Heatmap/Lines...

View source: R/added_plotting_functions.R

plot_interaction_surfaceR Documentation

Plot Interaction Conditional Power Surface/Heatmap/Lines (Multi-Effect Grid Friendly)

Description

Visualizes a metric (e.g., conditional Bayesian power) as a function of two effect grid variables for a fixed sample size or averaged over n. Allows line, heatmap, or contour modes.

Usage

plot_interaction_surface(
  data,
  metric,
  effect1,
  effect2,
  n = NULL,
  line = FALSE,
  facet_by = NULL,
  agg_fun = mean,
  title = NULL,
  subtitle = NULL
)

Arguments

data

Data frame (typically power_results$summary).

metric

Name of the summary column to plot, e.g. "power_direction", "power_threshold".

effect1

Name of effect grid column for x-axis.

effect2

Name of effect grid column for y-axis or color/facets.

n

Optional sample size to filter to (else averages/plots all n's).

line

Logical; if TRUE, make a lineplot (effect1 on x, one line for each effect2). If FALSE, make a heatmap or contour.

facet_by

Optional grid column(s) to facet by.

agg_fun

Aggregation function if multiple entries per cell (default = mean).

title, subtitle

Optional plot labels.

Value

A ggplot object.


powerbrmsINLA documentation built on July 2, 2026, 5:07 p.m.