I don't have the Econometrics toolbox so I can't give you detailed code for it (most Matlab installs don't have this toolbox by default). However, your case is a pretty common so I imagine that it shouldn't be too hard to do what you need. You might consider creating a service request with The MathWorks or posting a question at Quant.StackExchange. Make sure you're clear about the SDEs that you're interested in. Sorry that I can't help you more in that area.
Another way to simulate this coupled set of SDEs is to use my own SDETools toolbox which is available for free on GitHub. These are quite straightforward if you have any experience with Matlab's ODE Suite functions such as ode45
. SDETools also has dedicated functions for common stochastic process (e.g., geometric Brownian motion and Ornstein-Uhlenbeck) using their analytic solutions. Here is basic code with arbitrary parameter values to simulate your SDEs using the Euler-Maryama integrator function, sde_euler
, in SDETools:
t0 = 0;
dt = 1e-2;
tf = 1e1;
tspan = t0:dt:tf; % Time vector
y0 = [1;1]; % Initial conditions
kappa = 10;
mu = 0;
tau = 1e-1;
sigma = 1e-2;
f = @(t,y)[kappa.*(mu-y(1));y(1).*y(2)]; % Drift
g = @(t,y)[tau;sigma.*y(2)]; % Diffusion
% Set random seed and type of stochastic integration
options = sdeset('RandSeed',1,'SDEType','Ito');
Y = sde_euler(f,g,tspan,y0,options); % Euler-Maruyama
figure;
plot(tspan,Y)
In fact, it's possible that the sde
function in the Econometrics toolbox could itself take the two function handles, f
and g
, I created above.
Here's another way you can simulate the system (it may or may not be faster), this time using the sde_ou
function to first generate an OU process, which itself is independent of the other equation:
...
options = sdeset('RandSeed',1);
Y(:,1) = sde_ou(kappa,mu,tau,tspan,y0(1),options); % OU process
f = @(t,y)Y(round(t/dt)+1,1).*y; % Index into OU process as a function of t
g = @(t,y)sigma.*y;
options = sdeset('RandSeed',2,'SDEType','Ito');
Y(:,2) = sde_euler(f,g,tspan,y0(2),options); % Euler-Maruyama of just second equation
figure;
plot(tspan,Y)
Note that even the the same random seed is used for the OU process, the output of Y(:,1)
will be slightly different for this and the sde_euler
case because of the order in which the Wiener increments are generated internally. Again, you may well be able to do something similar using the function in the Econometrics toolbox.