CART: Creates a classification or regression tree.

View source: R/cart.R

CARTR Documentation

Creates a classification or regression tree.

Description

Creates a classification or regression tree.

Usage

CART(
  formula,
  data = NULL,
  subset = NULL,
  weights = NULL,
  output = "Sankey",
  missing = "Use partial data",
  prune = "None",
  early.stopping = TRUE,
  auxiliary.data = NULL,
  show.labels = FALSE,
  predictor.level.treatment = "Abbreviated labels",
  outcome.level.treatment = "Full labels",
  decimals = NULL,
  long.running.calculations = TRUE,
  seed = 12321,
  ...
)

Arguments

formula

A formula expression. The left-hand-side (response) should be either a numerical vector when a regression tree will be fitted or a factor, when a classification tree is produced. The right-hand-side should be a series of numeric or factor variables separated by +; there should be no interaction terms. Both . and - are allowed: regression trees can have offset terms

data

A data frame in which to preferentially interpret formula, weights and subset

subset

An optional vector specifying a subset of observations to be used in the fitting process or the name of a variable in data. It may not be an expression.

weights

An optional vector of sampling weights or the name of a variable in data. It may not be an expression.

output

How the tree is represented: "Sankey", "Tree", "Text", "Prediction-Accuracy Table", "Cross Validation" or "Decision Rules"

missing

How missing data is to be treated in the regression. Options are: "Error if missing data", "Exclude cases with missing data", "Use partial data",and "Imputation (replace missing values with estimates)".

prune

How to prune the tree according to the cross-validated error. Options are: "None", "Minimum error" and "Smallest tree".

early.stopping

Whether or not to stop building the tree early if splits are not decreasing the lack of fit sufficiently.

auxiliary.data

A data frame containing additional variables to be used in imputation.

show.labels

Shows the variable labels, as opposed to the names, in the outputs, where a variables label is an attribute (e.g., attr(foo, "label")).

predictor.level.treatment

How predictor factor labels are displayed: "Letters", "Abbreviated labels" or "Full labels".

outcome.level.treatment

How outcome factor labels are displayed: "Letters", "Abbreviated labels" or "Full labels".

decimals

The number of decimal places to show when "output" is "Prediction-Accuracy Table".

long.running.calculations

Allow categorical predictors with over 30 levels.

seed

The random number seed.

...

Other arguments to be supplied to rpart. Normally used for mincut, minsize or mindev

Details

Creates an rpart.object tree and plots it as a SankeyTree


Displayr/flipTrees documentation built on Feb. 26, 2024, 12:46 a.m.