3
$\begingroup$

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
   set.seed(26)
   train=sample(1:nrow(testarbre2),nrow(testarbre2)*7/10)
   test=-train
   training_data=testarbre2[train,]
   testing_data=testarbre2[test,]
   testing_vote=vote[test]

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

    #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])
    rpart.plot(treeOptimal)

   #Prediction
   a=predict(ptitanicOptimal,testing_data2,type = "class")
   mc=table(a,testing_vote2)

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

$\endgroup$
1
  • $\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$ Sep 3, 2016 at 12:32

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Your Answer

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

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