DispersalGenerator | R Documentation |
R6
class functionality for modeling dispersals within a
spatially-explicit population model. The model calculates dispersal rates between
population model cells using a distance-based function: p*exp(-distance/b)
for distance <= r (otherwise zero), where p (proportion), b
(breadth or average distance) and r (range or maximum distance) are
configurable model attributes. The dispersal rates are adjusted to limit
emigration from each cell to p. The model also generates data for
constructing compacted dispersal matrices. It dynamically generates attributes
defined as outputs (default: dispersal_data) given sampled
inputs (default: dispersal_proportion and
dispersal_max_distance). An optional DispersalFriction
object
may be utilized to modify (equivalent) distances given a (spatio-temporal) frictional
landscape. When this landscape includes temporal changes, the generated
dispersal_data will be a temporal list of changing dispersal rates.
poems::GenericClass
-> poems::GenericModel
-> poems::SpatialModel
-> poems::Generator
-> DispersalGenerator
attached
A list of dynamically attached attributes (name-value pairs).
model_attributes
A vector of model attribute names.
region
A Region
(or inherited class) object specifying the study region.
coordinates
Data frame (or matrix) of X-Y population (WGS84) coordinates in longitude (degrees West) and latitude (degrees North) (get and set), or distance-based coordinates dynamically returned by region raster (get only).
description
A brief description of what the generator generates.
inputs
An array of input attribute names for the generator.
outputs
An array of output attribute names for the generator.
file_templates
A nested list of file template attributes.
function_templates
A nested list of function template attributes.
distribution_templates
A list of distribution template attributes.
uses_correlations
A boolean to indicate that a SpatialCorrelation
(or inherited class) object is used for generating correlated random deviates.
spatial_correlation
A SpatialCorrelation
(or inherited class) object for generating correlated random deviates.
temporal_correlation
Absolute correlation coefficient between simulation time steps for all grid cells (0-1; default = 1).
time_steps
Number of simulation time steps.
decimals
Number of decimal places applied to generated data outputs (default: NULL = no rounding).
occupancy_mask
Optional binary mask array (matrix), data frame, or raster (stack) for generated (time-series) data outputs.
template_attached
A list of template-nested dynamically attached model attributes that are maintained via shallow or new cloning.
dispersal_friction
A DispersalFriction
(or inherited class) object for dispersal distance multiplier data.
distance_classes
Vector of distance interval boundaries for calculating discrete dispersal rates.
max_distance_classes
The maximum number of distance classes when they are calculated automatically via the maximum distance (default: 1000).
distance_scale
Scale of distance values in meters (default = 1). Usage: set to 1 for values in meters, or to 1000 for values in kilometers.
distance_data
Data frame of distance classes including indices for the construction of compact matrices (columns: target_pop, source_pop, compact_row, distance_class).
dispersal_function_data
Data frame of discrete dispersal function values. Optional first column may provide distance intervals (non-inclusive lower bounds).
dispersal_proportion
Dispersal function: p*exp(-distance/b) p parameter. Represents the proportion and limit of dispersers between model cells.
dispersal_breadth
Dispersal function: p*exp(-distance/b) b parameter. Represents the breadth of the dispersal between model cells. Typically estimated via average migration distance.
dispersal_max_distance
Dispersal maximum distance or range (r) parameter limits the use of the dispersal function: p*exp(-distance/b). The function is utilized when distance <= r otherwise the dispersal rate is set to zero.
dispersal_index
Sampled index for the dispersal function data frame (to look-up dispersal function parameters).
dispersal_matrix
Dispersal matrix calculated via dispersal function.
dispersal_data
Data frame of non-zero dispersal rates including indices for the construction of compact matrices (columns: target_pop, source_pop, emigrant_row, immigrant_row, dispersal_rate).
attribute_aliases
A list of alternative alias names for model attributes (form: alias = "attribute"
) to be used with the set and get attributes methods.
generative_template
A nested DispersalTemplate
(or inherited class) object for model attributes that are maintained via shallow or new cloning.
generative_requirements
A list of attribute names and the template setting ("file", "function", or "default") that is required to generate their values.
error_messages
A vector of error messages encountered when setting model attributes.
warning_messages
A vector of warning messages encountered when setting model attributes.
poems::GenericModel$get_attribute()
poems::GenericModel$get_attribute_aliases()
poems::GenericModel$get_attribute_names()
poems::GenericModel$set_attributes()
poems::Generator$add_distribution_template()
poems::Generator$add_file_template()
poems::Generator$add_function_template()
poems::Generator$add_generative_requirements()
poems::Generator$generate()
poems::Generator$get_attributes()
poems::Generator$new_clone()
poems::Generator$read_file()
poems::Generator$run_function()
poems::Generator$sample_distribution()
new()
Initialization method sets the generative template and requirements, optionally the dispersal friction object, as well as any attributes passed via a params list or individually.
DispersalGenerator$new( generative_template = NULL, generative_requirements = NULL, dispersal_friction = NULL, attribute_aliases = NULL, ... )
generative_template
Optional nested object for generative attributes that need to be maintained when a new clone object is generated for a sample simulation (usually a ).
generative_requirements
Optional list of attribute names and the template setting ("file" or "function") that is required to generate their values (otherwise default functionality is used).
dispersal_friction
Optional DispersalFriction
(or inherited class) object for dispersal distance multiplier data.
attribute_aliases
Optional list of extra alias names for model attributes (form: alias = "attribute"
) to be used with the set and get attributes methods.
...
Parameters passed via a params list or individually.
generative_requirements_satisfied()
Returns a boolean to indicate that all the default, file and/or function template settings that are required for attribute generation are present.
DispersalGenerator$generative_requirements_satisfied()
Boolean to indicate that the required settings for attribute generation are present.
set_distance_classes()
Sets the distance classes to a sequence of values from minimum to maximum in steps of interval size.
DispersalGenerator$set_distance_classes( minimum = 1, maximum = 10, interval = 1 )
minimum
Minimum or first distance class sequence value (default = 1).
maximum
Maximum or last distance class value (default = 10).
interval
Interval or distance class sequence step size (default = 1).
calculate_distance_matrix()
Returns a matrix with the calculated distance (in meters by default) between each pair of region cells.
DispersalGenerator$calculate_distance_matrix(use_longlat = NULL)
use_longlat
Optional boolean indicating use of (WGS84) coordinates in longitude (degrees West) and latitude (degrees North).
Matrix with distances between region cells.
calculate_distance_data()
Calculates the distance class for within-range populations using the set/provided distance classes. Also calculates indices for constructing compact matrices.
DispersalGenerator$calculate_distance_data(distance_matrix = NULL, ...)
distance_matrix
Optional pre-calculated matrix with distances between population cells (population rows by population columns).
...
Parameters passed via a params list or individually.
calculate_dispersals()
Calculates, using the conditional dispersal limiting function for a simulation sample, a dispersal matrix, or a list of data frames of non-zero dispersal rates and indices for constructing a compact dispersal matrix (default), and optional changing rates over time (via DispersalFriction
object).
DispersalGenerator$calculate_dispersals(type = "data")
type
Optional type selector ("data" or "matrix") to determine whether to calculate a dispersal matrix or data frame (default).
Returns character string message when calculation prerequisites are not met (for simulation logging).
clone()
The objects of this class are cloneable with this method.
DispersalGenerator$clone(deep = FALSE)
deep
Whether to make a deep clone.
# U Island example region
coordinates <- data.frame(
x = rep(seq(177.01, 177.05, 0.01), 5),
y = rep(seq(-18.01, -18.05, -0.01), each = 5)
)
template_raster <- Region$new(coordinates = coordinates)$region_raster # full extent
template_raster[][-c(7, 9, 12, 14, 17:19)] <- NA # make U Island
region <- Region$new(template_raster = template_raster)
raster::plot(region$region_raster,
main = "Example region (indices)",
xlab = "Longitude (degrees)", ylab = "Latitude (degrees)",
colNA = "blue"
)
# Distance-based dispersal generator
dispersal_gen <- DispersalGenerator$new(
region = region,
dispersal_max_distance = 3000, # in m
inputs = c("dispersal_p", "dispersal_b"),
decimals = 5
)
dispersal_gen$calculate_distance_data() # pre-calculate
dispersal_gen$generate(input_values = list(
dispersal_p = 0.5,
dispersal_b = 700
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.