I am trying to understand how ctree fits/predict observations with complete missingness in all predictors. For example,
library(partykit)
airq <- subset(airquality, !is.na(Ozone))
airq <- rbind(airq,data.frame(Ozone=rnorm(50),Solar.R=NA,Wind=NA,Temp=NA,Month=NA,Day=NA))
airct <- ctree(Ozone ~ ., data = airq,control = ctree_control(majority = TRUE))
table(tail(predict(airct,type="node"),50))
The last 50 rows of airq
are missing all predictors, and from reading the documentation, I get the impressions that with majority=TRUE
it will just follow the majority, meaning they should all go into the same node with no variation at all. And yet I get a distribution of prediction for them.
So
- is my understanding of how
majority=TRUE
works correct? - How is ctree fitting/predicting the rows that doesn't have any observed predictors?
by the way, I tried tracing the code to see how the majority
argument is used and see that line #104
in partykit:::.cnode
has:
prob <- numeric(0) + 1L:length(prob) %in% which.max(prob)
which look rather strange to me as the result will always be numeric(0)
.