[R-sig-eco] Univariate CART- problem with Variable Importance

Fabio Castagnino fabio.castagnino.u at gmail.com
Tue Jan 19 22:48:04 CET 2016


Hi,

I'm having trouble retrieving the variable importance from a univariate
CART: the importance of variables (got with *varImp(function)*) does not
coincide with the hierarchy of the variables in the ploted tree; they are
totally different.

I'm using *rpart* to construct the tree (also *prune *to simplify it) from
the rpart package, and then I'm using *varImp* from the caret package to
retrieve variable importance.

The command line is this (dataset = fish):


library(rpart)
library(caret)

vars  <- fish[,c(2:8)]  ## explanatory variables (categorical, read as
factors)
preys <- fish[,c(9)] ## one numeric response variable labeled Biomass

cart <- rpart(Biomass ~ Time + Station + Species + Sex + Sizeclass +
Lifestage + Maturity, data = fish, minsplit = 10, cp=0.001)
smallcart = prune(cart, cp=0.0210)

plot(smallcart, branch = 0.3, uniform=T)   ## ploting tree
text(smallcart, use.n=FALSE, pretty=TRUE)
title(main="RegTree")

varImp(smallcart)  ##retrieving variable importance

The importance of variables does not match the hierarchy in the tree.

I could very much use some help.
Thanks in advanced.

Regards,

*Fabio Castagnino Ugolotti*
*Turismo sostenible*
*Gestión de recursos marino costeros*
*Buceo libre*
Tel. +051-949171412

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list