kuenm_modvar: Prediction variance coming from distinct sources in ENMs

View source: R/kuenm_modvar.R

kuenm_modvarR Documentation

Prediction variance coming from distinct sources in ENMs

Description

kuenm_modvar calculates the variance in model predictions distinguishing the source from which this is coming. In this version potential sources of variation are: replicates, parameterizations, general circulation models (GCMs), and emission scenarios. The last two considered only when projections in time are performed.

Usage

kuenm_modvar(sp.name, fmod.dir, is.swd, replicated, format = "asc", project,
             current, time.periods, emi.scenarios, clim.models, ext.type,
             split.length = 100, out.dir = "Variation_from_sources")

Arguments

sp.name

(character) name of the species. This name must be the one that appears as part of the raster file of each model replicate. If results are from Maxent, this is the name that is in the first column of the csv containing species occurrence data (species) but excluding spaces.

fmod.dir

(character) the name of the folder in which final models are (i.e., the output folder after using the kuenm_mod) function.

is.swd

(logical) whether model calibration and final models were produced using SWD format.

replicated

(logical) whether or not final models were created performing replicates.

format

(character) format of model raster files. Options are: "asc" or "tif"; default = "asc".

project

(logical) if TRUE, assumes that models were projected to other scenarios. These scenarios can be current (projections in space), and/or future or past (projections in time).

current

(character) pattern to look for when defining which is the scenario of current projection. If not defined variance maps will be produced for the area of calibration, and if #' any of time.periods, clim.models, or emi.scenarios exist, variance maps will be produced for these layers as well.

time.periods

(character or numeric) pattern to be searched when identifying models from distinct time projections. If not defined it is assumed that one time period was considered.

emi.scenarios

(character) pattern to be searched for identifying distinct emission scenarios (e.g., RCP numbers). If not defined, it is assumed that only one emission scenario was used. Therefore, this source of variation will not be considered.

clim.models

(character) names that identify climatic models used to project ENMs. If not defined it is assumed that only one climate model was used. Therefore, this source of variation will not be considered.

ext.type

(character) valid if project = TRUE, vector of pattern(s) to be searched in the folders inside fmod.dir that identify the extrapolation type(s) of model projections. This pattern(s) need to be clearly distinguishable from the rest of the name of the model folder name. For instance, capital letter can be used to separate this pattern from the rest of the folder name (e.g., "EC" will be the patter that denotes extrapolation and clamping in the folder named "M_0.1_F_l_set1_EC").

split.length

(numeric) limit number of models to be processed at the time. Bigger numbers would demand more from the RAM. Default = 100.

out.dir

(character) name of the output directory to be created in which subdirectories containing raster layers of model variance will be written. Default = "Variation_from_sources".

Details

If any of the potential sources of variation is equal to one (e.g., only one parameter, or only one climate model), this source of variation will not be considered.

Users must be specific when defining the patterns that the function will search for. This patterns must be part of the model (raster layer) names so the function can locate each file without problems. This function uses this system of work to avoid high demands of the RAM while perfomring these analyses.

Value

Folders named Variation or Variation_("pattern" depending on the ext.type) containing subdirectories named according to where/when models were projected. Inside this folder, raster layers of variance coming from distinct sources. All results will be written inside out.dir.

Examples

# Models should be ready before starting these analyses, for an example of
# how to create them see https://github.com/marlonecobos/kuenm

# Arguments
sp_name <- "sp1"
fmod_dir <- "Final_Models"
is_swd <- FALSE
rep <- TRUE
format <- "asc"
project <- TRUE
curr <- "current"
emi_scenarios <- c("RCP4.5", "RCP8.5")
c_mods <- c("GCM1", "GCM2")
ext_type <- c("E", "EC", "NE")
split <- 100
out_dir2 <- "Variation_from_sources"

kuenm_modvar(sp.name = sp_name, fmod.dir = fmod_dir, is.swd = is_swd,
             replicated = rep, format = format, project = project,
             current = curr, emi.scenarios = emi_scenarios,
             clim.models = c_mods, ext.type = ext_type, split.length = split,
             out.dir = out_dir2)

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