# NOT RUN {
data("Univranks")
tree <- ranktree(Univranks$rankings,Univranks$predictors,num=50)
# }
# NOT RUN {
data(Irish)
#build the tree with default options
tree <- ranktree(Irish$rankings,Irish$predictors)
#plot the tree
plot(tree,dispclass=TRUE)
#visualize information
summary(tree)
#get information about the paths leading to terminal nodes (all the paths)
infopaths <- treepaths(tree)
#the terminal nodes
infopaths$leaves
#sample size within each terminal node
infopaths$size
#visualize the path of the second leave (terminal node number 8)
infopaths$paths[[2]]
#alternatively
nodepath(termnode=8,tree)
set.seed(132) #for reproducibility
#validation of the tree via v-fold cross-validation (default value of V=5)
vtree <- validatetree(tree,method="cv")
#extract the "best" tree
dtree <- getsubtree(tree,vtree$best_tau)
summary(dtree)
#plot the validated tree
plot(dtree,dispclass=TRUE)
#predicted rankings
rankfit <- predict(dtree,newx=Irish$predictors)
#fit of rankings
rankfit$rankings
#fit in terms of orderings
rankfit$orderings
#all info about the fit (id og the leaf, predictor values, and fit)
rankfit$orderings
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab