Fits a single cta_fit model with group as the class
variable and all columns of X as candidate predictors. Returns a
structured summary of the CTA balance result.
Usage
cta_balance_table(
group,
X,
w = NULL,
mindenom = 1L,
alpha = 0.05,
loo = "off",
mc_iter = 5000L,
mc_seed = NULL,
...
)Arguments
- group
Integer (or coercible) binary group indicator. Must have exactly two distinct non-missing values.
- X
Data frame of baseline covariate columns.
- w
Optional numeric case-weight vector. When supplied, CTA uses case weights and
has_weights = TRUEin the result.- mindenom
Integer minimum endpoint denominator passed to
cta_fit. Default1L.- alpha
Numeric significance threshold stored in the result and used in the
no_tree_messageofcta_balance_plot_data. Default0.05. Does not overridealpha_split; passalpha_splitvia...to change the CTA node-level threshold.- loo
LOO gate mode passed to
cta_fit. Default"off".- mc_iter
Integer MC iterations per CTA node. Default
5000L.- mc_seed
Integer RNG seed;
NULLfor unseeded.- ...
Additional arguments forwarded to
cta_fit(e.g.,alpha_split,prune_alpha,priors_on).
Value
A list of class "cta_balance_table" with fields:
statusCharacter:
"valid_tree","stump","no_tree", or"fit_error".balance_interpretationCharacter:
"discriminating"or"no_discriminating_combinations"(whenno_tree);NAon fit error.root_attributeCharacter; root split variable name;
NAwhenno_tree.n_endpointsInteger; number of terminal endpoints;
NAwhenno_tree.overall_essNumeric; full-tree ESS (%) when weights not active;
NAotherwise.overall_wessNumeric; full-tree WESS (%) when weights active;
NAotherwise.ess_displayNumeric; operative measure (
overall_wesswhen weights active, elseoverall_ess);NAfor no_tree.d_statNumeric; parsimony-adjusted D statistic;
NAfor no_tree.mindenomInteger; MINDENOM used.
alphaNumeric; significance threshold stored for downstream use.
has_weightsLogical; whether case weights were active.
treeThe raw
cta_treeobject;NULLon fit error.endpoint_tableData frame from
cta_endpoint_table; zero-row for no_tree.node_tableData frame from
cta_node_table.fit_errorLogical;
TRUEwhencta_fitthrew.fit_reasonCharacter; error message when
fit_error;NAotherwise.
Details
A status = "no_tree" result means no combination of baseline
covariates in X predicted group membership at the declared
significance level, LOO constraint, and minimum endpoint denominator.
This is favorable evidence of multivariable covariate balance
under the declared analytic constraints. It must not be interpreted as
a model failure; in balance analysis, inability to discriminate groups is
the goal.
group vs. outcome: group is the binary class variable.
The scientific outcome is strictly out of scope.
Implementation constraint: this function calls cta_fit
once; it does not reimplement ENUMERATE or node-growth logic.
References
Linden A, Yarnold PR (2016). Using machine learning to assess covariate balance in matching studies. Journal of Evaluation in Clinical Practice, 22(6), 861-867.
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)
ct$status
#> [1] "valid_tree"
ct$balance_interpretation
#> [1] "discriminating"