Skip to contents

This function generates a combined plot consisting of a decision tree and a graph showing relationships between variables in the recommended policy.

Usage

margot_plot_policy_combo(
  result_object,
  model_name,
  label_mapping = NULL,
  original_df = NULL,
  layout = list(heights = c(1, 2)),
  annotation = list(tag_levels = "A"),
  generate_policy_tree = TRUE,
  generate_decision_tree = TRUE,
  policy_tree_args = list(),
  decision_tree_args = list()
)

Arguments

result_object

An object containing the results from a multi-arm causal forest model.

model_name

A character string specifying the name of the model.

label_mapping

Optional named list for custom label mappings.

original_df

Optional dataframe with untransformed variables.

layout

A list specifying the layout of the combined plot. Default is `list(heights = c(1, 2))`, which sets the relative heights of the two plots.

annotation

A list specifying the annotation for the combined plot. Default is `list(tag_levels = "A")`, which adds alphabetic tags to the subplots.

generate_policy_tree

Logical, whether to generate the policy tree plot. Default is TRUE.

generate_decision_tree

Logical, whether to generate the decision tree plot. Default is TRUE.

policy_tree_args

A list of arguments to pass to margot_plot_policy_tree. Default is list().

decision_tree_args

A list of arguments to pass to margot_plot_decision_tree. Default is list().

Value

A list containing:

policy_tree

A ggplot object representing the policy tree (if generated)

decision_tree

A ggplot object representing the decision tree (if generated)

combined_plot

A ggplot object representing the combined plot (if both plots are generated)

Examples

if (FALSE) { # \dontrun{
# Assuming 'results' is your Margot results object, 'model_name' is the name of your model,
# 'label_mapping' is your custom label mapping, and 'original_df' is your original dataframe
combined_plot <- margot_plot_policy_combo(
  result_object = results,
  model_name = "model_t2_env_not_env_efficacy_z",
  label_mapping = label_mapping,
  original_df = original_df,
  policy_tree_args = list(point_alpha = 0.75),
  decision_tree_args = list(text_size = 4.5, edge_label_offset = 0.01)
)

# Print the combined plot
print(combined_plot$combined_plot)
} # }