Description

This R markdown file is in the working directory, and is designed as a short guide, to make the processes of ecological niche modeling more reproducible. The values defined for the variables used as arguments are only examples, such values can and in some cases must be changed according to the user's data and results.

Information on using this R Markdown file:

A brief tutorial for using functions of the kuenm R package can be found here. Additionally, the help of different functions can be checked to change arguments according to specific needs.


Pre-modeling and other analisis

As the quality of data is directly related to how good model results are, preparing data for modeling is a critical phase in these types of exercises. A set of functions in kuenm can help with some of the required analysis to prepare the data. These functions include: explore_var_contrib, kuenm_occsplit, kuenm_rpca, kuenm_toclosest, and kuenm_varcomb.

Many of the functions in kuenm were prepared to perform analysis presented in the following sections. However, some analysis can be performed independently with the following functions: kuenm_aicc, kuenm_mop, kuenm_omrat, and kuenm_proc.


Model calibration

Candidate models

Candidate models are a large set of candidate models created to respond to the need to test broad suites of parameter combinations, such as, distinct regularization multiplier values, various feature classes, and different sets of environmental variables. The following code calls the help page of the function kuenm_cal.

help(kuenm_cal)


The next chunk of code is for preparing the arguments to use the function. These variables should be changed according to each case.

occ_joint <- "Sp_joint.csv"
occ_tra <- "Sp_train.csv"
M_var_dir <- "M_variables"
batch_cal <- "Candidate_models"
out_dir <- "Candidate_Models"
reg_mult <- c(seq(0.1, 1, 0.1), 2:5)
f_clas <- "all"
args <- NULL
maxent_path <- "YOUR/DIRECTORY"
wait <- FALSE
run <- TRUE


The following is the code for using the function.

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, args = args, maxent.path = maxent_path, 
          wait = wait, run = run)


Evaluation and selection of best models

Evaluation is a crucial step in model calibration. This step centers on selecting candidate models and their associated parameters to identify the best models for the purposes of the study. The kuenm_ceval function evaluates candidate models based on three distinct criteria: statistical significance (based on partial ROC analyses), prediction ability (omission rates), and model fit and complexity (using AICc). The following code chunk calls the function help window.

help(kuenm_ceval)


Below, arguments for this functions will be defined. Change them as needed.

occ_test <- "Sp_test.csv"
out_eval <- "Calibration_results"
threshold <- 5
rand_percent <- 50
iterations <- 500
kept <- TRUE
selection <- "OR_AICc"
# Note, some of the variables used here as arguments were already created for the previous function


This code allows evaluating candidate models that were created previously, selecting those with best performance based on the three criteria.

cal_eval <- kuenm_ceval(path = out_dir, occ.joint = occ_joint, occ.tra = occ_tra, 
                        occ.test = occ_test, batch = batch_cal, out.eval = out_eval, 
                        threshold = threshold, rand.percent = rand_percent, 
                        iterations = iterations, kept = kept, selection = selection)


Final model(s)

Final model creation

After selecting parameterizations that produce best models, the next step is to create the final models, and if needed transfer them to other environmental data sets (e.g., to other time periods or other geographic regions). The help page of kuenm_mod is called via this code:

help(kuenm_mod)


To prepare the arguments for this function use the following chunk of code. Change variables as needed.

batch_fin <- "Final_models"
mod_dir <- "Final_Models"
rep_n <- 10
rep_type <- "Bootstrap"
jackknife <- FALSE
out_format <- "logistic"
project <- TRUE
G_var_dir <- "G_variables"
ext_type <- "all"
write_mess <- FALSE
write_clamp <- FALSE
wait1 <- FALSE
run1 <- TRUE
args <- NULL
# Again, some of the variables used as arguments were already created for the previous functions


The kuenm_mod function has the following syntax:

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)


Final model evaluation

Final models can be evaluated after being created; for this step, independent data are needed (data not used in the calibration process, ideally coming from different sources). The function help is called via this code:

help(kuenm_feval)


The next chunk of code is to prepare the arguments for using the function. These variables should be changed according to each case.

occ_ind <- "Sp_ind.csv"
replicates <- TRUE
out_feval <- "Final_Models_evaluation"
# Most of the variables used here as arguments were already created for the previous functions


The following is the code to use the function.

fin_eval <- kuenm_feval(path = mod_dir, occ.joint = occ_joint, occ.ind = occ_ind, 
                        replicates = replicates, out.eval = out_feval, 
                        threshold = threshold, rand.percent = rand_percent,
                        iterations = iterations)


Evaluation of extrapolation risks

If transfers were performed when creating final models, the MOP analysis will help to identify areas of strict extrapolation and levels of similarity between the calibration area and the region or scenario of projection. The code below will help to see the function's documentation:

help(kuenm_mmop)


Below, arguments for this functions will be defined. Change them as needed.

is_swd <- FALSE
sets_var <- c("Set3")
out_mop <- "MOP_results"
percent <- 10
paral <- FALSE # make this true to perform MOP calculations in parallel, recommended
               # only if a powerful computer is used (see function's help)
# Some of the variables used as arguments were already created for the previous functions


The kuenm_mmop function has the following syntax:

kuenm_mmop(G.var.dir = G_var_dir, M.var.dir = M_var_dir, is.swd = is_swd,
           sets.var = sets_var, out.mop = out_mop, percent = percent, 
           parallel = paral)


Post-modeling analysis

Other functions in kuenm allow to perform analyses that summarize results and help with interpretations. These functions are kuenm_modstats, kuenm_projchanges, kuenm_modvar, kuenm_hierpart, and kuenm_mopagree. More details on how to use these functions can be found here



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