R: Conditional Inference Trees (2024)

Conditional Inference Trees {party}R Documentation

Conditional Inference Trees

Description

Recursive partitioning for continuous, censored, ordered, nominal andmultivariate response variables in a conditional inference framework.

Usage

ctree(formula, data, subset = NULL, weights = NULL, controls = ctree_control(), xtrafo = ptrafo, ytrafo = ptrafo, scores = NULL)

Arguments

formula

a symbolic description of the model to be fit. Notethat symbols like : and - will not workand the tree will make use of all variables listed on therhs of formula.

data

a data frame containing the variables in the model.

subset

an optional vector specifying a subset of observations to beused in the fitting process.

weights

an optional vector of weights to be used in the fittingprocess. Only non-negative integer valued weights areallowed.

controls

an object of class TreeControl, which can beobtained using ctree_control.

xtrafo

a function to be applied to all input variables.By default, the ptrafo function is applied.

ytrafo

a function to be applied to all response variables. By default, the ptrafo function is applied.

scores

an optional named list of scores to be attached to orderedfactors.

Details

Conditional inference trees estimate a regression relationship by binary recursivepartitioning in a conditional inference framework. Roughly, the algorithmworks as follows: 1) Test the global null hypothesis of independence betweenany of the input variables and the response (which may be multivariate as well). Stop if this hypothesis cannot be rejected. Otherwise select the inputvariable with strongest association to the resonse. Thisassociation is measured by a p-value corresponding to a test for thepartial null hypothesis of a single input variable and the response.2) Implement a binary split in the selected input variable. 3) Recursively repeate steps 1) and 2).

The implementation utilizes a unified framework for conditional inference,or permutation tests, developed by Strasser and Weber (1999). The stopcriterion in step 1) is either based on multiplicity adjusted p-values (testtype == "Bonferroni"or testtype == "MonteCarlo" in ctree_control),on the univariate p-values (testtype == "Univariate"),or on values of the test statistic(testtype == "Teststatistic"). In both cases, thecriterion is maximized, i.e., 1 - p-value is used. A split is implemented when the criterion exceeds the value given by mincriterion asspecified in ctree_control. For example, when mincriterion = 0.95, the p-value must be smaller than$0.05$ in order to split this node. This statistical approach ensures thatthe right sized tree is grown and no form of pruning or cross-validationor whatsoever is needed. The selection of the input variable to split inis based on the univariate p-values avoiding a variable selection biastowards input variables with many possible cutpoints.

Multiplicity-adjusted Monte-Carlo p-values are computed following a "min-p" approach. The univariate p-values based on the limiting distribution (chi-squareor normal) are computed for each of the random permutations of the data. This means that one shoulduse a quadratic test statistic when factors are inplay (because the evaluation of the correspondingmultivariate normal distribution is time-consuming).

By default, the scores for each ordinal factor x are1:length(x), this may be changed using scores = list(x = c(1,5,6)), for example.

Predictions can be computed using predict ortreeresponse. The first function accepts argumentstype = c("response", "node", "prob") where type = "response"returns predicted means, predicted classes or median predicted survivaltimes, type = "node" returns terminal node IDs (identical towhere) and type = "prob" gives more information aboutthe conditional distribution of the response, i.e., class probabilities orpredicted Kaplan-Meier curves and is identical totreeresponse. For observations with zero weights,predictions are computed from the fitted tree when newdata = NULL.

For a general description of the methodology see Hothorn, Hornik andZeileis (2006) and Hothorn, Hornik, van de Wiel and Zeileis (2006). Introductions for novices can be found in Strobl et al. (2009) andat https://github.com/christophM/overview-ctrees.

Value

An object of class BinaryTree-class.

References

Helmut Strasser and Christian Weber (1999). On the asymptotic theory of permutationstatistics. Mathematical Methods of Statistics, 8, 220–250.

Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel and Achim Zeileis (2006).A Lego System for Conditional Inference. The American Statistician,60(3), 257–263.

Torsten Hothorn, Kurt Hornik and Achim Zeileis (2006). Unbiased RecursivePartitioning: A Conditional Inference Framework. Journal ofComputational and Graphical Statistics, 15(3), 651–674. Preprint availablefrom https://www.zeileis.org/papers/Hothorn+Hornik+Zeileis-2006.pdf

Carolin Strobl, James Malley and Gerhard Tutz (2009).An Introduction to Recursive Partitioning: Rationale, Application, and Characteristics of Classification and Regression Trees, Bagging, and Random forests.Psychological Methods, 14(4), 323–348.

Examples

 set.seed(290875) ### regression airq <- subset(airquality, !is.na(Ozone)) airct <- ctree(Ozone ~ ., data = airq, controls = ctree_control(maxsurrogate = 3)) airct plot(airct) mean((airq$Ozone - predict(airct))^2) ### extract terminal node ID, two ways all.equal(predict(airct, type = "node"), where(airct)) ### classification irisct <- ctree(Species ~ .,data = iris) irisct plot(irisct) table(predict(irisct), iris$Species) ### estimated class probabilities, a list tr <- treeresponse(irisct, newdata = iris[1:10,]) ### ordinal regression data("mammoexp", package = "TH.data") mammoct <- ctree(ME ~ ., data = mammoexp) plot(mammoct) ### estimated class probabilities treeresponse(mammoct, newdata = mammoexp[1:10,]) ### survival analysis if (require("TH.data") && require("survival")) { data("GBSG2", package = "TH.data") GBSG2ct <- ctree(Surv(time, cens) ~ .,data = GBSG2) plot(GBSG2ct) treeresponse(GBSG2ct, newdata = GBSG2[1:2,]) } ### if you are interested in the internals: ### generate doxygen documentation ## Not run: ### download src package into temp dir tmpdir <- tempdir() tgz <- download.packages("party", destdir = tmpdir)[2] ### extract untar(tgz, exdir = tmpdir) wd <- setwd(file.path(tmpdir, "party")) ### run doxygen (assuming it is there) system("doxygen inst/doxygen.cfg") setwd(wd) ### have fun browseURL(file.path(tmpdir, "party", "inst", "documentation", "html", "index.html")) ## End(Not run)

[Package party version 1.3-15 Index]

R: Conditional Inference Trees (2024)

FAQs

What are conditional inference trees? ›

Conditional inference trees estimate a regression relationship by binary recursive partitioning in a conditional inference framework. Roughly, the algorithm works as follows: 1) Test the global null hypothesis of independence between any of the input variables and the response (which may be multivariate as well).

What is the ctree function in R? ›

The function ctree() is used to create conditional inference trees. The main components of this function are formula and data. Other components include subset, weights, controls, xtrafo, ytrafo, and scores. arguments. formula: refers to the the decision model we are using to make predicitions.

Can you create an R decision tree? ›

Using the function decision_tree() from the Tidymodels package in R, it is straightforward to create a decision tree model specification first and then fit the model on the training data. We use the “regression” model here, and for a classification decision tree, we would have to use the “classification” mode.

What is the difference between CIT and cart? ›

Conditional Inference Trees (CITs) are much better at determining the true effect of a predictor, i.e. the effect of a predictor if all other effects are simultaneously considered. In contrast to CARTs, CITs use p-values to determine splits in the data.

Are decision trees immune to multicollinearity in features? ›

Here's why multicollinearity isn't a significant concern for decision trees: Variable Selection: Decision trees perform feature selection implicitly during the training process. At each node, the algorithm chooses the feature that best splits the data, making decisions based on the available features.

Are decision trees unstable? ›

Decision-tree algorithms are known to be unstable: small variations in the training set can result in different trees and different predictions for the same validation examples.

How do decision trees work with an example? ›

A. A decision tree is a tree-like structure that represents a series of decisions and their possible consequences. It is used in machine learning for classification and regression tasks. An example of a decision tree is a flowchart that helps a person decide what to wear based on the weather conditions.

Which package do we use for decision trees in R? ›

R has packages which are used to create and visualize decision trees. For new set of predictor variable, we use this model to arrive at a decision on the category (yes/No, spam/not spam) of the data. The R package "party" is used to create decision trees.

How do you interpret a decision tree graph? ›

To interpret a decision tree, you need to follow the path from the root node to the leaf node that corresponds to your data point or scenario. Each node and branch will tell you what feature and value are used to split the data, and what proportion and value of the outcome variable are associated with each group.

What is the difference between R * tree and R tree? ›

In data processing R*-trees are a variant of R-trees used for indexing spatial information. R*-trees have slightly higher construction cost than standard R-trees, as the data may need to be reinserted; but the resulting tree will usually have a better query performance.

How accurate is the decision tree in R? ›

The tree model has an accuracy of 0.8361 on the training set, but we'd expect it to perform well on the data set used to create it.

What is the entropy of a decision tree in R? ›

Entropy in R Programming is said to be a measure of the contaminant or ambiguity existing in the data. It is a deciding constituent while splitting the data through a decision tree. An unsplit sample has an entropy equal to zero while a sample with equally split parts has entropy equal to one.

What is a cart in slang? ›

Is cart slang for vape? Yes, “cart” is a common slang term used to refer to a marijuana oil vape cartridge. Pre-filled carts contain cannabis concentrates and connect to a battery operated vape pen.

What is the difference between TCR and cart? ›

Like CAR-T cell therapy, TCR therapy involves the modification of T cells in a lab. However, unlike CAR-T cell therapy — which relies on man-made receptors that can only target things on the surface of cells —TCR therapy capitalizes on the natural mechanisms of T cells.

What does the acronym cart stand for? ›

What is CART and what does it stand for? CART, an acronym for “Communication Access Real-Time Translation” is a process that turns spoken words into written text in real time. With the help of technology and a machine called a stenotype, a CART service captures what is being said and displays it as text on a screen.

What are decision trees for inference? ›

Inferring a decision tree from a given dataset is a classic problem in machine learning. This problem consists of building, from a labelled dataset, a tree where each node corresponds to a class and a path between the tree root and a leaf corresponds to a conjunction of features to be satisfied in this class.

What are conditions in decision trees? ›

Conditions with two possible outcomes (for example, true or false) are called binary conditions. Decision trees containing only binary conditions are called binary decision trees. Non-binary conditions have more than two possible outcomes.

What is an example of a decision tree? ›

A decision tree is a tree-like structure that represents a series of decisions and their possible consequences. It is used in machine learning for classification and regression tasks. An example of a decision tree is a flowchart that helps a person decide what to wear based on the weather conditions.

What are decision trees in causal inference? ›

Decision trees for causal inference are generally used to separate data into buckets in order to estimate the average treatment effects within each node.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 5661

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.