rTrajMou {sdetorus} | R Documentation |
Simulation of trajectories for the multivariate OU diffusion
Description
Simulation of trajectories of the multivariate Ornstein–Uhlenbeck (OU) diffusion
dX_t=A(\mu - X_t)dt+\Sigma^\frac{1}{2}dW_t, X_0=x_0
using the exact transition probability density.
Usage
rTrajMou(x0, A, mu, Sigma, N = 100, delta = 0.001)
Arguments
x0 |
a vector of length |
A |
the drift matrix, of size |
mu |
unconditional mean of the diffusion, a vector of length |
Sigma |
square of the diffusion matrix, a matrix of size |
N |
number of discretization steps in the resulting trajectory. |
delta |
time discretization step. |
Details
The law of the discretized trajectory at each time step is
a multivariate normal with mean meantMou
and covariance
matrix covtMou
. See rTrajOu
for the univariate
case (more efficient).
solve(A) %*% Sigma
has to be a covariance matrix (symmetric and
positive definite) in order to have a proper transition density. For the
bivariate case, this can be ensured with the alphaToA
function.
In the multivariate case, it is ensured if Sigma
is isotropic and
A
is a covariance matrix.
Value
A matrix of size c(N + 1, p)
containing x0
in the
first row and the exact discretized trajectory on the remaining rows.
Examples
set.seed(987658)
data <- rTrajMou(x0 = c(0, 0), A = alphaToA(alpha = c(1, 2, 0.5),
sigma = 1:2), mu = c(1, 1), Sigma = diag((1:2)^2),
N = 200, delta = 0.1)
plot(data, pch = 19, col = rainbow(201), cex = 0.25)
arrows(x0 = data[-201, 1], y0 = data[-201, 2], x1 = data[-1, 1],
y1 = data[-1, 2], col = rainbow(201), angle = 10, length = 0.1)