This function uses the function ssa.adaptivetau to simulate the model and returns the trajectories in a valid format for the class fitmodel.

simulateModelStochastic(theta, initState, times, transitions, rateFunc)

Arguments

theta

named vector of model parameters.

initState

named vector of initial state of the model.

times

time sequence for which state of the model is wanted; the first value of times must be the initial time.

transitions

One of two possible data types:

  • A list with length equal to the number of transitions. Each element of the list should be a vector specifying a transition (i.e., which state(s) change and by how much). Each entry in the vector needs a name (specifying which state variable to change, either by name or index) and a value (specifying the amount by which this variable will change).

  • A two-dimensional matrix of integers specifying how each state variable (rows) should be changed for a given transition (columns). Generally this will be a sparse matrix of primarily 1s and -1s, which can make this structure inefficient.

See the example below for details as well as ssa.maketrans or the vignette accompanying this package.

rateFunc

R function that returns instantaneous transition rates for each transition in the form a real-valued one-dimensional vector with length equal to the number of transitions. The order of these rates must match the order in which transitions were specified in the transitions parameter above. This function must accept the following arguments:

  • vector of current values for all state variables (in order used in the init.values argument above)

  • parameters as supplied in argument to ssa.adaptivetau

  • single real number giving the current time (all simulations start at t=0)

Value

a data.frame of dimension length(times)x(length(initState)+1)

with column names equal to c("time",names(initState)).