Index in position 1 exceeds array bounds. IRF plot.
显示 更早的评论
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?
采纳的回答
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 个评论
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);
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
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?
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.
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?
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.
Vectors must be the same length.
Okay, got it. Thank you so much for answering!
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
