explore_var_contrib: Evaluation and plot of variable contribution to Maxent models

View source: R/explore_var_contrib.R

explore_var_contribR Documentation

Evaluation and plot of variable contribution to Maxent models

Description

Exploration of variable contribution to Maxent models based on metrics of contribution percentage, permutation importance, and a jackknife analysis.

Usage

explore_var_contrib(occ, M_variables, maxent.path, reg.mult = 1,
                    f.clas = NULL, max.memory = 1000, args = NULL,
                    plot = TRUE, verbose = TRUE)

plot_contribution(contribution_list, col.cont = "gray25",
                  col.imp = "gray25", col.with = "gray15",
                  col.without = "gray65", col.all = "gray1")

Arguments

occ

a data.frame with occurrence records. If M_variables is of class "RasterStack", columns must be (in that order): Species, Longitude, Latitude. If M_variables is of class "data.frame" (SWD), columns containing the values of the environmental variables in M_variables must be added.

M_variables

RasterStack or data.frame. If RasterStack, object containing the variables to be used for modeling. If data.frame (SWD), columns must be: "background", "longitude", "latitude", and a column for each of the variables of interest. If data.frame, occ must be a data.frame.

maxent.path

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

reg.mult

(numeric vector) regularization multiplier(s) to be evaluated.

f.clas

(character) feature classes 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.

max.memory

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

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. See details for other options.

sample.size

(numeric) number of points to represent the background for the model. Default = 10000

plot

(logical) whether to produce a default plot of results.

verbose

(logical) whether to print messages; default = TRUE.

contribution_list

a list of results obtained with explore_var_contrib, or an element of a list obtained with model_var_contrib.

col.cont

color of contribution bars; default = "gray25".

col.imp

color of importance bars; default = "gray25".

col.with

color of regularized training gain bars when using individual variables; default = "gray15".

col.without

color of regularized training gain bars when using all variables except the one in question; default = "gray65".

col.all

color of line representing regularized training gain of the model using all variables; default = "gray1".

Details

All potential combinations of feature classes (l = linear, q = quadratic, p = product, t = threshold, and h = hinge) are: "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 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 list with results of variable contribution, permutation importance, and jackknife results. If plot = TRUE results are plotted as horizontal bars using plot_contribution.

Examples

# data
data("sp_joint", package = "kuenm")
occ <- data.frame(Species = "A_americanum", sp_joint)

mvars <- raster::stack(list.files(system.file("extdata", package = "kuenm"),
                                  pattern = "Mbio_", full.names = TRUE))
# analysis
var_cont <- explore_var_contrib(occ = occ, M_variables = mvars,
                                maxent.path = "C:/Maxent/3.4.1", plot = FALSE)

# plot
plot_contribution(var_cont)

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