I have the following function:
brt <- gbm.step(data = train,
gbm.x = 5:9, # column indices for covariates
gbm.y = 4, # column index for response (presence-absence)
family = "bernoulli",
tree.complexity = ifelse(prNum < 50, 1, 5),
learning.rate = 0.001,
bag.fraction = 0.75,
max.trees = ifelse(s == "Jacaranda.puberula" | s == "Cestrum.intermedium", 50, 10000),
n.trees = 50,
n.folds = 5, # 5-fold cross-validation
silent = TRUE) # avoid printing the cv results
I'm trying to run the abovementioned function but they way I'm using the ifelse inside the max.trees argument returns an error. Is that the right way of coding it? What I'm trying to accomplish is simply using 50, instead of 10000 max.trees for those two species: Jacaranda.puberula or Cestrum.intermedium. Just to inform, the object s comes from another vector called sp, which is a list of species names. Each s is a different species that I'm looping in this function.
Is the problem on the way I am writing the statement or in the fact that I'm using OR as the logical?
EDIT: I think that may be something related to the function. I re-runned the analysis here and it returns:
Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "NULL"
In addition: There were 50 or more warnings (use warnings() to see the first 50)
