library(terra)
# Load species occurrences (6 species available)
data(DataSpecies)
head(DataSpecies)
# Select the name of the studied species
myRespName <- 'GuloGulo'
# Get corresponding presence/absence data
myResp <- as.numeric(DataSpecies[, myRespName])
# Get corresponding XY coordinates
myRespXY <- DataSpecies[, c('X_WGS84', 'Y_WGS84')]
# Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12)
data(bioclim_current)
myExpl <- terra::rast(bioclim_current)
# \dontshow{
myExtent <- terra::ext(0,30,45,70)
myExpl <- terra::crop(myExpl, myExtent)
# }
# --------------------------------------------------------------- #
# Format Data with true absences
myBiomodData <- BIOMOD_FormatingData(resp.var = myResp,
expl.var = myExpl,
resp.xy = myRespXY,
resp.name = myRespName)
# --------------------------------------------------------------- #
### Duration for turing all models sequential with default settings
### on 3.4 GHz processor: approx. 45 min tuning all models in parallel
### (on 8 cores) using foreach loops runs much faster: approx. 14 min
if (FALSE) {
# library(doParallel)
# cl <- makeCluster(8)
# doParallel::registerDoParallel(cl)
time.seq <- system.time(
bm.tuning <- BIOMOD_Tuning(bm.format = myBiomodData, ME.env = myExpl, ME.n.bg = ncell(myExpl))
)
# stopCluster(cl)
plot(bm.tuning$tune.CTA.rpart)
plot(bm.tuning$tune.CTA.rpart2)
plot(bm.tuning$tune.RF)
plot(bm.tuning$tune.ANN)
plot(bm.tuning$tune.MARS)
plot(bm.tuning$tune.FDA)
plot(bm.tuning$tune.GBM)
plot(bm.tuning$tune.GAM)
# Get tuned modeling options
myBiomodOptions <- bm.tuning$models.options
}
Run the code above in your browser using DataLab