Tree models are computationally intensive methods that are used in situations where there are many explanatory variables and we would like guidance about which of them to include in the model. Often there are so many explanatory variables that we simply could not test them all, even if we wanted to invest the huge amount of time that would be necessary to complete such a complicated multiple regression exercise. Tree models are particularly good at tasks that might in the past have been regarded as the realm of multivariate statistics (e.g. classification problems). The great virtues of tree models are as follows:
It is best to begin by looking at a tree model in action, before thinking about how it works. Here is an air pollution example that we might want to analyze as a multiple regression. We begin by using tree, then illustrate the more modern function rpart (which stands for ‘recursive partitioning’)
install.packages("tree") library(tree) Pollute <- read.table("c:\\temp\\Pollute.txt",header=T) attach(Pollute) names(Pollute)
 "Pollution" "Temp" "Industry" "Population" "Wind"  "Rain" "Wet.days"
model <- tree(Pollute) plot(model) text(model)
You follow a path from the top of the tree (called, in defiance of gravity, the root ...