Skip to contents

Transforms a cta_balance_table result into a renderer-independent data structure suitable for Graphics v3 plotting. For no_tree results, populates no_tree_message with the favorable-balance interpretation.

Usage

cta_balance_plot_data(cta_balance, target_class = 1L, digits = 1L)

Arguments

cta_balance

A "cta_balance_table" object from cta_balance_table.

target_class

Integer; target class for endpoint coloring in the embedded tree diagram. Default 1L (group 1 = treated).

digits

Integer; decimal digits passed to cta_plot_data. Default 1L.

Value

A list of class "cta_balance_plot_data" with elements:

status

Character; "valid_tree", "stump", "no_tree", or "fit_error".

balance_interpretation

Character.

no_tree_message

Character; human-readable no-tree annotation for renderers; NA when status is not "no_tree".

cta_pd

List from cta_plot_data when a valid tree or stump was found; NULL for no_tree or fit_error.

ess_display

Numeric; full-tree ESS/WESS (%); NA for no_tree.

d_stat

Numeric; NA for no_tree.

has_weights

Logical.

ess_label

Character; "WESS" or "ESS".

Details

This function does not fit any CTA models. It is a pure transformation of the pre-computed cta_balance_table result.

Examples

X <- data.frame(
  A = c(rep(0L, 20), rep(1L, 20), rep(1L, 20)),
  B = c(rep(0L, 20), rep(0L, 20), rep(1L, 20))
)
group <- c(rep(0L, 40), rep(1L, 20))
ct  <- cta_balance_table(group, X, mindenom = 5L,
                          mc_iter = 200L, mc_seed = 42L)
cpd <- cta_balance_plot_data(ct)
cpd$status
#> [1] "valid_tree"