Description Usage Arguments Details Value References See Also Examples
Fit a rtree
model
1 |
data |
inputs |
method |
defines the splitting rule, that is, 'entropy' for the entropy criterion and 'gini' for the Gini criterion. |
alpha |
determines the significance threshold by which |
cost |
defines misclassification cost of each category. It is a vector whose dimension is the same as the levels of response variable. Default value is a vector with all elements 1. |
The object rtree function produces can be used to run plot.ctree
and forecast.ctree
function.
nnd |
the total number of nodes in the tree. |
dt |
the sequence number of a left daughter node for each internal node. |
pt |
the sequence number of the parent node for any daughter node. |
spv |
the splitting variable used to split a given node. |
spvl |
the cut-off value of the splitting variable above. |
final_counts |
the table that contains the number of observations in each node. |
varcatg |
a numerical indicator for the category of each variable. Value '-1' points to the response variable, '1' to oridinal variables, an integer greater than 1 to a nominal variable with the number of levels equal to the integer. |
nodeclass |
the class membership of a terminal node which depends on the choice of the misclassification cost. |
p_value |
the p-value of the chi-square test performed at each internal node. It forms the basis to prune the offspring nodes of any internal node. More details in Recursive Partitioning and Applications [Zhang and Singer]. |
call |
the call by which this object is generated. |
learning.data |
the data that are actually used in |
Zhang, H. and Singer, B. (1999) Recursive partitioning in the health sciences. Springer Verlag.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library(macs)
set.seed(1234)
data <- data.frame(y = sample(1:3, 1000, replace = TRUE),
n = sample(1:4, 1000, replace = TRUE,
prob = c(0.1, 0.3, 0.2, 0.4)),
o1 = sample(1:50, 1000, replace = TRUE),
o2 = sample(1:30, 1000, replace = TRUE),
o3 = sample(1:10, 1000, replace = TRUE),
o4 = sample(1:60, 1000, replace = TRUE),
o5 = sample(1:20, 1000, replace = TRUE),
o6 = sample(1:40, 1000, replace = TRUE))
data[,2] <- as.factor(data[,2])
result <- rtree(data, method = "entropy", alpha = 0.01, cost = NULL)
plot(result)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.