Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables contribution and mapping of model predictions using presence-only data #14

Open
flopesdematos opened this issue Jan 12, 2022 · 1 comment

Comments

@flopesdematos
Copy link

flopesdematos commented Jan 12, 2022

Dear Babak,

I'm trying to extract the variables importance and map the model prediction of models fitted using presence-only. However, the following errors pop-up:

  • for the getVarImp() function -> Error in o[[1]] : subscript out of bounds
  • for the predict() function -> Error in .generateWLP(x = object, newdata = newdata, w = w, species = species, : the data does not contain some or all of the variables that the model needs...

I include a reproducible example:

library(sdm)

file <- system.file("external/po_spatial_points.shp", package="sdm") # path to a shapefile

po <- shapefile(file)
class(po) 

head(po) 

path <- system.file("external", package="sdm") 
lst <- list.files(path=path,pattern='asc$',full.names = T) 


preds <- stack(lst) # making a raster object


d <- sdmData(formula=sp4~., train=po, predictors=preds)

d

m <- sdm(sp4~., data=d, methods=c("bioclim","domain"),
          replication='sub', test.percent=30, n=10)

getModelInfo(m)

getVarImp(m) 

p1 <- predict(m, newdata=preds)

There is an easy fix for this issue?

Thank you!

@babaknaimi
Copy link
Owner

Hi,

I understand that the methods you selected are presence-only, but it would currently be better to generate background as well, because they would be needed for model evaluations, so adding bg to sdmData would fix the issue.

d <- sdmData(formula=sp4~., train=po, predictors=preds,bg=list(n=100))

Hope this helps,
Babak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants