simTs: Simulate a model on a regular grid of times, using a function...

View source: R/StepGillespie.R

simTsR Documentation

Simulate a model on a regular grid of times, using a function (closure) for advancing the state of the model

Description

This function simulates single realisation of a model on a regular grid of times using a function (closure) for advancing the state of the model, such as created by StepGillespie or StepEulerSPN.

Usage

simTs(x0,t0=0,tt=100,dt=0.1,stepFun,...)

Arguments

x0

The initial state of the process at time t0.

t0

The initial time to be associated with the initial state x0. Defaults to 0.

tt

The terminal time of the simulation.

dt

The time step of the output. Note that this time step relates only to the recorded output, and has no bearing on the accuracy of the simulation process.

stepFun

A function (closure) for advancing the state of the process, such as produced by StepGillespie or StepEulerSPN.

...

Additional arguments will be passed to stepFun.

Value

An R ts object representing the simulated process.

See Also

StepEulerSPN, StepGillespie, StepSDE, simTimes, simSample, as.timedData

Examples

# load the LV model
data(spnModels)
# create a stepping function
stepLV = StepGillespie(LV)
# simulate a realisation of the process and plot it
out = simTs(c(x1=50,x2=100),0,100,0.1,stepLV)
plot(out)
plot(out,plot.type="single",lty=1:2)

smfsb documentation built on Jan. 13, 2024, 3:02 a.m.