Using the sde package in R, I would like to simulate the following model for stock prices $p_t$:
$\mathrm{d}\sigma^2_t = (\theta_1 – \theta_2\sigma^2_t)\mathrm{d}t + \theta_3\sigma_t\mathrm{d}W_{\sigma,t}$ (CIR model used for stochastic volatility)
$\mathrm{d}\log{p_t} = \sigma_t\mathrm{d}W_{p,t}$
where correlation between $W_{p,t}$ and $W_{\sigma,t}$ is possibly non-zero.
Q: Is that possible? Is it even possible to simulate multivariate SDEs in the "sde" package the way one can in S+FinMetrics using the gensim
functions? Is there another package in R that might do this?
I'm able to simulate the variance process simply enough with the following code:
library(sde)
sig2 <- sde.sim(X0=0.04, theta=c(0.3141, 8.0369, 0.43), model="CIR")
I can then simulate the price series (starting with initial price = 100) using:
logr <- rnorm(n=length(sig2),sd=sqrt(sig2))
logp <- cumsum(c(log(100),logr))
p <- exp(logp)
But this approach seems unnecessarily clunky and can't capture non-zero correlation between the Brownian Motions.
Best Answer
Hull-White/Vasicek Model: dX(t) = 3*(2-x)*dt+ 2*dw(t)
Multiple trajectories of the OU process by Euler Scheme
You can also use the package Sim.DiffProcGUI (Graphical User Interface for Simulation of Diffusion Processes).