crtree: Classification and regression trees based on the rpart...

View source: R/crtree.R

crtreeR Documentation

Classification and regression trees based on the rpart package

Description

Classification and regression trees based on the rpart package

Usage

crtree(
  dataset,
  rvar,
  evar,
  type = "",
  lev = "",
  wts = "None",
  minsplit = 2,
  minbucket = round(minsplit/3),
  cp = 0.001,
  pcp = NA,
  nodes = NA,
  K = 10,
  seed = 1234,
  split = "gini",
  prior = NA,
  adjprob = TRUE,
  cost = NA,
  margin = NA,
  check = "",
  data_filter = "",
  arr = "",
  rows = NULL,
  envir = parent.frame()
)

Arguments

dataset

Dataset

rvar

The response variable in the model

evar

Explanatory variables in the model

type

Model type (i.e., "classification" or "regression")

lev

The level in the response variable defined as _success_

wts

Weights to use in estimation

minsplit

The minimum number of observations that must exist in a node in order for a split to be attempted.

minbucket

the minimum number of observations in any terminal <leaf> node. If only one of minbucket or minsplit is specified, the code either sets minsplit to minbucket*3 or minbucket to minsplit/3, as appropriate.

cp

Minimum proportion of root node deviance required for split (default = 0.001)

pcp

Complexity parameter to use for pruning

nodes

Maximum size of tree in number of nodes to return

K

Number of folds use in cross-validation

seed

Random seed used for cross-validation

split

Splitting criterion to use (i.e., "gini" or "information")

prior

Adjust the initial probability for the selected level (e.g., set to .5 in unbalanced samples)

adjprob

Setting a prior will rescale the predicted probabilities. Set adjprob to TRUE to adjust the probabilities back to their original scale after estimation

cost

Cost for each treatment (e.g., mailing)

margin

Margin associated with a successful treatment (e.g., a purchase)

check

Optional estimation parameters (e.g., "standardize")

data_filter

Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000")

arr

Expression to arrange (sort) the data on (e.g., "color, desc(price)")

rows

Rows to select from the specified dataset

envir

Environment to extract data from

Details

See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant

Value

A list with all variables defined in crtree as an object of class tree

See Also

summary.crtree to summarize results

plot.crtree to plot results

predict.crtree for prediction

Examples

crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary()
result <- crtree(titanic, "survived", c("pclass", "sex")) %>% summary()
result <- crtree(diamonds, "price", c("carat", "clarity"), type = "regression") %>% str()

radiant.model documentation built on Oct. 16, 2023, 9:06 a.m.