I am trying to do a boosted regression tree in R using gbm.step. I have 470 observations and I have 20 predictor variables. The full error I get is Error: Must subset columns with a valid subscript vector.
i Logical subscripts must match the size of the indexed input.
x Input has size 1 but subscript model.mask
has size 470.
I try to run the following code:
parrotfish.tc5.lr01 <- gbm.step(data=fd,
gbm.x = c(2:22),
gbm.y = 1,
family = "gaussian",
tree.complexity = 5,
learning.rate = 0.01,
bag.fraction = 0.5,
ZI= FALSE)
A sample dataframe would have helped a lot. With given code, you are passing a combine list of 1:22 which is a value list into the x for gbm. Change it to 2:22 which is the index of the input data frame. Try this