I have a dataset that I split into a test / train dataset. Immediately after this split, I created a logistic model with:
logModel1 = glm(Y ~ . -var1 -var2 -var3, data=train, family=binomial)
If I use this model for predictions on one set, I get no error (although, of course, not a super-useful test of my model). So I used the code below to predict on my test suite:
predictLog1 <- predict(logModel1, type="response", newdata=test)
But I get the following error:
Error in model.frame.default (terms, newdata, na.action = na.action, xlev = object $ xlevels): factor myCharVar has new levels. this is myCharVar observation, This is different ...
Here's what got me particularly confused:
- myCharVar - , .
str(test$myCharVar) str(train$myCharVar) - myCharVar .
2 SO:
" " ,
, , , , . , "-myCharVar". - , - " ", .