Description Usage Arguments Value Examples
This function allows you to simulate two-dimensional stochastic differential equations.
1 2 |
init.x |
initial condition for the x state variable |
init.y |
initial condition for the y state variable |
y0 |
instead of init.x and init.y, can assign a two-element vector of the initial conditions for the state variables. Elements must be assigned as objects (see Example below). |
time |
numeric value indicating the total time over which the simulation is to be run. |
deltat |
numeric value indicating the frequency of stochastic perturbation, as Δ t. |
x.rhs |
a string containing the right hand side of the equation for x. |
y.rhs |
a string containing the right hand side of the equation for y. |
parms |
n-element vector of objects representing unvalued parameters in the equation. If parameter values are values in the equation, then default is |
sigma |
numeric value specifying the noise intensity. |
lower.bound |
numeric value specifying a lower bound in the simulation. |
upper.bound |
numeric value specifying an upper bound in the simulation. |
returns a matrix with three columns (timestep, x values, and y values) with a length of time/deltat
(2*e4 in the examples below).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # First, the parameter values
model.state <- c(x = 3, y = 3)
model.sigma <- 0.2
model.deltat <- 0.1
model.time <- 100
# Second, write out the deterministic skeleton of the equations to be simulated
equationx <- "1.54*x*(1.0-(x/10.14)) - (y*x*x)/(1.0 + x*x)"
equationy <- "((0.476*x*x*y)/(1 + x*x)) - 0.112590*y*y"
# Third, Run it
ModelOut <- TSTraj(y0 = model.state, time = model.time, deltat = model.deltat,
x.rhs = equationx, y.rhs = equationy, sigma = model.sigma)
# Can also input x.rhs and y.rhs as strings that contain parameter names
# and include parms with names and values of parameters
model.state <- c(x = 1, y = 2)
model.parms <- c(alpha = 1.54, beta = 10.14, delta = 1, kappa = 1, gamma = 0.476, mu = 0.112509)
model.sigma <- 0.2
model.time <- 100
model.deltat <- 0.1
test.eqn.x = "(alpha*x)*(1-(x/beta)) - ((delta*(x^2)*y)/(kappa + (x^2)))"
test.eqn.y = "((gamma*(x^2)*y)/(kappa + (x^2))) - mu*(y^2)"
ModelOut.parms <- TSTraj(y0 = model.state, time = model.time, deltat = model.deltat,
x.rhs = test.eqn.x, y.rhs = test.eqn.y, parms = model.parms, sigma = model.sigma)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.