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?

 Accepted Answer

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 Comments

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.
Okay, got it. Thank you so much for answering!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!