simTimes {smfsb} | R Documentation |
Simulate a model at a specified set of times, using a function (closure) for advancing the state of the model
Description
This function simulates a single realisation from a Markovian model and
records the state at a specified set of times using a function (closure) for advancing the state of the model, such as created by StepGillespie
or StepEulerSPN
.
Usage
simTimes(x0,t0=0,times,stepFun,...)
Arguments
x0 |
The initial state of the process at time |
t0 |
The initial time to be associated with the initial state |
times |
A vector of times at which the state of the process is required. It is assumed that the times are in increasing order, and that the first time is at least as big as |
stepFun |
A function (closure) for advancing the state of the process, such as produced by |
... |
Additional arguments will be passed to |
Value
An R matrix where each row represents the state of the process at one of the required times. The row names contain the sampled times.
See Also
StepEulerSPN
, StepGillespie
,
simTs
, simSample
,
as.timedData
, pfMLLik
Examples
# load the LV model
data(spnModels)
# create a stepping function
stepLV = StepGillespie(LV)
# simulate a realisation using simTimes
times = seq(0,100,by=0.1)
plot(ts(simTimes(c(x1=50,x2=100),0,times,stepLV),start=0,deltat=0.1),plot.type="single",lty=1:2)
# simulate a realisation at irregular times
times = c(0,10,20,50,100)
out2 = simTimes(c(x1=50,x2=100),0,times,stepLV)
print(out2)