I want to compare CART and CHAID algorithm, I choose rpart (cart algorithm) and party (chaid algorithm) to see the difference between them. My data is about blood pressure :
The party function returns me :
library(party)
# par <- ctree_control(minsplit=20, minbucket=10)
arbre <- ctree(bpress_level ~ ., data = df)
arbre
plot(arbre)
The rpart package returns me :
library(rpart)
fit <- rpart(bpress_level ~ .,
method="class", data=df)
printcp(fit) # display the results
plotcp(fit)
plot(fit, uniform=TRUE,
main="Classification Tree for pressure level")
text(fit, use.n=TRUE, all=TRUE, cex=.8)
I don't inderstand why the tree decisin are so different, is it normal ? Why for party package the algorithm ignores like smoke, stress, gender .... Thank you in advance.
First of all ctree ([party]) doesn't uses CHAID algorithm. It is very much similar to CHAID but not CHAID. CHAID can only be applied when data is categorical in nature.
Of course, there are numerous other recursive partitioning algorithms that are more or less similar to CHAID which can deal with mixed data types. For example, the CTree algorithm (conditional inference trees) is also based on significance tests and is available in ctree() in package partykit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With