sylvainschmitt / SSDM

Stacked Species Distribution Modelling R package
Other
41 stars 17 forks source link

Maxent problem in stacked.SDM #90

Closed preuss96 closed 4 years ago

preuss96 commented 4 years ago

Hello

I need to project the maxent model to the future with the "project" function.

error

I am finding some problems even after saw the issues on github.

I am doing a stacked.SDM from maxent and I tried to use your function to change maxent with get_model:

setMethod("get_model", "MAXENT.SDM", function(obj, Env, ...) { factors <- c() for (i in 4:length(names(obj@data))) { if (is.factor(obj@data[, i])) { factors <- c(factors, names(obj@data)[i]) } } model <- maxent(x = Env, p = obj@data[which(obj@data$Presence == 1), 1:2], a = obj@data[which(obj@data$Presence == 0), 1:2], factors = factors) return(model) })

However I am finding this error:

Error in conformMethod(signature, mnames, fnames, f, fdef, definition) : in method for ‘get_model’ with signature ‘x="MAXENT.SDM"’: formal arguments (x = "MAXENT.SDM", ... = "MAXENT.SDM") omitted in the method definition cannot be in the signature

My code is:

SSDM <- stack_modelling("MAXENT", Occ, Env1, Xcol = "longitude", Ycol = "latitude", Pcol = NULL, Spcol = "Especie", rep = 2, name = NULL, save = TRUE, path = 'C:/Users/Gabriel/Desktop/Dissertação/Bats/Dissertation/model_atual', PA = NULL, cv = "holdout", cv.param = c(0.75, 1), thresh = 100, axes.metric = "Pearson", uncertainty = TRUE, tmp = TRUE, ensemble.metric = c("AUC"), ensemble.thresh = c(0.5), weight = TRUE, method = "pSSDM", metric = "SES", range = NULL, endemism = c("WEI", "Binary"), verbose = TRUE, cores=7)

I try to project like this:

project(SSDM, variaveis.2070.245) ## variaveis.270.245 are my environmental variables to the future).

Error in maxent(x = Env, p = obj@data[which(obj@data$Presence == 1), 1:2], : argument "Env" is missing, with no default

May you help me, please?

sylvainschmitt commented 4 years ago

Update to the last version of SSDM on GitHub and use stack_modelling and project functions.

preuss96 commented 4 years ago

I updated that and now I cant run the stack_modelling, even with 76 species, which had successfully predict with the other SSDM version.

I got this error:

Error in stack_modelling("MAXENT", Occ, Env1, Xcol = "longitude", Ycol = "latitude", : Less than two species models were retained, you should lower the ensemble threshold value (ensemble.thresh parameter).

preuss96 commented 4 years ago

The threshold is already in 0.1 and this error continues

preuss96 commented 4 years ago

Here is a minimal example with package data:

SSDM <- stack_modelling('MAXENT', Occurrences, Env, rep = 1, Xcol = 'LONGITUDE', Ycol = 'LATITUDE', Spcol = 'SPECIES', ensemble.thresh = 0.3,verbose = TRUE, cores = 7)

Error in stack_modelling("MAXENT", Occurrences, Env, rep = 1, Xcol = "LONGITUDE", : Less than two species models were retained, you should lower the ensemble threshold value (ensemble.thresh parameter).

I also tried with other algorithms without success

sylvainschmitt commented 4 years ago

Did you forgot the maxent.jar in the dismo installation ? Anyway the minimal example in the last version should work.

preuss96 commented 4 years ago

I have maxent.jar in dismo installation, and its not working.

I also tried with other algorithms. All of them presents the same error:

Error in stack_modelling("MAXENT", Occ, Env1, Xcol = "longitude", Ycol = "latitude", : Less than two species models were retained, you should lower the ensemble threshold value (ensemble.thresh parameter).

preuss96 commented 4 years ago

When I try with package data (Occurrences and Env) using GLM algorithm, I got this error:

Error in checkForRemoteErrors(val) : one node produced an error: Error in loadNamespace(name) : there is no package called 'sdm'

preuss96 commented 4 years ago

So I downloaded sdm package and the threshold error continues

sylvainschmitt commented 4 years ago

Please give a full minimal example with SSDM data and corresponding R code and console outputs in a logfile

lukasbaumbach commented 4 years ago

Could also be a parallelization issue... can you please check running with cores=0?