Skip to contents

Creates a forest plot visualization of cross-validation heterogeneity test results from margot_rate_cv(). Shows t-statistics, p-values, and significance for each model.

Usage

margot_plot_cv_results(
  cv_results,
  title = NULL,
  subtitle = NULL,
  x_lab = "t-statistic",
  y_lab = "Model",
  remove_model_prefix = TRUE,
  label_mapping = NULL,
  show_p_values = TRUE,
  significance_color = "#4CAF50",
  non_significance_color = "#9E9E9E",
  null_line_color = "#FF5252",
  point_size = 3,
  text_size = 3
)

Arguments

cv_results

A margot_cv_results object from margot_rate_cv()

title

Character string for the plot title. If NULL (default), a title is generated based on the CV method details.

subtitle

Character string for the plot subtitle. Default shows the adjustment method.

x_lab

Character string for the x-axis label. Default is "t-statistic".

y_lab

Character string for the y-axis label. Default is "Model".

remove_model_prefix

Logical; remove "model_" prefix from model names. Default TRUE.

label_mapping

Optional named list for custom label mappings. Keys should be model names (with or without "model_" prefix), and values should be the desired display labels.

show_p_values

Logical; show p-values on the plot. Default TRUE.

significance_color

Color for significant results. Default "#4CAF50" (green).

non_significance_color

Color for non-significant results. Default "#9E9E9E" (gray).

null_line_color

Color for the null hypothesis line. Default "#FF5252" (red).

point_size

Size of the points. Default 3.

text_size

Size of p-value text. Default 3.

Value

A ggplot object that can be further customized or printed.

Examples

if (FALSE) { # \dontrun{
# Run cross-validation heterogeneity test
cv_results <- margot_rate_cv(
  model_results = cf_results,
  num_folds = 5,
  target = "AUTOC",
  alpha = 0.2, # recommended for Bonferroni
  adjust = "bonferroni"
)

# Create forest plot
p <- margot_plot_cv_results(cv_results)
print(p)

# Create summary plot
p_summary <- margot_plot_cv_summary(cv_results)
print(p_summary)

# With custom labels
label_mapping <- list(
  "model_happiness" = "Happiness",
  "model_depression" = "Depression"
)
p <- margot_plot_cv_results(cv_results, label_mapping = label_mapping)

# Note: If you try to use margot_plot_rate() with CV results, you'll get an error:
# margot_plot_rate(cv_results$cv_results)  # Error - use margot_plot_cv_results() instead
} # }