abc_moran_deme: Run Multiple Moran Community Simulations With Priors.

View source: R/ABC_functions.R

abc_moran_demeR Documentation

Run Multiple Moran Community Simulations With Priors.

Description

This function runs multiple simulations of the Moran Community model by randomly generating parameters according to user input prior distributions for use in downstream ABC analyses.

Usage

abc_moran_deme(
  nsims,
  t,
  priors,
  x.max = NULL,
  y.max = NULL,
  spatial = NULL,
  eqpop = FALSE,
  eqmig = TRUE,
  outgens = NULL
)

Arguments

nsims

Numeric, The number of simulations to run.

t

Numeric, the number of generations to run for each simulation.

priors

Priors object specifying the priors to use for simulations. See make_priors.

x.max, y.max

Numeric, maximum spatial extent in x or y direction for site placement if randomly generating spatial data.

spatial

Two column Numeric matrix or Distance object specifying spatial arrangement of communities.

eqpop

Logical, if TRUE all community sizes are the same within a simulation, if FALSE each community is randomly given a community size each simulation.

eqmig

Logical, if TRUE all species will have the same migration matrix, if FALSE each species will recieve it's own migration matrix each simulation according to priors file settings

outgens

Integer, vector giving the generations for which metacommunities should be output

Details

This function is used to run the Moran Community model simulation multiple times in preparation for Approximate Bayesian Analysis (ABC). Users specify prior distributions for community size, selection coefficients, frequency dependence, and migration parameters in a priors object. From this information, parameter values are randomly drawn according to the prior distributions and simulations are run from these parameter values.

Value

If all communities have the same size, then returns a list with a list of final metacommunity matrices for each simulation, a list of selection matrices used for each simulation, a matrix with frequency dependence parameters for each species (columns are species and rows are simulation runs), and a dataframe with the parameters used for each simulation (each row corresponds to one simulation). If communities are allowed to have different sizes, then the list also contains a matrix containing the community sizes for each community in each simulation.

Examples


testpriors <- make_priors(5, 5)
xy <- random_points(5, 100, 100)

testpriors$jdist <- 1
testpriors$jparams <- c(100, 200)
testpriors$seldist <- 2
testpriors$selparams <- c(.5, .1)
testpriors$fddist <- 1
testpriors$fdparams <- c(-.5, -.2)
testpriors$migdist <- 1
testpriors$migdistparams <- c(10, 50)
testpriors$migprobdist <- 1
testpriors$migprobparams <- c(.1, .2)

abc_moran_deme(5, 5, testpriors, eqpop = FALSE, spatial = xy)


trevorjwilli/CommSimABCR documentation built on Feb. 4, 2025, 1:22 a.m.