ENMeval

1,743 views
Skip to first unread message

Maarten Hofman

unread,
Jun 8, 2015, 2:13:32 PM6/8/15
to max...@googlegroups.com
Hi all, 
I'm running Maxent from R and I am trying to get the ENMeval package to work to evaluate maxent models. 
I run regular models with maxent {dismo} using the raw output, and I want to use the models produced to calculate AICc with calc.aicc {ENMeval}
But when I want to determine the no. of parameters, it gives an error... 

> me <- maxent(envS.vifstep,p=wlp, a=bg, factors=c("weco","paef2010","lanhet"), 
 args=c("outputformat=raw","responsecurves=TRUE","replicates=10","replicatetype=subsample","randomtestpoints=25","randomseed=TRUE","writemess=TRUE","jackknife=TRUE"), path="Output/MaxEnt/")

> nparam <- get.params(me)                                            
Error in get.params(me) : no slot of name "lambdas" for this object of class "MaxEntReplicates"

I'm probably overlooking something obvious?

Jamie M. Kass

unread,
Jun 8, 2015, 2:18:21 PM6/8/15
to max...@googlegroups.com
This is likely due to the way you're using ENMeval. It is meant to be used via a single call that looks like this:
ENMevaluate(occs, preds, bg.coords=backgPts, ...)

Define all the parameters that you'd like, run it, and inspect the output table. The other functions in the package are helper functions that are called by ENMevaluate. They are not meant to be used outside of ENMevaluate. I hope this helps. If you're still having problems, post back.

Maarten Hofman

unread,
Jun 12, 2015, 11:14:39 PM6/12/15
to max...@googlegroups.com
Thanks for the response, Jamie. 
One of the reasons why I decided to just use calc.aicc is because I had another error while running ENMevaluate.

ENMevaluate(as.matrix(wlp@coords), envS.vifstep, bg.coords = as.matrix(bg), RMvalues = seq(0.5, 4, 0.5),
            fc = c("L", "LQ", "H", "LQH", "LQHP", "LQHPT"),
            categoricals = c("paef2010","lanhet","weco"), n.bg = 10000, method = "randomkfold",
            overlap = FALSE, aggregation.factor = c(2, 2),
            kfolds = 7, bin.output = FALSE, clamp = TRUE)

with the output being:
Doing random k-fold evaluation groups...
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

I figured it had to do something with the input format of the presence or background points (hence the as.matrix() calls), but changing the input format gave the same error. 

(the other reason why I wanted to use calc.aicc() was because I originally used 25% of the presence points as test data using subsampling instead of k-fold partition, and I wanted to keep the subsampling method). 


Op maandag 8 juni 2015 14:18:21 UTC-4 schreef Jamie M. Kass:

Jamie M. Kass

unread,
Jun 12, 2015, 11:26:57 PM6/12/15
to max...@googlegroups.com
So not sure what the issue is, and you could try sending me your data, or a sample of it, and I will look into the issue. Otherwise, I see that the problem in using calc.aicc is that you're inputting a "MaxEntRepliaces" object instead of a "MaxEnt" object, and perhaps the lambdas file is not where ENMevaluate expects it to be. ENMeval was not built to handle MaxEntReplicate objects. I'm not sure, but are there MaxEnt object hidden in the MaxEntReplicates object if you use the "@" command?

Ahmed El-Gabbas

unread,
Jun 13, 2015, 1:38:18 PM6/13/15
to max...@googlegroups.com
Hello Maarten,

Could you, please, provide some information about your data, e.g.:
head(as.matrix(wlp@coords))
tail(as.matrix(wlp@coords))
summary(as.data.frame(wlp@coords))

class(envS.vifstep)
names(envS.vifstep)

head(as.matrix(bg))
tail(as.matrix(bg))
summary(as.data.frame(bg))

--------------
Regards,
Ahmed ElGabbas

Maarten Hofman

unread,
Jul 3, 2015, 12:52:04 PM7/3/15
to max...@googlegroups.com
Hi Jamie, I've attached a sample set of occurrence points and a limited extent of my predictor variables.
I've looked a little bit further into it and found that it might be the specification of the categoricals in the call that causes the problem when I run ENMevaluate (see traceback() ):

> system.time(FullEval <- ENMevaluate(as.matrix(wlp@coords), envS.vifstep, bg.coords = as.matrix(bg@coords), categoricals = c("paef2010250","lanhet250","weco250"), RMvalues = seq(0.5, 4, 0.5),
+                         fc = c("L", "LQ", "H", "LQH", "LQHP", "LQHPT"), n.bg = 10000, method = "randomkfold",
+                         overlap = TRUE, kfolds = 7, bin.output = FALSE, clamp = TRUE))
Doing random k-fold evaluation groups...
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
Timing stopped at: 10.701 0.036 10.748
> traceback()
8: stop("'x' must be atomic for 'sort.list'\nHave you called 'sort' on a list?")
7: sort.list(y)
6: factor(x)
5: as.factor(pres[, categoricals])
4: as.factor(pres[, categoricals])
3: tuning(occ, env, bg.coords, occ.grp, bg.grp, method, maxent.args,
       args.lab, categoricals, aggregation.factor, kfolds, bin.output,
       clamp)
2: ENMevaluate(as.matrix(wlp@coords), envS.vifstep, bg.coords = as.matrix(bg@coords),
       categoricals = c("paef2010250", "lanhet250", "weco250"),
       RMvalues = seq(0.5, 4, 0.5), fc = c("L", "LQ", "H", "LQH",
           "LQHP", "LQHPT"), n.bg = 10000, method = "randomkfold",
       overlap = TRUE, kfolds = 7, bin.output = FALSE, clamp = TRUE)
1: system.time(FullEval <- ENMevaluate(as.matrix(wlp@coords), envS.vifstep,
       bg.coords = as.matrix(bg@coords), categoricals = c("paef2010250",
           "lanhet250", "weco250"), RMvalues = seq(0.5, 4, 0.5),
       fc = c("L", "LQ", "H", "LQH", "LQHP", "LQHPT"), n.bg = 10000,
       method = "randomkfold", overlap = TRUE, kfolds = 7, bin.output = FALSE,
       clamp = TRUE))



Does that help in trying to get it to work? 


Op zaterdag 13 juni 2015 05:26:57 UTC+2 schreef Jamie M. Kass:
ENMevalQuestion.zip

Jamie M. Kass

unread,
Jul 3, 2015, 1:36:12 PM7/3/15
to max...@googlegroups.com
So sorry to neglect this for so long. You indeed found an error in our code -- it previously did not allow multiple categorical assignments. I fixed it on the Github version, and you can download this version of the package with this command, after installing "devtools".

install_github("bobmuscarella/ENMeval@master")

Restart RStudio after you do this (assuming you're using RStudio), and the code should work. Thanks a ton for pointing this out.

--
You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/cHHKIe5GUrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.
To post to this group, send email to max...@googlegroups.com.
Visit this group at http://groups.google.com/group/maxent.
For more options, visit https://groups.google.com/d/optout.



--
-----------------------------------------------------------
Jamie Kass
PhD Student, Department of Biology
City College of New York, CUNY Graduate Center

Jamie M. Kass

unread,
Jul 3, 2015, 1:38:34 PM7/3/15
to max...@googlegroups.com
An addendum: Bob Muscarella and I will be releasing a new version of ENMeval by the end of the summer, and this edit will be included. Thus, if you just install directly from CRAN in the near future, this categoricals problem won't be an issue. Until then, please use the github master version. The new version of ENMeval will include options for parallel computing, along with a few other neat things. Stay tuned.

Jodi

unread,
Jul 6, 2015, 2:08:20 PM7/6/15
to max...@googlegroups.com
Thank you for adding parallel computing!!!

Hillary Koros

unread,
Jul 9, 2015, 1:02:19 PM7/9/15
to max...@googlegroups.com
Hi Maxent community,

I am trying to download maxent.bat but am getting this error message: java -mx512m -jar maxent.jar
@if errorlevel 1 pause


What could be the problem??

Please help

ndimhypervol

unread,
Jul 9, 2015, 1:21:51 PM7/9/15
to max...@googlegroups.com
Please tell us exactly what you're doing. Looks like you're trying to run Maxent in the command line, not download it. 

Jamie Kass
PhD Student, CCNY

Tereza

unread,
Apr 3, 2016, 6:03:02 AM4/3/16
to Maxent
Hi all,

I am too trying to calculate AICc values in ENMeval
> ENM <- ENMevaluate(SPECIES, WC30_4, bg.coords = backg, method = "randomkfold", kfolds = 2, rasterPreds = FALSE, fc = "L")
However, I get NaN values in return:
> ENM@results
  settings features  rm full.AUC  Mean.AUC      Var.AUC Mean.AUC.DIFF Var.AUC.DIFF Mean.OR10    Var.OR10 Mean.ORmin   Var.ORmin nparm aicc
1    L_0.5        L 0.5   0.9025 0.8322143 1.339286e-03     0.1007500 0.0019500595 0.4017857 0.001434949  0.3303571 0.003985969     3  NaN
2      L_1        L 1.0   0.9037 0.8225536 1.048172e-03     0.1076429 0.0017650500 0.3928571 0.022959184  0.3303571 0.003985969     3  NaN
3    L_1.5        L 1.5   0.9036 0.8099107 5.612149e-04     0.1139643 0.0013824857 0.3928571 0.022959184  0.3303571 0.003985969     2  NaN
4      L_2        L 2.0   0.9029 0.7965000 2.058000e-04     0.1146250 0.0012257292 0.3303571 0.003985969  0.3303571 0.003985969     2  NaN
5    L_2.5        L 2.5   0.9029 0.7664911 2.005835e-04     0.1280804 0.0006090073 0.3303571 0.003985969  0.3303571 0.003985969     2  NaN
6      L_3        L 3.0   0.9019 0.7626339 7.908348e-05     0.1303750 0.0007735714 0.4017857 0.001434949  0.3303571 0.003985969     2  NaN
7    L_3.5        L 3.5   0.9012 0.7626339 7.908348e-05     0.1303750 0.0007735714 0.4017857 0.001434949  0.3303571 0.003985969     2  NaN
8      L_4        L 4.0   0.8983 0.7626339 7.908348e-05     0.1303750 0.0007735714 0.4017857 0.001434949  0.3303571 0.003985969     2  NaN

Can you, please, advice me what is causing this? I tried different combinations of the parameters, different occurrence records and variables and I always get NaN values for my AICc.
Thanks so much for your help,
Tereza

Jamie M. Kass

unread,
Apr 4, 2016, 3:55:05 PM4/4/16
to max...@googlegroups.com
Tereza,

This is happening because you have rasterPreds set to FALSE. Set it to TRUE, and AICc can be calculated, as it needs the predictions for the calculation.

-Jamie

--
You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/cHHKIe5GUrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.
To post to this group, send email to max...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tereza

unread,
Apr 5, 2016, 6:09:51 PM4/5/16
to Maxent
Jamie,

Thanks so much! Really appreciate your help. You saved me a lot of time :)

Tereza

ramon gallego

unread,
Oct 24, 2016, 7:49:51 AM10/24/16
to Maxent
Hi all,

I'm running ENMeval with several methods for data partition. When it comes to use the "user" partition, I got the presence and background points from ARCGIS and turned them into .csv files that I imported back to R. This is the script I've used

#IMport presence data and bins
lv.new<-read.csv("lv_complete.csv")
lv.bins<-read.csv("lv_complete_bins.csv")
#import env.variables
list_asc<-list.files(path="asc",pattern=".asc", full.names=T)
list_asc_1<-vector(mode="list", length=length(list_asc))
list_asc_1<-lapply(list_asc,raster)
larval.env<-stack(list_asc_1)
#Import bg points and bins
bgpoints<-read.csv("bkg_lv_100k.csv")
bg.bins<-read.csv("bkg_lv_bin_100k.csv")

#Call ENMeval
ENMevaluate(lv.new,larval.env,method="user",occ.grp=lv.bins, bg.coords=bgpoints,bg.grp=bg.bins, n.bg=9999, overlap=T,bin.output=T, clamp=T,parallel=T, rasterPreds=T, numCores=8)

And the error I get is this

Error in rowMeans(AUC.DIFF) :
  'x' must be an array of at least two dimensions
Calls: ENMevaluate -> tuning -> rowMeans
Execution halted


ENMevaluate works fine with other settings using the same occurrence and background points, as in

ENMevaluate(lv.new,larval.env,method="jackknife",bg.coords =bgpoints, n.bg=9999,overlap=T,bin.output=T,clamp=T,parallel=T, rasterPreds = T, numCores = 8)

So I guess the problem should be in either the bins for occurrence points or bkg points

str(lv.bins)
'data.frame':   60 obs. of  1 variable:
 $ x: int  1 1 1 1 1 1 1 1 1 2 ...
str(bg.bins)
'data.frame':   9999 obs. of  1 variable:
 $ x: int  1 1 1 1 1 1 1 1 1 1 ...

Any ideas?


Jamie M. Kass

unread,
Oct 27, 2016, 9:35:15 PM10/27/16
to Maxent
Not sure what the problem is, and I can't reproduce this error. Can you try using a development version of ENMeval and rerunning the code that errored? Some bugs were fixed in this one, and we plan to release it to CRAN soon. Download the dev version with the code below (make sure you have package "devtools").

devtools::install_github("bobmuscarella/ENMeval@Edits_on_v0.2.1")

Jamie

ramon gallego

unread,
Oct 30, 2016, 4:47:05 PM10/30/16
to max...@googlegroups.com
Hi Jamie,

Thanks for your reply. I managed to find out what was wrong. The issue was with the format of occ.grp object, in my case lv.bins.  It was a df and it requires a vector. So I solved it by changing occ.grp=lv.bins to occ.grp=lv.bins$x

Thanks again. If you think someone else could face such an easy mistake, maybe include a precheck in the ENMeval function? and return an error message (expected a vector, object is a dataframe)?

Cheers!

--
You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/cHHKIe5GUrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+unsubscribe@googlegroups.com.

ndimhypervol

unread,
Oct 31, 2016, 9:17:14 AM10/31/16
to max...@googlegroups.com
Glad you got it to work, Ramon. In the dev version we have some checks like that, but a df one would be useful too. Would you be able to raise an issue on the Github page? That way we can keep track of fixes. Thanks!

Jamie Kass
PhD Candidate, CCNY
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.

Iman Momeni

unread,
Aug 18, 2017, 2:16:02 AM8/18/17
to Maxent


Dear all

I ran ENMeval several times using below script. Now I found that in the script I have forgotten to delete n.bg=10000 because I already introduced a background file with 10000 points (background_fox). Does it affect my results?


FOX <-ENMevaluate(fox, EW, bg.coords = background_fox, method = "checkerboard2", overlap = FALSE, RMvalues=c(0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10), fc = c("L","H", "LQ", "LQH", "LQHP"), bin.output = FALSE, n.bg =10000)

Iman Momeni

unread,
Aug 18, 2017, 5:24:20 AM8/18/17
to Maxent
and please inform me if you find any other errors in this.

Thank you
Iman

Jamie M. Kass

unread,
Aug 25, 2017, 5:13:04 AM8/25/17
to max...@googlegroups.com
Iman,

No, you're fine. The parameter bg.coords overrides n.bg, so if you specify bg.coords those background points will be used in the models.

Jamie

--
You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/cHHKIe5GUrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.
To post to this group, send email to max...@googlegroups.com.
Visit this group at https://groups.google.com/group/maxent.
For more options, visit https://groups.google.com/d/optout.

Iman Momeni

unread,
Aug 26, 2017, 4:40:08 AM8/26/17
to Maxent

Hi Jamie
thank you for your answer.
I have one more question about ENMeval.
I don't know if I can use "calc.niche.overlap" in ENMeval for RAW output format of MaxEnt  or any kind of changes or transformations must be applied before using them as inputs of mentioend function?

Best regards
Iman

Shawan Chowdhury

unread,
Jul 4, 2019, 11:14:15 AM7/4/19
to Maxent
Hello everyone,

I have developed distribution model using the ENMeval package. I will need the predicted map as a raster file for further work. Could any of you please tell me how can I save the predicted model as a raster layer (e.g., .tif)?

Thanks
- Shawan.

gafna jeff

unread,
Jul 4, 2019, 11:25:19 AM7/4/19
to max...@googlegroups.com
Hello Shawan,


I guess you want to save raster prediction of your model. Please use this codes. Hope you understand.

raster_prediction <- predict(model, your predictors)

writeRaster(raster_ prediction, filename="output/raster",  format="GTiff", overwrite=TRUE)

 NB in the file name you will write the path in which you want to save it. See my example

Good luck

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.

To post to this group, send email to max...@googlegroups.com.
Visit this group at https://groups.google.com/group/maxent.

Shawan Chowdhury

unread,
Jul 5, 2019, 7:22:00 AM7/5/19
to max...@googlegroups.com
Thanks a lot for your help, Gafna. A few weeks earlier, a friend of mine helped me to sort this out - just after I posted here. 
________________________
PhD Student
School of Biological Sciences
University of Queensland
Mobile: +61469842439


You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/cHHKIe5GUrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.

To post to this group, send email to max...@googlegroups.com.
Visit this group at https://groups.google.com/group/maxent.
Reply all
Reply to author
Forward
0 new messages