rvalavi/blockCV

ERROR - blockCV folds in biomod2

Closed this issue · 6 comments

Hi dear,
I'm with a problem when a make a BIOMOD_Modeling using spatialBlock function in my modeling. Bellow, I put part of my script and the error message.
Please, could you help me with this problem?
Thanks,

...
library(blockCV)
library(sf)

import presence-background species data

pb_data <- st_as_sf(sdmdata, coords = c("x", "y"), crs = crs(myvar))

number of presence and background records

table(pb_data$Species)

spatial blocking by specified range with random assignment

sb <- spatialBlock(speciesData = pb_data,
species = "occ",
rasterLayer = myvar,
theRange = 300000, # size of the blocks
k = 5,
selection = "random",
iteration = 100, # find evenly dispersed folds
biomod2Format = TRUE,
xOffset = 0, # shift the blocks horizontally
yOffset = 0)

sac <- spatialAutoRange(rasterLayer = myfuturevar.2070.85,
sampleNumber = 5000,
doParallel = FALSE,
showPlots = TRUE)

DataSplitTable <- sb$biomodTable
############
##MODELING##
############

myRespName <- 'Bartramia.longicauda'
myBiomodData <- BIOMOD_FormatingData(resp.var = sdmdata[,1],
expl.var = myvar,
resp.xy = sdmdata[,2:3],
resp.name = myRespName,
na.rm = TRUE)

myBiomodData

Defining Models Options using default options.

myBiomodModelOut <- BIOMOD_Modeling(myBiomodData,
models = c("GAM"),
models.options = myBiomodOption,
NbRunEval = 10,
DataSplit = DataSplitTable,
VarImport = 0,
models.eval.meth = c('TSS', 'ROC'),
do.full.models = F,
modeling.id ="test")

Checking Models arguments...
Error in .Models.check.args(data, models, models.options, NbRunEval, DataSplit, :
objeto 'myBiomodOption' não encontrado

Hi @jopaulo77

Did you try to run the biomod funtion without the DataSplitTable option?

Hi dear,
Thank you for your contact.
Sorry, but if I try to do this I don't get imagine how I'd validate my model.
Just explain, I have 28 migratory species and I have to fit a model in present and forecast in future. Could you help me with this procedure?
Cheers,

You're welcome!
I understand you need to evaluate your models. I just want to check where the error comes from. Because the error could be from other parts of biomod such as model options etc..

Have you tried to print sb$biomodTable to see if it is creating the matrix?

Hi dear,
Yes. When a print de results, I get to access the result matrix. To generate the results in BlockCV I used presence and pseudoAbscense data, and environmental data and landcover data.

This error is probably from biomod, not blockCV. If you like, you can email me your data (or a subset of it) and I will have a look.

Hi Dear,
I have sent a sample data by rvalavi@student.unimelb.edu.au.

Thank you for your help, and maybe we can make a collaboration in this study.