marlonecobos / kuenm

kuenm: An R package for detailed calibration and construction of Maxent Ecological Niche Models.
63 stars 24 forks source link

kuenm_cal biasfile error #18

Closed mclin013 closed 3 years ago

mclin013 commented 3 years ago

Hello,

I am trying to use kuenm to run a series of models that include a bias file. The file itself was constructed as directed in the directions (it is a kernel density estimation of sampling points to mimic sampling intensity - there are no zeros or negative values in the file, the file itself is an ascii, and the values themselves have been multiplied by 1000 and rounded to the nearest 4-5 digit). When I run the command however I get an error that biasfile has not been recognized. When I run just a single line in the command line I get "Error: Initialization flags not understood". For reference the argument for the biasfile looks like this:

args=biasfile=/User/Folder/Species/biasfile_rec.asc biastype=3

I'm really not sure what could be going on but any guidance you might have would be so greatly appreciated. Thank you for creating such a wonderful package!

taprs commented 3 years ago

Have you tried adding quotes to this argument? It might be a simple R error (the interpreter should pass additional arguments to the batch script generator as a string object). Like

args="biasfile=/User/Folder/Species/biasfile_rec.asc biastype=3"

mclin013 commented 3 years ago

Yes I've tried it with quotes, without quotes... when I take away the args portion it says it can't read the bias file. Not sure if this is a maxent issue or a kuenm issue so I'm interested in whether the developer has made the process work using a bias file

taprs commented 3 years ago

kuenm worked smoothly with KDE bias file for me when I passed it as an argument like you did. Maybe you should try running Java Maxent with your bias file to check if it gets the job done... Sorry I cannot help more.

mclin013 commented 3 years ago

Okay that is very good to know - sorry to be daft but how do I go about running Java Maxent? I only know how to run it via R & the command line

taprs commented 3 years ago

The jar file used by kuenm can be launched directly from the file manager or from the command line with something like

java -mx1024m -jar /path/to/maxent/maxent.jar

it has a user-friendly interface and a bunch of tutorials here: https://biodiversityinformatics.amnh.org/open_source/maxent/

marlonecobos commented 3 years ago

Hi @mclin013, please let me know if you were able to run the models using the bias file and the Maxent UI. If that does not work it may be a problem with the file you are using, otherwise, if you share your code and data somehow, I could explore more deeply what the problem is. Let me know the Maxent version you are using as well.

@taprs, thanks for sharing your experience.

mclin013 commented 3 years ago

Thank you for all the feedback and input - the bias file initially appeared to be the issue (I couldn't run it with Java Maxent) so I tinkered with it and got it running on the Java version-- unfortunately I still couldn't make it run with kuenm. When I run an individual line of the batch file that kuenm generates I get the "Initialization flags not understood" error. However when I change the bias file command to not be an argument but rather its own stand alone command (aka biasfile="pathtobiasfile/biasfile.asc") the process runs correctly. I am using the most recent version of Maxent (3.4.4) -- I guess this is not an issue now since I can just change that wording.. thank you for all the help!

mclin013 commented 3 years ago

Hello sorry I have another question ! Now that I've gotten the models to run the bias file correctly, when I evaluate the models using kuenm_ceval the majority of calculated AICc values are NA values. Why might this be?

marlonecobos commented 3 years ago

You get NA in AIC when there are more parameters in the model than records used, which basically means the model is too complex.

I'll close this issue.

RhettRautsaw commented 2 years ago

Hi @marlonecobos,

First off, I love kuenm! Thank you for making it. However, I'm having a similar issue here where I get NAs for my AIC which causes kuenm_ceval to get stuck...unfortunately it doesn't even error out. Just stays running forever.

I have 2,139 records in Sp_joint.csv and I get NAs even for models with as few as 7 parameters.

Model","Mean_AUC_ratio","pval_pROC","Omission_rate_at_5%","AICc","delta_AICc","W_AICc","num_parameters"
"M_0.1_F_l_Set_bioc",1.12389900499483,0,0.039426523297491,NA,NA,NA,7
"M_0.1_F_l_Set_topo",1.03168511654894,0,0.0663082437275986,60695.3035096671,829.186349185577,1.78857409714549e-183,7
"M_0.1_F_l_Set_topvars",1.12717972254982,0,0.03584229390681,NA,NA,NA,10

Any idea what could be causing this?

marlonecobos commented 2 years ago

Hi, I have seen this before and sincerely still don't know what is the reason for it to happen.

When one or a few records are predicted to have raw maxent values that are so small that they become zero, AIC values become NA because of the calculation log(0). These are potential solutions I have explored before. Filter your data once more. Sometimes if you are more rigorous in selecting which data to use to model, you end up with fewer records, which means that your models are calibrated with more reliable data. Sometimes this is not an option because you don't have many records, but in your case, that won't be a problem. Try that and see what happens.

This is not an issue of kuenm, but from the entire idea of calculating AIC values for maxent models, so I am not reopening this issue.