This function visualizes the results of a permutation test by plotting a histogram of the permutation test statistics. A red dotted line indicates the location of the original unpermuted test statistic.

visualize_permutation_test(
  permutation_results,
  original_stat,
  stat_name,
  plot_title,
  bin_width = 0.1
)

Arguments

permutation_results

A numeric vector of permutation test statistics.

original_stat

A numeric value representing the original unpermuted test statistic.

stat_name

A character string representing the name of the test statistic.

plot_title

string for plot title

bin_width

optional bin width for the histogram

Value

A ggplot object showing the histogram of permutation test statistics with the original test statistic marked.

Examples

if (FALSE) { # \dontrun{
set.seed(123)
n_perms <- 1000
permutation_results <- rnorm(n_perms, mean = 0, sd = 1)
original_stat <- 2
visualize_permutation_test(permutation_results, original_stat, "Simulated Statistic")
} # }