Predicting and calculating test mse using cforest R I'm new to the cforest package and am trying to create a cforest model to predict a new test set and calculate the model test MSE.  My data is split into d.train and d.test.  If I use randomForest, the code for predicting and determining the MSE is as follows:
set.seed(1)
rfp.data <- randomForest(d.train$Y.Weight ~ . -d.train$Y.Weight, data = d.train, mtry = sqrt(p), importance = TRUE)
yhat.rfp <- predict(rfp.data, newdata = d.test)
mean((yhat.rfp - d.test$Y.Weight)^2)
#MSE  = 9.648027

My code for cforest is similar but it doesn't look like cforest is returning a model like randomForest. 
cf.data <- cforest(d.train$Y.Weight ~. -d.train$Y.Weight, data = d.train, controls =   cforest_unbiased(mtry = p/3, ntree = 500))
yhat.cf <- predict(cf.data, newdata = d.test)


Error in model.frame.default(formula = ~(Wrist.Diam + Wrist.Girth +
  Forearm.Girth +  :    variable lengths differ (found for
  'data$Y.Weight')

I also tried using the entire dataset and then using subset for the training set and received the same error.
cf.data <- cforest(d.train$Y.Weight ~. -d.train$Y.Weight, data = d.train, controls = cforest_unbiased(mtry = p/3, ntree = 500))
yhat.cf <- predict(cf.data, newdata = d.test)


Error in model.frame.default(formula = ~(Wrist.Diam + Wrist.Girth +
  Forearm.Girth +  :    variable lengths differ (found for
  'd.train$Y.Weight')

I haven't been able to find too many examples of cforest other than the cran party pdf.  Any pointers to an example would be greatly appreciated as well.
 A: You might want to add the following to your predict function call:
, OOB=TRUE, type = "response"

so it reads:
yhat.cf <- predict(cf.data, newdata = d.test, OOB=TRUE, type = "response")

I'm basing this off of this tutorial.
A: rfnewb, I just encountered the same problem (except that I do not have continuous variables, but factors. For continuous variables, simply replace as.factor to as.numeric and it should will work - I tested it). I could not solve it with Sebee's solution, but the book is indeed a great place to start and it gave me the clue to solve this issue. 
You need two modifications: (I will paste here the variables relevant to my code, but you can easily swap them with the variables you are using. The key thing is that you need to fill the Weight column with NA and also, you do not need to specify that Weight belongs to d.train, as it is already interpreted by cforest this way)


*

*/This will resolve the error message about differing variable lengths, but if you use the test values as factors, you will get an other error saying that factor levels differ between training and test set. This error is resolved by step 2/
test$Severe <- NA
cf.data <- cforest(as.factor(Severe) ~ . -as.factor(Severe), data=train)
res <- predict(fit, test, OOB=TRUE, type="response")

*To solve the different levels of factors problem, you actually need to combine the training and test set and then split them again (this is the easiest way, see: http://trevorstephens.com/kaggle-titanic-tutorial/r-part-4-feature-engineering/)
test$Severe <- NA
combi <- rbind(train, test)
combi$Severe <- factor(combi$Severe)
train <- combi[1:63,]
test <- combi[64:106,]
cf.data <- cforest(as.factor(Severe) ~ . -as.factor(Severe), data=train)
res <- predict(fit, test, OOB=TRUE, type="response")
Hope this helps :)
