I have faced this block for a few days even with much research online, and much grateful if there are some insights in dealing this kind of warnings: " Contrasts dropped from factor x" . This occurred when I tried to use newly created decision tree model to predict on the test data using rpart package.
Following are the scripts that I have used :
contrasts(db$staffx.f) = contr.treatment(8) … create same for other categorical variables.
tree<-rpart(L2 ~ staffx+…other variables, method = “class”, data = db )
rpart.plot(tree,type = 3,tweak =1.2)
pred1 <- predict(tree,Testdata,type=“class”)
In which areas that I need to adjust ? Does this mean the model has failed?