Hi all,
I am trying to extrapolate my species distribution model generated using randomForest to past and future climate scenarios. Using the predict function is not working for a raster stack that was NOT used to fit the model. It gives me an error message saying that my raster stack and my variables are not of the same size. I think the predict function might not be the best way to extrapolate my model, but I don't know which function I would use for extrapolating my model in time.

My script looks more or less like this:

# fitting Random Forest SDM model with current climate data

files <- list.files(path="./WorldClim/0k", pattern='asc', full.names=TRUE)
predictors <-stack(files)
pres <- read.csv('pres_H_lundii.csv')
backgr <- randomPoints(predictors, 500)
presclim <- extract(predictors, pres)
absclim <- extract(predictors, backgr)
presabs <- c(rep(1, nrow(presclim)), rep(0, nrow(absclim)))
sdm_data <- data.frame(cbind(presabs, rbind(presclim, absclim)))
model <- factor(presabs) ~ alt + bio3 + bio4 + bio7 + bio10 + bio11 + bio14 + bio15 + bio16 + bio17
RF <- randomForest(model, data=sdm_data)

# extrapolating to past scenario 6kya

files_6k <- list.files(path="./WorldClim/6k", pattern='asc', full.names=TRUE)
predictors_6k <-stack(files_6k)
pred <- predict(predictors_6k, RF, type="response", filename = "0k_results.asc", format = "ascii", 
+ progress='window', overwrite=TRUE)


Any help on this would be much appreciated!
Thanks,

----------------------
Mariana Vasconcellos
The University of Texas at Austin




	[[alternative HTML version deleted]]

