Skip to contents

This function creates a ggplot object displaying Qini curves based on the results of a margot_multi_arm_causal_forest() model. It includes label transformations and informative CLI messages.

Usage

margot_plot_qini(
  mc_result,
  outcome_var,
  remove_tx_prefix = TRUE,
  remove_z_suffix = TRUE,
  use_title_case = TRUE,
  remove_underscores = TRUE,
  label_mapping = NULL
)

Arguments

mc_result

A list containing the results from margot_multi_arm_causal_forest().

outcome_var

A character string specifying the name of the outcome variable to plot. This should match one of the model names in mc_result$results.

remove_tx_prefix

Logical value indicating whether to remove the "tx_" prefix from labels. Default is TRUE.

remove_z_suffix

Logical value indicating whether to remove the "_z" suffix from labels. Default is TRUE.

use_title_case

Logical value indicating whether to convert labels to title case. Default is TRUE.

remove_underscores

Logical value indicating whether to remove underscores from labels. Default is TRUE.

label_mapping

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

Value

A ggplot object representing the Qini curves for the specified outcome variable.

Examples

if (FALSE) { # \dontrun{
# Assuming mc.test is the result of margot_multi_arm_causal_forest()
plot_qini_curves(mc.test, "model_t2_belong_z")

# Using custom label mapping
label_mapping <- list(
  "t2_env_not_env_efficacy_z" = "Deny Personal Environmental Efficacy",
  "t2_env_not_climate_chg_real_z" = "Deny Climate Change Real"
)
plot_qini_curves(mc.test, "model_t2_env_not_env_efficacy_z", label_mapping = label_mapping)
} # }