*! version 1.0.0 07Jan2020

Title

cta -- Classification Tree Analysis

Syntax

cta classvar attributes [if] [in]
, pathcta(filepath)
[ version(string)
store(filepath)
name(string)
iter(#)
cutoff(#)
stop(#)
cat(varlist)
usefisher
loo(string)
wt(varname)
missing(#)
direction(string)
nopriors
prune(#)
enumerate
forcenode(varname #)
skipnode(#)
maxlevel(#)
mindenom(#) ]

classvar must be binary; attributes may be binary, ordinal, nomimal, or continuous.

pathcta(filepath) specify the file path of the cta64.exe (or cta32.exe) file; pathcta() is required

version(string) specify the CTA version for the user's computer (options are cta32 and cta64)); default is cta64

store(filepath) specify the file path to store all files and output generated by cta; default is the current working directory

name(string) provide name for all files produced; default is name of the classvar

iter(#) perform # random permutations; default is 1000

cutoff(#) cutoff level for permutations; default is 0.05

stop(#) stopping rule for permutations; default is 99.9

cat(varlist) indicate which attributes should be treated as categorical variables

usefisher specify that all probability calculations for categorical variables be determined by Fisher’s exact test rather than permutation test

loo(string) specify that leave-one-out (jackknife) analysis be performed; loo can be specified with no option or loo(stable)

wt(varname) weight variable for use in weighted analyses

missing(#) integer value (positive or negative) indicating missing values

direction(string) compute one-sided P-values. "<" or "lt" indicates that the classvar values are ordered in the “less-than” direction. ">" or "gt"
indicates the classvar values are ordered in the “greater-than” direction. The value list must contain both values of the classvar

nopriors turn priors off; default is on

prune(#) indicate the P-value with which to optimally prune the classification tree

enumerate specify that all combinations of attributes in the top three nodes will be evaluated. prune() must also be specified

forcenode(varname #) force CTA to insert the attribute at node # in the solution tree

skipnode(#) specify that the node # will be empty of any attribute in the solution tree

maxlevel(#) deepest level allowed in the solution tree

mindenom(#) specify the minimum denominator value for an attribute to be allowed in the solution tree

Description

cta is a wrapper program for the Classification Tree Analysis (CTA) software (Yarnold & Soltysik 2016). Therefore,
CTA must be installed in order for the cta Stata package to work. CTA software is available at https://odajournal.com/resources/.

Remarks

In its simplest form, CTA is an optimal discriminant analysis (ODA) model (Yarnold & Soltysik 1991, 2005, 2016). ODA is a machine-learning algorithm that finds the
cutpoint(s) on a continuous (ordered) attribute (variable) that maximally discriminates between two or more classes (e.g. treatment groups). The optimal cutpoint
is determined by iterating through each value on the attribute and calculating the effect strength for sensitivity [ESS], which is the mean sensitivity
amongst the classes, standardized to a 0 - 100% scale where 0 represents the discriminatory accuracy expected by chance, and 100% represents perfect
discrimination. By definition, the maximally accurate predictive model uses the “optimal” cutpoint achieving the highest ESS. This model is further
subjected to a non-parametric permutation test to assess the statistical validity of that cutpoint. Finally, generalizability of the model is assessed
using leave-one-out cross-validation.

CTA models use one or more attributes to classify a sample of observations into two or more subgroups that are represented as model endpoints (these are called
“terminal nodes” in alternative decision-tree methods). Subgroups are known as “sample strata” because the CTA model stratifies the sample into subgroups of
observations that -- with respect to model attributes -- are homogeneous within and heterogeneous between strata (Yarnold & Soltysik 2016). The pruned CTA
algorithm involves chained ODA models in which the initial (“root”) node represents the attribute achieving the highest ESS value for the entire sample, and
additional nodes yielding greatest ESS are iteratively added at every step on all model branches while retaining statistical significance (defined by the prune() option).
In contrast, the enumerated-optimal CTA algorithm explicitly evaluates all possible combinations of the first three nodes, which dominate the solution.

See Soltysik & Yarnold (2010) for an excellent introduction to CTA models, and Yarnold & Soltysik (2016) for a comprehensive discussion. Additional
references are provided below that detail the use of CTA for causal inferential problems.

Options

pathcta(filepath) file path where the cta64.exe (or cta32.exe) is located on the user's computer (e.g. "C:\CTA\"). pathcta() is required.

version(string) specifies the CTA version for the user's computer (options are cta32 and cta64)). Default is cta64.

store(filepath) file path to store all files and output generated by cta (e.g. "C:\CTA\output\"). Default is the current working directory.

name(string) provides a name for all files produced (extensions such as .csv, .out, .txt will be added accordingly). Default is name of the classvar.

iter(#) specifies the number of random permutations to perform. Default is 1000 iterations.

cutoff(#) specifies the P-value cutoff level for stopping the permutation test if it can be reached before the iterations naturally end (and before
the stop value is reached). Default is 0.05.

stop(#) specifies the confidence level for the stopping the permuation test if it can be reached before the iterations naturally end (and before
the cutoff value is reached). Default is 99.9.

cat(varlist) indicates which attributes should be treated as categorical variables. The default is to treat the attributes as continuous (ordered).

usefisher specifies that all probability calculations for categorical variables be determined by Fisher’s exact test rather than by permutation tests.

loo(string) specifies that leave-one-out analysis be performed for every attribute in the tree. loo can be specified alone, while loo(stable)
allows only attributes with LOO ESS equal to the ESS for that attribute. In CTA, LOO is not available for weighted categorical problems (i.e. loo cannot be specified
together with both wt() and cat()).

wt(varname) indicates the weight variable for use with weighted analyses. wt() cannot be the same variable specified as either the classvar
or any of the attributes; CTA treats weight() as an importance weight (see weight).

missing(#) is an integer value (positive or negative) indicating missing values. It is common in surveys to code missing values as 99, 999, 9999, -99, etc.

direction(string) compute one-sided P-values. "<" or "lt" indicates that the classvar values are ordered in the “less-than” direction. ">" or "gt"
indicates the classvar values are ordered in the “greater-than” direction. The value list must both values of the classvar, and each character must be separated
with a space (e.g. "< 0 1" or "lt 0 1" or "> 1 0" or "gt 1 0"). By default, two-sided P-values are computed (i.e no directional hypothesis).

nopriors by default, CTA weights analyses by the reciprocal of sample class membership, in order to adjust for differences in class category sizes. nopriors is
therefore recommended for balanced samples so that no unnecessary weighting will be employed.

prune(#) indicates the P-value with which to optimally prune the classification tree.

enumerate specifies that all combinations of attributes in the top three nodes will be evaluated. prune() must also be specified when enumerate is specified.

forcenode(varname #) forces CTA to insert the attribute at node # in the solution tree. For example forcenode(v1 1) indicates that the variable
v1 should be forced into the first node in the tree.

skipnode(#) specifies that the node # will be empty of any attribute in the solution tree.

maxlevel(#) deepest level allowed in the solution tree.

mindenom(#) specifies the minimum denominator value for an attribute to be allowed in the solution tree. To increase the likelihood of the model
cross-generalizing when applied to a validity sample, model endpoints should represent at least 5% of the total sample. For example if the total sample size is 4000,
then mindenom(200) may be a reasonable minimum value.

Examples

Setup

. webuse cattaneo2, clear

We assess whether CTA can distinguish between low and normal birthweights based on several attributes. We use the default 1000 permutations,
specify that LOO analysis be conducted with the stable option, and stipulate that a pruned tree and enumerated tree also be generated

. cta lbweight mage fage mmarried msmoke fbaby foreign, pathcta("C:\CTA\") store("C:\CTA\output") cat(mmarried msmoke fbaby foreign) loo(stable) prune(0.05) enumerate

Same as above but specify that Fisher's exact test be performed on categorical variables instead of permutation tests

. cta lbweight mage fage mmarried msmoke fbaby foreign, pathcta("C:\CTA\") store("C:\CTA\output") cat(mmarried msmoke fbaby foreign) loo(stable) prune(0.05) enumerate usefisher

Same as above but specify that model endpoints must have a denominator of at least 250 (approximately 5% of the sample)

. cta lbweight mage fage mmarried msmoke fbaby foreign, pathcta("C:\CTA\") store("C:\CTA\output") cat(mmarried msmoke fbaby foreign) loo(stable) prune(0.05) enumerate usefisher mindenom(250)

Stored results

cta stores the following in r(), which can be displayed by typing return list after cta is finished. When wt() is specified, the stored values are weighted:

Scalars

r(ess_unpruned) ESS for the unpruned model

r(ess_pruned) ESS for the pruned model (when the pruned() option is specified)

r(ess_enumerate) ESS for the enumerated model (when the enumerate option is specified)

References

Soltysik RC, Yarnold PR. Automated CTA software: fundamental concepts and control commands.
Optimal Data Analysis 2010;1:144-160.

Yarnold PR, Soltysik RC. Theoretical distributions of optima for univariate discrimination of random data.
Decision Sciences 1991;22:739–752.

Yarnold PR, Soltysik RC. Optimal Data Analysis: A Guidebook with Software for Windows. Washington, DC: APA Books, 2005.

Yarnold PR, Soltysik RC. Maximizing Predictive Accuracy. Chicago, IL: ODA Books. DOI: 10.13140/RG.2.1.1368.3286, 2016.

Linden A, Yarnold PR. Using data mining techniques to characterize participation in observational studies. Journal of Evaluation in Clinical Practice 2016;22:839-847.

Linden A, Yarnold PR. Using classification tree analysis to generate propensity score weights. Journal of Evaluation in Clinical Practice 2017;23:703-712.

Linden A, Yarnold PR. Modeling time-to-event (survival) data using classification tree analysis. Journal of Evaluation in Clinical Practice 2017;23:1299-1308.

Linden A, Yarnold PR. Minimizing imbalances on patient characteristics between treatment groups in randomized trials using classification tree analysis. Journal of Evaluation in Clinical Practice 2017;23:1309-1315.

Linden A, Yarnold PR. Identifying causal mechanisms in health care interventions using classification tree analysis. Journal of Evaluation in Clinical Practice 2018;24:353-361.

Linden A, Yarnold PR. Estimating causal effects for survival (time-to-event) outcomes by combining classification tree analysis and propensity score weighting. Journal of Evaluation in Clinical Practice 2018;24:380-387.

Citation of cta

cta is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. (2020). CTA: Stata module for conducting Classification Tree Analysis. Statistical Software Components S458729, Boston College Department of Economics.

Author

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Acknowledgments

I wish to thank Paul R. Yarnold for reviewing cta and providing valuable comments.

Also see

Online: oda (if installed), looclass (if installed), kfoldclass (if installed) classtabi (if installed)