Closed momeni133 closed 6 years ago
I haven't actually messed around much with passing arguments to Maxent that way. I'll see what I can figure out.
Wait, actually...you're passing 'factors' and 'path' to enmtools.maxent. It doesn't know what either of those things mean. Are you meaning for those to be passed on to the dismo maxent command?
Excuse me if you find my script unclear. As I mentioned before, I'm new in R and programming. The most of these arguments are about maxent tunning (feature type and regularization multiplier). I used 'factors' to define categorical variables (in this case LULC), and 'path' to define a location to save maxent outputs. I think the problem is 'replicates=10',. By removing this argument, everything works well. But unfortunately, I have to use this argument in the process. Both 'path' and 'factors' are arguments from dismo.
I notice that 'replicates' is in single quotes while the rest of your arguments are in double quotes. Have you tried changing that?
yes, the same error with double quotes. Have you ever seen this error?
I'm afraid not, but like I say I haven't really messed around with sending arguments to Maxent this way. Just out of curiosity, did you try passing that set of args to the dismo maxent function directly?
No, I didn't. I'll try this and will inform you about the result. If you don't use these arguments, could you please tell me how you set the selected feature type, regularization multiplier, and k-fold crossvalidation in enmtools package?
these arguments worked perfectly in dismo. please see the attached image
Welp, that's just weird. ENMTools should be passing my.args through untouched. I'm kind of at a loss, but I'll poke around and see what I can figure out.
Okay, I've got it. The issue here is that when you do more than one replicate through Maxent, the returned object no longer includes just one model and so the evaluate() function from dismo no longer works on it. That's what's returning the error. The question now is what to do about it.
Great! Dan, do you think this problem is easy to solve?
Well...yes and no. There's a quick and dirty version where I could just make it work if your only goal is to make maxent models; I could just have it check to see if it's a single- or multi-model object and then treat it appropriately. The real concern is that it would break everything downstream that talks to enmtools.maxent (e.g., the hypothesis tests). I'm not sure what to do about that.
For your current purpose do you just need to be able to make a model using cross-validation? If so, I could just make a branch for you and fix it there to work with replicates.
Dan, I need to calculate and compare niche breadth and overlap between different species (and also 'env.overlap' as you suggested in your paper).
Okay, then that approach wouldn't work. Is there a reason you're not using the identity.test and background.test functions for that?
Thank you for these recommendations. I'll try these two functions as well. I'll also try the perl version of enmtools to calculate niche breadth and overlap.
Hello, I'm a new user of R. I need to run maxent to provide habitat suitability layer for a species (call it pooh). whenever I use the below code, I receive an error. the error persists as long as 'replicates=10' exist in the arguments. Could you please help me to solve the problem? `library(dismo) library(rJava) library(rgdal) library(sp) library(parallel) library(ENMTools)
setwd("C:/Users/x/Desktop/maxent.r") env <- list.files(path= "C:/Users/x/Desktop/maxent.r/ascii", pattern='asc', full.names=TRUE) env_stck <- stack(env) projection(env_stck) <- CRS("+init=EPSG:2059") pooh <- enmtools.species() pooh$species.name <- "pooh" pooh$presence.points <- read.table("C:/Users/x/Desktop/maxent.r/pooh.csv", header=TRUE, sep=',')[,-1] pooh$background.points <- read.table("C:/Users/x/Desktop/maxent.r/background_carn.csv", header=TRUE, sep=',') pooh$range <- env_stck$ndvi my.args = c( "outputformat=cloglog", "jackknife=TRUE", "pictures=true", "betamultiplier=8", "replicatetype=crossvalidate", 'replicates=10', "linear=TRUE", "quadratic=TRUE", "product=TRUE", "threshold=FALSE", "hinge=TRUE", "outputfiletype=asc", "outputgrids=TRUE", "threads=7", "askoverwrite=false", "writeplotdata=TRUE", "maximumiterations=5000") outdir = "C:/Users/x/Desktop/maxent.r/output" pooh.mx <- enmtools.maxent(pooh, env_stck, factors='lulc', args= my.args, path=outdir)`
The error massage is: Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘raster’ for signature ‘"numeric"’