Create a decision tree

dtree(yl, opt = "max", base = character(0), envir = parent.frame())

Arguments

yl

A yaml string or a list (e.g., from yaml::yaml.load_file())

opt

Find the maximum ("max") or minimum ("min") value for each decision node

base

List of variable definitions from a base tree used when calling a sub-tree

envir

Environment to extract data from

Value

A list with the initial tree and the calculated tree

Details

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

See also

summary.dtree to summarize results

plot.dtree to plot results

sensitivity.dtree to plot results

Examples

yaml::as.yaml(movie_contract) %>% cat()
#> name: Sign contract #> variables: #> legal fees: 5000 #> type: decision #> Sign with Movie Company: #> cost: legal fees #> type: chance #> Small Box Office: #> p: 0.3 #> payoff: 200000 #> Medium Box Office: #> p: 0.6 #> payoff: 1000000 #> Large Box Office: #> p: 0.1 #> payoff: 3000000 #> Sign with TV Network: #> payoff: 900000
dtree(movie_contract, opt = "max") %>% summary(output = TRUE)
#> Decision tree input: #> name: Sign contract #> variables: #> legal fees: 5000 #> type: decision #> Sign with Movie Company: #> cost: legal fees #> type: chance #> Small Box Office: #> p: 0.3 #> payoff: 200000 #> Medium Box Office: #> p: 0.6 #> payoff: 1000000 #> Large Box Office: #> p: 0.1 #> payoff: 3000000 #> Sign with TV Network: #> payoff: 900000 #> #> Variable input values: #> #> legal fees 5000 #> #> Initial decision tree: #> Probability Payoff Cost Type #> Sign contract #> ¦--Sign with Movie Company 5,000.00 decision #> ¦ ¦--Small Box Office 30.00 % 200,000.00 chance #> ¦ ¦--Medium Box Office 60.00 % 1,000,000.00 chance #> ¦ °--Large Box Office 10.00 % 3,000,000.00 chance #> °--Sign with TV Network 900,000.00 decision #> #> Final decision tree: #> Probability Payoff Cost Type #> Sign contract 955,000.00 #> ¦--Sign with Movie Company 955,000.00 5,000.00 decision #> ¦ ¦--Small Box Office 30.00 % 200,000.00 chance #> ¦ ¦--Medium Box Office 60.00 % 1,000,000.00 chance #> ¦ °--Large Box Office 10.00 % 3,000,000.00 chance #> °--Sign with TV Network 900,000.00 decision