For loop in GARCH Monte Carlo Simulation
3 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
I am trying to run a monte carlo simulation on a GARCH based conditional variance model, but I fail to correctly implement a loop into the code. I would like to simulate 10000 paths each for 250 days and the resulting output variables SimInno and SimVar should not be overwritten with each step, but added one column each time the loop runs (so I would like to get two 250x10000 arrays from the original 1x10000 arrays).
Any help would be highly appreciated.
SimInno = VolGARCHsp(end).*normrnd(0,1,10000,1) %starting value VolGARCHsp stems from an estimated GARCH model
SimVar = ParGARCHsp(end,1) + ParGARCHsp(end,2).*SimInno.^2 + ParGARCHsp(end,3).*VolGARCHsp(end).^2 %parameters ParGARCHsp come from the same model
for i = 1:250
SimInno = SimVar(i).*normrnd(0,1,10000,1)
SimVar = ParGARCHsp(end,1) + ParGARCHsp(end,2).*SimInno(i+1) + ParGARCHsp(end,3).*SimVar(i+1)
end
Leo
0 件のコメント
採用された回答
Asvin Kumar
2021 年 2 月 8 日
I'm unsure what the variables mean. If what you are trying to do is preserve the values at each step of your for loop, you can do that by pre-allocating an array and filling up each row of it. Here's a template you can adapt from:
varA = zeros(25+1,10); % preallocate as required
varB = zeros(25+1,10); % "
varA(1,1:10) = 2*ones([1,10]); % start values
for i=2:26
varA(i) = varA(i-1)+varB(i-1); % use your formula here
varB(i) = varA(i-1)-varB(i-1); % use your formula here
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Conditional Variance Models についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!