kuenm_cal | R Documentation |
kuenm_cal creates and executes a batch file (bash for Unix) for generating candidate models in Maxent to test multiple parameter combinations, including distinct regularization multiplier values, various feature classes, and different sets of environmental variables.
kuenm_cal(occ.joint, occ.tra, M.var.dir, batch, out.dir, max.memory = 1000,
reg.mult, f.clas = "all", args = NULL, maxent.path,
wait = TRUE, run = TRUE)
occ.joint |
(character) is the name of the csv file with all the occurrences; columns must be: species, longitude, latitude. |
occ.tra |
(character) is the name of the csv file with the calibration occurrences; columns equal to occ.joint. |
M.var.dir |
(character) is the name of the folder containing other folders with different sets of environmental variables. |
batch |
(character) name of the batch file (bash for Unix) with the code to create all candidate models. |
out.dir |
(character) name of the folder that will contain all calibration model subfolders. |
max.memory |
(numeric) maximum memory (in megabytes) to be used by maxent while creating the models. Default = 1000. |
reg.mult |
(numeric vector) regularization multiplier(s) to be evaluated. |
f.clas |
(character) feature clases can be selected from five different combination sets or manually. Combination sets are: "all", "basic", "no.t.h", "no.h", and "no.t". Default = "all". basic = "l", "lq", "lqp", "lqpt", "lqpth". Combinations "no.t.h", "no.h", and "no.t", exclude t and/or h. See details for all the available potential combinations of feature classes. |
args |
(character) additional arguments that can be passed to Maxent. See the Maxent help for more information on how to write these arguments, default = NULL. Note that some arguments cannot be changed here because they are part of the parameters of the function already (e.g., "betamultiplier" or "plots"). See details for other options. |
maxent.path |
(character) the path were the maxent.jar file is in your computer. |
wait |
(logical) if TRUE R will wait until all the Maxent models are created. If FALSE the process of model creation will be performed separately and R could be used at the same time. This may be useful for evaluating candidate models parallelly. Default = TRUE. |
run |
(logical) if TRUE the batch runs after its creation, if FALSE it will only be created and its runnig would be manual, default = TRUE. |
Java needs to be installed in the computer and maxent.jar needs to be in a known place in the computer. Java can be obtained from https://java.com/es/download/manual.jsp. Users of Linux and Mac need the entire Java Development Kit available in http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Maxent can be downloaded from https://biodiversityinformatics.amnh.org/open_source/maxent/
Below all potential combinations of feature classes are shown. Manual selection can be done by creating a vector of one or more of the combinations of this list. l = linear, q = quadratic, p = product, t = threshold, and h = hinge. "l", "q", "p", "t", "h", "lq", "lp", "lt", "lh", "qp", "qt", "qh", "pt", "ph", "th", "lqp", "lqt", "lqh", "lpt", "lph", "lth", "qpt", "qph", "qth", "pth", "lqpt", "lqph", "lqth", "lpth", "qpth", and "lqpth".
The way to include further arguments is as follows: args = "biasfile=COMPLETE_PATH\bias.asc biastype=3" in windows, or args = "biasfile=COMPLETE_PATH/bias.asc biastype=3" in Unix based systems. If the path contains spaces the way to write it is: args = "biasfile=\"COMPLETE PATH\bias.asc\" biastype=3" in windows, or args = "biasfile=\"COMPLETE PATH/bias.asc\" biastype=3" in Unix based systems.
Other options that can be included in args are all "Flags" from the following list:
Flag | Abbrv | Type | Default | Meaning
maximumbackground | MB | integer | 10000 | If the number of background points / grid cells is larger than this number, then this number of cells is chosen randomly for background points.
togglelayertype | t | string | | Toggle continuous/categorical for environmental layers whose names begin with this prefix (default: all continuous).
biasfile | | file | | Sampling is assumed to be biased according to the sampling distribution given in this grid file. Values in this file must not be zero or negative. MaxEnt will factor out the bias. We recomend to create this file as a kernell density of geographic points representing all localities were samplings of similar organisms have been performed (multiply this layer by 1000 and round it to reduce number of decimals). IMPORTANT: A biasfile must be included with its entire path, as indicated above above.
biastype | | integer | | If biasfile is defined, this integer needs to be defined depending on the type of bias added. If the bias file is prepared as recomended, biastype=3.
writebackgroundpredictions | | boolean | FALSE | Write .csv file with predictions at background points.
maximumiterations | m | integer | 500 | Stop training after this many iterations of the optimization algorithm.
convergencethreshold | c | double | 0.00001 | Stop training when the drop in log loss per iteration drops below this number.
threads | | integer | 1 | Number of processor threads to use. Matching this number to the number of cores on your computer speeds up some operations, especially variable jackknifing.
logfile | | string | maxent.log | File name to be used for writing debugging information about a run in output directory.
cache | | boolean | TRUE | Make a .mxe cached version of ascii files, for faster access.
defaultprevalence | | double | 0.5 | Default prevalence of the species: probability of presence at ordinary occurrence points. See Elith et al., Diversity and Distributions, 2011 for details.
Other more advanced arguments are (use these ones only if you understand them completely):
lq2lqptthreshold | | integer | 80 | Number of samples at which product and threshold features start being used.
l2lqthreshold | | integer | 10 | Number of samples at which quadratic features start being used.
hingethreshold | | integer | 15 | Number of samples at which hinge features start being used.
beta_threshold | | double | -1 | Regularization parameter to be applied to all threshold features; negative value enables automatic setting.
beta_categorical | | double | -1 | Regularization parameter to be applied to all categorical features; negative value enables automatic setting.
beta_lqp | | double | -1 | Regularization parameter to be applied to all linear, quadratic and product features; negative value enables automatic setting.
beta_hinge | | double | -1 | Regularization parameter to be applied to all hinge features; negative value enables automatic setting.
A folder named out.dir with all the subfolders to save Maxent results when running the .bat file (.sh for Unix). A .bat file (.sh for Unix) containing the java codes to run the calibration models, it will run auotmatically or on some computers a dialog box will ask if running is allowed.
# To replicate this example dowload the data from the following link:
# https://kuscholarworks.ku.edu/bitstream/handle/1808/26376/ku.enm_example_data.zip?sequence=3&isAllowed=y
# Variables with information to be used as arguments.
occ_joint <- "aame_joint.csv"
occ_tra <- "aame_train.csv"
M_var_dir <- "M_variables"
batch_cal <- "Candidate_models"
out_dir <- "Candidate_Models"
reg_mult <- c(seq(0.1, 1, 0.1), seq(2, 6, 1), 8, 10)
f_clas <- "all"
maxent_path <- "YOUR/DIRECTORY/WITH/MAXENT"
wait <- FALSE
run <- TRUE
kuenm_cal(occ.joint = occ_joint, occ.tra = occ_tra, M.var.dir = M_var_dir, batch = batch_cal,
out.dir = out_dir, reg.mult = reg_mult, f.clas = f_clas, maxent.path = maxent_path,
wait = wait, run = run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.