kuenm_mod: Creation of Maxent models with selected parameters

View source: R/kuenm_mod.R

kuenm_modR Documentation

Creation of Maxent models with selected parameters

Description

kuenm_mod creates and executes a batch file (bash for Unix) for generating Maxent models using parameters previously selected with the kuenm_ceval function.

Usage

kuenm_mod(occ.joint, M.var.dir, out.eval, batch, rep.n = 10, rep.type = "Bootstrap",
          jackknife = FALSE, out.dir, max.memory = 1000, out.format = "logistic",
          project = FALSE, G.var.dir, ext.type = "all", write.mess = FALSE,
          write.clamp = FALSE, maxent.path, args = NULL, wait = TRUE, run = TRUE)

Arguments

occ.joint

(character) the csv file with all the occurrences; columns must be: species, longitude, latitude.

M.var.dir

(character) name of the forlder containing folders in which calibration environmental datasets are placed.

out.eval

(character) name of the folder where evaluation results (from calibration) were written.

batch

(character) name of the batch file (bash for Unix) with the code to create final Maxent models.

rep.n

(numeric) number of model replicates, default = 10.

rep.type

(character) the replicate type; it can be: "Crossvalidate", "Bootstrap", or "Subsample".

jackknife

(logical) if TRUE, a jackknife process is performed while runing Maxent models, default = FALSE.

out.dir

(character) name of the output directory to be created and in which all model subdirectories will be created.

max.memory

(numeric) maximum memory (in megabytes) to be used by maxent while creating the models. Default = 1000.

out.format

(character) the model output format; it can be: "raw", "logistic", "cloglog", or "cumulative".

project

(logical) if TRUE, your models will be projected to scenarios in G.var.dir, default = FALSE.

G.var.dir

(character) if project is TRUE, name of the folder containing folders in which variables of projection scenarios are placed.

ext.type

(character) if project is TRUE, is the extrapolation type of projections; can be: "all", "ext_clam", "ext", and "no_ext", default = "all". ext = free extrapolation, ext_clam = extrapolation and clamping, no_ext = no extrapolation, and all = all three of the options listed above.

write.mess

(logical) if TRUE, grids of MESS analysis results will be written, default = FALSE.

write.clamp

(logical) if TRUE, a grid of the spatial distribution of clamping will be written, default = FALSE.

maxent.path

(character) the path were the maxent.jar file is in your computer.

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., "writemess"). See details for other options.

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 running would be manual, default = TRUE.

Details

Same requirements regarding Java and maxent than in kuenm_cal.

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 definef 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.

Value

A folder named as out.dir with all the subfolders to save Maxent final model results when running the .bat file (.sh for Unix). A batch file (bash for Unix) for creating all the final Maxent models with their projections if project = TRUE.

Examples

# To run this function model evaluation and selection using the kuenm_ceval function should have been used before.
# The evaluation function generates one of the imputs needed.

# Variables with information to be used as arguments.
occ_joint <- "aame_joint.csv"
M_var_dir <- "M_variables"
out_eval <- "Calibration_results"
batch_fin <- "Final_models"
mod_dir <- "Final_Models"
rep_n <- 10
rep_type <- "Bootstrap"
jackknife <- FALSE
G_var_dir <- "G_variables"
out_format <- "logistic"
project <- TRUE
ext_type <- "all"
write_mess <- FALSE
write_clamp <- FALSE
wait1 <- FALSE
run1 <- TRUE
args <- NULL

kuenm_mod(occ.joint = occ_joint, M.var.dir = M_var_dir, out.eval = out_eval, batch = batch_fin, rep.n = rep_n,
          rep.type = rep_type, jackknife = jackknife, out.dir = mod_dir, out.format = out_format, project = project,
          G.var.dir = G_var_dir, ext.type = ext_type, write.mess = write_mess, write.clamp = write_clamp,
          maxent.path = maxent_path, args = args, wait = wait1, run = run1)

manubio13/ku.enm documentation built on Jan. 5, 2024, 5:55 a.m.