Description Usage Arguments Details Value Examples
Simulates a discretized Euler-Maruyama approximation to the true SDE trajectory.
1 2 3 4 5 6 7 8 9 10 11 12 |
model |
An |
x0 |
A vector or a matrix of size |
theta |
A vector or matrix of size |
dt |
Scalar interobservation time. |
dt.sim |
Scalar interobservation time for simulation. That is, interally the interobservation time is |
nobs |
The number of SDE observations per trajectory to generate. |
burn |
Scalar burn-in value. Either an integer giving the number of burn-in steps, or a value between 0 and 1 giving the fraction of burn-in relative to |
nreps |
The number of SDE trajectories to generate. |
max.bad.draws |
The maximum number of times that invalid forward steps are proposed. See Details. |
verbose |
Whether or not to display information on the simulation. |
The simulation algorithm is a Markov process with Y_0 = x_0 and
Y_(t+1) ~ N(Y_t + dr(Y_t, θ) dt_(sim), df(Y_t, θ) dt_(sim)),
where dr(y, θ) is the SDE drift function and df(y, θ) is the diffusion function on the variance scale. At each step, a while-loop is used until a valid SDE draw is produced. The simulation algorithm terminates after nreps
trajectories are drawn or once a total of max.bad.draws
are reached.
A list with elements:
data
An array of size nobs x ndims x nreps
containing the simulated SDE trajectories.
params
The vector or matrix of parameter values used to generate the data.
dt, dt.sim
The actual and internal interobservation times.
nbad
The total number of bad draws.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # load pre-compiled model
hmod <- sde.examples("hest")
# initial values
x0 <- c(X = log(1000), Z = 0.1)
theta <- c(alpha = 0.1, gamma = 1, beta = 0.8, sigma = 0.6, rho = -0.8)
# simulate data
dT <- 1/252
nobs <- 2000
burn <- 500
hsim <- sde.sim(model = hmod, x0 = x0, theta = theta,
dt = dT, dt.sim = dT/10,
nobs = nobs, burn = burn)
par(mfrow = c(1,2))
plot(hsim$data[,"X"], type = "l", xlab = "Time", ylab = "",
main = expression(X[t]))
plot(hsim$data[,"Z"], type = "l", xlab = "Time", ylab = "",
main = expression(Z[t]))
|
Number of normal draws required: 25000
Running simulation...
Execution time: 0 seconds.
Bad Draws = 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.