I’m trying to plot the IRFs and when I insert
plot(x, exp(oo_.endo_simul(1,:)))
I get the error “index in position 1 exceeds array bounds”.
My x is defined as linspace(1,40,40);
Could you please help me with this?

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 3 月 16 日

0 投票

The error has to do with the 1 in oo_.endo_simul(1,:). Check the size of this data. It apparetly has 0 rows.

7 件のコメント

Ayazhan Zhangalova
Ayazhan Zhangalova 2021 年 3 月 16 日
I was using this mod file to build my IRFs. Doesn’t seem like it has 0 rows. Where can I look for this information?
var Y w R I K A G C;
varexo ea eg;
parameters alphap betap deltap rhoa rhog omega chi;
alphap = 1/3; betap = 0.99; deltap = 0.02; rhoa = 0.97; rhog = 0.95; omega = 0.2; chi = 1;
model;
exp® = 1/betap - (1-deltap); exp(K) = (1/3)*((1 - betap*(1-deltap))/(alphap*betap))^(1/(alphap-1)); exp(Y) = (1/3)*((1 - betap*(1-deltap))/(alphap*betap))^(alphap/(alphap-1)); exp(I) = (deltap/3)*((1 - betap*(1-deltap))/(alphap*betap))^(1/(alphap-1)); exp(C) = exp(Y) * (1-omega) - exp(I); exp(w) = (1-alphap)*((1 - betap*(1-deltap))/(alphap*betap))^(alphap/(alphap-1)); G = (1-rhog)*omega*Y + rhog*G(-1) + eg; A = rhoa*A(-1) + ea;
end;
initval;
K = log(12.3); Y = log(1.1); A = 0; C = log(0.64); I = log(0.25); w = log(2.22); R = log(0.03); G = log(0.22);
end;
shocks; var eg; stderr 1; var ea; stderr 1; end;
steady; check;
stoch_simul(order=1, irf=20, periods=40);
Cris LaPierre
Cris LaPierre 2021 年 3 月 16 日
Sorry, how does this code relate to oo_.endo_simul?
I would suggest opening oo_ in the variable editor and seeing what is contained in endo_simul
Ayazhan Zhangalova
Ayazhan Zhangalova 2021 年 3 月 16 日
This is the code for neoclassical model with two shocks. I want to plot the IRFs based on the output of this model.
When I open oo_ endo_simul indeed contains only zeros. How do I fix this?
Cris LaPierre
Cris LaPierre 2021 年 3 月 16 日
It sounds lke you have an error in your simulation code. Not sure we have enough information to be able to help with that, though.
Ayazhan Zhangalova
Ayazhan Zhangalova 2021 年 3 月 16 日
編集済み: Ayazhan Zhangalova 2021 年 3 月 16 日
Oh, I actually found a mistake, thanks! I have one more question though. Could you please tell me what “vectors must be the same length” refers to?
Cris LaPierre
Cris LaPierre 2021 年 3 月 16 日
In the context of plotting, this means your input for X has to be a vector the same length as Y. Otherwise, there are leftover numbers.
x=1:5;
y=[3 1];
plot(x,y)
Error using plot
Vectors must be the same length.
Ayazhan Zhangalova
Ayazhan Zhangalova 2021 年 3 月 16 日
Okay, got it. Thank you so much for answering!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by