PaleoPopModel: R6 class representing a population model for the paleopop...

PaleoPopModelR Documentation

R6 class representing a population model for the paleopop simulator

Description

R6 class representing a spatially-explicit demographic-based population model. It extends the SimulationModel class with parameters for the paleopop_simulator. It inherits functionality for creating a nested model, whereby a nested template model with fixed parameters is maintained when a model is cloned for various sampled parameters. Also provided are extensions to the methods for checking the consistency and completeness of model parameters.

Super classes

poems::GenericClass -> poems::GenericModel -> poems::SpatialModel -> poems::SimulationModel -> PaleoPopModel

Public fields

attached

A list of dynamically attached attributes (name-value pairs).

Active bindings

simulation_function

Name (character string) or source path of the default simulation function, which takes a model as an input and returns the simulation results.

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 coordinates (WGS84) in longitude (degrees West) and latitude (degrees North).

random_seed

Number to seed the random number generation for stochasticity.

time_steps

Number of simulation time steps.

years_per_step

Number of years per time step.

populations

Number of population cells.

initial_abundance

Array (matrix) of initial abundance values at each population cell.

transition_rate

Rate (numeric) of transition between generations at each time-step.

standard_deviation

Standard deviation (numeric) for applying environmental stochasticity to transition rates.

compact_decomposition

List containing a compact transposed (Cholesky) decomposition matrix (t_decomposition_compact_matrix) and a corresponding map of population indices (t_decomposition_compact_map), as per SpatialCorrelation class attributes.

carrying_capacity

Array (or matrix) of carrying capacity values at each population cell (across time).

density_dependence

Density dependence type ("competition", "logistic", or "ceiling").

growth_rate_max

Maximum growth rate (utilized by density dependence processes).

dispersal_data

List of data frames of non-zero dispersal rates and indices for constructing a compact dispersal matrix, and optional changing rates over time, as per class DispersalGenerator dispersal_data attribute.

dispersal_target_k

Target population carrying capacity threshold for density dependent dispersal.

harvest

Boolean for utilizing harvesting.

harvest_max

Proportion harvested per year (annual time scale - not generational).

harvest_g

The "G" parameter in the harvest function.

harvest_z

The "Z" parameter in the harvest function.

harvest_max_n

Maximum density per grid cell.

human_density

Matrix of human density (fraction) ($populations rows by $time_steps columns).

abundance_threshold

Abundance threshold (that needs to be exceeded) for each population to persist.

occupancy_threshold

Threshold for the number of populations occupied (that needs to be exceeded) for all populations to persist.

results_selection

List of results selection from ("abundance", "ema", "extirpation", "harvested", "occupancy", "human_density").

attribute_aliases

A list of alternative alias names for model attributes (form: alias = "attribute") to be used with the set and get attributes methods.

template_model

Nested template model for fixed (non-sampled) attributes for shallow cloning.

sample_attributes

Vector of sample attribute names (only).

required_attributes

Vector of required attribute names (only), i.e. those needed to run a simulation.

error_messages

A vector of error messages encountered when setting model attributes.

warning_messages

A vector of warning messages encountered when setting model attributes.

Methods

Public methods

Inherited methods

Method list_consistency()

Returns a boolean to indicate if (optionally selected or all) model attributes (such as dimensions) are consistent.

Usage
PaleoPopModel$list_consistency(params = NULL)
Arguments
params

Optional array of parameter/attribute names.

Returns

List of booleans (or NAs) to indicate consistency of selected/all attributes.


Method list_completeness()

Returns a list of booleans (or NAs) for each parameter to indicate attributes that are necessary to simulate the model have been set and are consistent/valid.

Usage
PaleoPopModel$list_completeness()
Returns

List of booleans (or NAs) for each parameter to indicate to indicate completeness (and consistency).


Method clone()

The objects of this class are cloneable with this method.

Usage
PaleoPopModel$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

library(poems)
library(raster)
# Ring Island example region
coordinates <- data.frame(x = rep(seq(-178.02, -178.06, -0.01), 5),
                          y = rep(seq(19.02, 19.06, 0.01), each = 5))
template_raster <- Region$new(coordinates = coordinates)$region_raster # full extent
sealevel_raster <- template_raster
template_raster[][c(7:9, 12:14, 17:19)] <- NA # make Ring Island
sealevel_raster[][c(7:9, 12:14, 17:18)] <- NA
raster_stack <- raster::stack(x = append(replicate(9, template_raster), sealevel_raster))
region <- PaleoRegion$new(template_raster = raster_stack)

# Model template
template_model <- PaleoPopModel$new(simulation_function = "paleopop_simulator", # the default
                                    region = region, years_per_step = 25, # default: 1 year
                                    time_steps = 10)
template_model$required_attributes # more requirements than the SimulationModel object in poems
template_model$is_complete() # the required attributes have not been filled in
template_model#is_consistent() # however, the attributes that are filled in are consistent


paleopop documentation built on Oct. 11, 2023, 5:14 p.m.