Setting classification rules
Let's follow a different logic to develop decision rules so that we can contrast the two results later. Let's select which shares offered the best returns. Decision or classification trees are great for this purpose. Here, R will pick from the given list of variables those that can create the most effective decision rules. Instead of building joint rules, like we did previously, first, it selects the variable using which we may create subgroups of the shares regarding their TRS. Then, for each of these subgroups, it will choose the second most effective variable and so on. The output is a kind of decision tree:
d_tree <- d[,c(3:17,19)] vars <- colnames(d_tree) m <- length(vars) tree_formula <- paste(vars[m], paste(vars[-m], collapse = " + "), sep = " ~ ") library(rpart) tree <- rpart(formula = tree_formula, data = d_tree, maxdepth = 5 ,cp = 0.001) tree <- prune(tree, cp = 0.003) par(xpd = T) plot(tree) text(tree, cex = .5, use.n = T, all = T...