Hi, I'm running a regression on the insurance data. I'm doing random forest and I get the following error:
"Warning message:
In mean.default((ytest - pred.bagging)^2) :
argument is not numeric or logical: returning NA"
my code is
library(randomForest)
set.seed(888888)
xtrain<-M[1:1000,]
ytest<-M[1001:1338,]
fit.bagging<-randomForest(charges~.,data=xtrain,importance=TRUE)
fit.bagging
pred.bagging<-predict(fit.bagging,data=(-xtrain))
MSE.bagging<-mean((ytest-pred.bagging)^2)
MSE.bagging
Can anyone help me with this error?