I have a database with 1200 observations and 14 variables and I'am trying to do a classification tree for my dependent nominal variable who hase 4 modality

    > table(testarbre2$Q99)

  Autres       Nahdha Ne pas voter Nidaa Tounes 
     248          351          303          298 

at firt i tried to do a multinom logistic regression but i got the mojority of my predictor variables non significant. it seems that Even with 1200 people I was trying to fit a model for which I don't have sufficient data. so i tried to do a classification tree using the package rpart from R but the problem is that the error is so high about 65% and more, and the missclassification is about 70% this is the code R that i used

   #preparation of the data

   #fitting the model
   Tree <- rpart(Q99~.,data=training_data)

    #Construction of the complete tree
  Tree <-rpart(Q99~.,data=training_data,control=rpart.control(minsplit=50,cp=0))

     #Prune the tree
    treeOptimal <- prune(Tree,cp=Tree$cptable[which.min(Tree$cptable[,4]),1])

   a=predict(ptitanicOptimal,testing_data2,type = "class")

I don't know if i missed a step or i used a wrong approach in the construction of my classification tree or the database is causing the problem

Please someone help me to understand what's wrong with my model

  • $\begingroup$ Unfortunately, asking for help w/ code, & code check, are off topic here. If you have a question about the statistical / machine learning aspects of this, please edit to clarify. Otherwise, this will probably be closed. $\endgroup$ Commented Sep 3, 2016 at 12:32

1 Answer 1


Classification trees require sometimes ten times the sample size of logistic regression, and you will be quite disappointed in the stability of the tree. Bootstrap the process for a few resamples and you will see the tree topology change quite a bit. Simplicity in single trees is more of an illusion than a reality. Trees seem simple when you select one tree from many competitors that are very difficult to choose from. In addition you have chosen a discontinuous improper accuracy scoring rule which is optimized by bogus predictions, i.e., optimized by using the wrong model for the data.

Lack of significance is not a reason to change methods. Instead consider data reduction masked to $Y$, or use penalized maximum likelihood estimation to deal with your relatively small sample size.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.