I’m using DifferentialEquations.jl
to try to simulate paths of the following SDE:
dS = 0.0314 dt + v*(-0.576) dW_1 + v*sqrt(1 - 0.576^2) dW_2
d(v^2) = 0.035*(0.636 - v^2) dt + 0.144 v^2 dW_1
Sorry for the formatting, I wasn’t sure if the Discourse equations plugin was activated here. Anyway, this is my first time using DifferentialEquations.jl
and I’m getting an error, presumably because I’m doing something wrong. My code is here:
function garch_diffusion_mu!(du, u, p, t)
du[1] = 0.0314
du[2] = 0.035 * (0.636 - u[2])
end
function garch_diffusion_sigma!(du, u, p, t)
du[1,1] = -0.576 * sqrt(u[2])
du[1,2] = sqrt(1 - 0.576^2) * sqrt(u[2])
du[2,1] = 0.144 * u[2]
du[2,2] = 0.0
end
garch_diffusion_g_mat = fill(0.1, 2, 2);
prob = SDEProblem(garch_diffusion_mu!, garch_diffusion_sigma!, [log(30.0), 0.1], (0.0, 500.0), noise_rate_prototype=garch_diffusion_g_mat);
dt = 1 // 1000;
sol = solve(prob, dt=dt)
plot(sol)
If I set the time span to (0.0, 1.0)
, everything works fine, but when I set it to (0.0, 500.0)
(which I need to do as I’m duplicating a simulation from a paper), I get the following error:
Warning: dt <= dtmin. Aborting. There is either an error in your model specification or the true solution is unstable
I’m assuming the problem is in my implementation of the SDE, since the equations themselves are known as the GARCH diffusion and have been in a fair few peer-reviewed papers.
Any help or insight that anyone can offer on this would be greatly appreciated.
Thanks,
Colin