Skip to contents

This function creates an interpretation of policy tree results from a causal forest or multi-arm causal forest model. It generates a formatted description of the policy tree, including the main splits and recommended actions.

Usage

margot_interpret_policy_tree(
  model,
  model_name,
  train_proportion = 0.7,
  custom_action_names = NULL,
  label_mapping = NULL,
  original_df = NULL,
  remove_tx_prefix = TRUE,
  remove_z_suffix = TRUE,
  use_title_case = TRUE
)

Arguments

model

A list containing the results from a multi-arm causal forest model.

model_name

A string specifying which model's results to interpret.

train_proportion

numeric value between 0 and 1 for the proportion of data used for training. default is 0.7.

custom_action_names

optional vector of custom names for the actions. must match the number of actions in the policy tree.

label_mapping

optional list that maps variable names to custom labels. used for descriptive labels in the interpretation.

original_df

optional dataframe with untransformed variables, used to display split values on the data scale.

remove_tx_prefix

logical indicating whether to remove prefixes like t0_ from variable names. default is true.

remove_z_suffix

logical indicating whether to remove the _z suffix from variable names. default is true.

use_title_case

logical indicating whether to convert variable names to title case. default is true.

Value

invisibly returns a string containing the interpretation. the function also prints the interpretation to the console.

Examples

if (FALSE) { # \dontrun{
# create a label mapping
label_mapping <- list(
  "t2_env_not_climate_chg_concern_z" = "Deny Climate Change Concern",
  "t2_env_not_climate_chg_cause_z" = "Deny Humans Cause Climate Change"
)

# interpret policy tree results with label mapping
interpretation <- margot_interpret_policy_tree_new(
  model = models_multi,
  model_name = "model_t2_env_not_climate_chg_concern_z",
  label_mapping = label_mapping,
  original_df = original_df
)

# print the interpretation
cat(interpretation)
} # }