For loop in GARCH Monte Carlo Simulation

3 ビュー (過去 30 日間)
Leonard Meyer
Leonard Meyer 2021 年 2 月 4 日
コメント済み: Leonard Meyer 2021 年 2 月 8 日
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

採用された回答

Asvin Kumar
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
GARCH models are not my area of expertise. This example on simulating GARCH models might help.
  1 件のコメント
Leonard Meyer
Leonard Meyer 2021 年 2 月 8 日
Thanks, I'll try that!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConditional Variance Models についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by