I'm pretty new to Maxent and fairly new at R, I'm attempting to write a program in R which I can use to make SDMs for a variety of species that have presence only data (where I plan on making pseudo-absence points). I've really hit a speedbump and I could use some help. I have been able to pull out the data and make training and test groups, as well as size the model (currently just using WorldClim data but I plan on adding more). Once I go to create the training environment, I am creating a numeric array of all NA values?
#size model and crop data
model.extent<-extent(-114,-89,25,38)
modelEnv=crop(currentEnv,model.extent)
#build test and train groups
specModl=cbind.data.frame(spec$Longitude,spec$Latitude)
fold <- kfold(specModl,k=5)
modelTest <- specModl[fold==2, ]
modelTrain <- specModl[fold!=2, ]
#build train environment
trainEnv <- extract(modelEnv, modelTrain) ## This is where I'm having trouble
#build absence vals
set.seed(0)
backGround <- randomPoints(modelEnv,1000)
absVals <- extract(modelEnv, backGround)
#make pres/abs columns
presabs <- c(rep(1, nrow(trainEnv)), rep(0, nrow(absVals)))
----------------------------------------------------------------------------------------------------------------
Does any know how I could be approaching this better? Or any resources I should follow? Also I plan on having the model fit 100 times randomly - although I'm uncertain how to include this into the code as well.