I am looking for solution to problematic response variable data structure in Bart Machine Modeling

30 Views Asked by At

so I have an excel dataset, which I have attached. And I am trying to train a Bart model, to assess predictors of covid-19 incidence. To do this I ran the following code, after making some transformations on the excel data variables.

The model is initializing and then an error is printed as follows "Error in build_bart_machine(X,y): Your response must be either numeric, an interger or a factor with two levels."

This is despite me having transformed the variables into numerics and factors and removed all cases with missing values.

Been looking for a solution and I can seem to find any.

Your help is greatly needed and will be greatly appreciated.

   Data$ActualIncidence <- as.numeric(Data$ActualIncidence)
   #training bart model 1
   set.seed(12345)
   RSample <- sample(1:nrow(Data), 2000)
   TrainSample <- Data[-RSample,]
   TestSample <- Data[RSample,]

   X <- TrainSample[, c('Age','Gender','Pop','PopDensity','SES','Municipal','Employed')]
   y <- TrainSample[,"ActualIncidence"]

   BartModel1 <- bartMachine(X,y, num_trees = 50)
0

There are 0 best solutions below