Sunday, March 7, 2010

Programmer - Is there an equivalence of "anova" (for lm) to an rpart object ?

Programmer Question

When using R's rpart function, I can easily fit a model with it. for example:



# Classification Tree with rpart
library(rpart)

# grow tree
fit <- rpart(Kyphosis ~ Age + Number + Start,
method="class", data=kyphosis)

printcp(fit) # display the results
plotcp(fit)
summary(fit) # detailed summary of splits

# plot tree
plot(fit, uniform=TRUE,
main="Classification Tree for Kyphosis")
text(fit, use.n=TRUE, all=TRUE, cex=.8)


My question is -
How can I measure the "importance" of each of my three explanatory variables (Age, Number, Start) to the model?



If this was a regression model, I could have looked at p values from the "anova" F test (between lm models with and without the variable). But what is the equivalence of using "anova" on lm to an rpart object ?



(I hope I managed to make my question clear)



Thanks.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails