I have a model with one particular variable giving me trouble. It is a factor variable with 2 levels, 'ADT' and 'CHD'
Using the predict(model,data, predict.all=TRUE,nodes=TRUE)
, I traced things as needed.
The row in question of the model (obtained from getTree(model,1)
)
shows as seen in pic.
According to documentation, on a factor variable, the splitpoint is the decimal represenation of the binary represenation of the included factors. In case of a 2 factor variable, and the value of 2, the Binary would be '10' My factor levels, confirmed in both the data and the model itself (under xlevels) are 'ADT' and 'CHD'
So the first level would be ADT, second level would be CHD.
However, in the testdata I am predicting, this splits on the right side instead of the left, but since the SplitVar (11) is equal to 'ADT' (level #1) in the test data, it should split to the left.
Is there something I am missing?