Parallel simulations of VAR
조회 수: 3 (최근 30일)
이전 댓글 표시
clear
clc
tic
bet = .2;
rho = .8;
gam = 0.06;
particles = 50000;
N = particles;
Time = 150;
T = Time;
y = zeros(particles,T);
e_y = zeros(particles,T);
u = zeros(N,T);
e = normrnd(0,1,[N,T]);
v = normrnd(0,1,[N,T]);
u(:,1) = e(:,1);
phi = [0,inv(1-bet*rho)]';
R_t = eye(2);
for i = 2:T
u(:,i) = rho*u(:,i-1) + e(:,i);
end
for n = 1:N
for i = 2:T
x = [1,u(i-1)]';
phi = phi + gam*inv(R_t)*x*(y(n,i-1)-phi'*x)';
R_t = R_t + gam*(x*x' - R_t);
e_y(n,i) = phi(1) + phi(2)*rho*u(n,i);
y(n,i) = bet*e_y(n,i) + u(n,i) + v(n,i);
end
end
toc
In the code above I am attempting to simulate a VAR process that is driven by two gaussian processes, one of which enters to create an autoregressive process. My goal is to efficiently and repeatedly simulate this VAR model in order to use a particle filter to estimate the parameters. As it is written now, however, simulating the model this many times requires about 45 seconds of computer time, which renders any simulation-based estimation procedure hopeless.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Monte-Carlo에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!