View source: R/treeSimulatorCpp2.R
build.demographic.process | R Documentation |
A model is constructed by supplying birth rates, migration rates, and death rates. The model can be used to simulate demographic histories or as an input to coalescent simulation or likelihood calculation.
build.demographic.process(
births,
nonDemeDynamics = NA,
migrations = NA,
deaths = NA,
parameterNames = c(),
rcpp = TRUE,
sde = FALSE
)
births |
A named character vector or matrix of mathematical expressions that describe model birth rates. Names correspond to each deme. If there is more than one deme, a matrix must be supplied describing birth rates between each pair of demes. Either R or C code can be supplied (see rcpp option). |
nonDemeDynamics |
A named character vector of mathematical expressions that describe rate of change for dynamic variables which are not demes; for example: an equation for the number susceptible in an SIR model. |
migrations |
A named character vector or matrix of mathematical expressions that describe model migration rates. Names correspond to each deme. If there is more than one deme, a matrix must be supplied describing migration rates between each pair of demes. Either R or C code can be supplied (see rcpp option). |
deaths |
A named character vector of mathematical expressions that describe death rates in each deme. |
parameterNames |
A character vector providing the names of static parameters used in the model. |
rcpp |
If TRUE, the expressions are interpreted as C code using the Rcpp package. |
sde |
If TRUE, a stochastic differential equation model is constructed; if FALSE, an ordinary differential equation model is constructed. |
An object of class demographic.process
, which is a function
that can be used to simulate the model. The model can also be used as an
input to tree simulation or likelihood calculation.
Erik Volz
# A simple exponential growth model with birth rates beta and death rates gamma:
# I is the number of infected individuals.
dm <- build.demographic.process(births=c(I = 'parms$beta * I'),
deaths = c(I = 'parms$gamma * I'),
parameterNames=c('beta', 'gamma'),
rcpp=FALSE,
sde = TRUE)
# Do a simulation and plot the trajectory:
show.demographic.process(dm,
theta = list(beta = 1.5, gamma = 1),
x0 = c(I = 1),
t0 = 0,
t1 = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.