Help! how to calculate the area of a circle from time to from time

Plz Help! :sob:
I just want to build a simple model to calculate the area of a circle from time to from time. Dynare didn’t report error, but the result (the circle area) is strange and wrong, can anyone tell me what is the problem and how to fix it? Here is the code:

var v radii circle no_use;
varexo ea;
parameters rho sigma;
rho = 0.9;
sigma = 0.5;

model;
v = rho* v(-1) + ea;
radii = 0.95* radii(-1) + v;
circle = 3.14159 * radii^2;
% the area of the circle
no_use=0.9* no_use(+1)+v;
% no_use is only for use of “order=2” in stoch_simul
end;

initval;
v=0; radii=0; circle=0; no_use=0;
end;
steady;
check;
shocks;
var ea; stderr sigma;
end;
stoch_simul(order=2,irf=200) ;

here is the result:
untitled

I am not sure I understand what you are trying to do. The problem here is mostly random shocks happening and your number if replic being to small to generate smoother GIRFs.

Thx for answering :heart:, Professor jpfeifer. What I try to do is to calculate the area of a circle, which is circle = 3.14159 * radii^2. But as you can see in the picture, circle definitely doesn’t satisfy the equation, and the IRF of circle isn’t smooth, I just want to know why and how to get the right picture :disappointed_relieved:.
I am not sure your meanning of “number too small”. in the code, I let stderr(radii)=0.5, I think it is large enough to generate smooth IRF, right?
If I still don’t make myself clear, plz tell me.

You don’t want GIRFs. Try

var v radii circle no_use;
varexo ea;
parameters rho sigma;
rho = 0.9;
sigma = 0.5;

model;
v = rho* v(-1) + ea;
radii = 0.95* radii(-1) + v;
circle = 3.14159 * radii^2;
% the area of the circle
no_use=0.9* no_use(+1)+v;
% no_use is only for use of “order=2” in stoch_simul
end;

initval;
v=0; radii=0; circle=0; no_use=0;
end;
steady;
check;
shocks;
var ea; stderr sigma;
end;
stoch_simul(order=2,irf=0) ;

ex_=zeros(200,1)
ex_(1)=1;
y_=simult_(M_,options_,oo_.dr.ys,oo_.dr,ex_,options_.order)
circle_pos=strmatch('circle',M_.endo_names,'exact');
radii_pos=strmatch('radii',M_.endo_names,'exact');
circle=y_(circle_pos,:);
radii=y_(radii_pos,:)

Thanks, professor jpfeifer. It works!
But I still have some questions.

  1. What is the difference between GIRFs and curves created by your code.
  2. if I want to let “radii = 1* radii(-1) + v” rather than “radii = 0.95* radii(-1) + v”, then I shoud use “simul” rather than " stoch_simul", right ?
  1. See
  1. Usually, the approximation quality deteriorates with unit root shocks as you move away from the steady state. But you can try. In principle, unit roots satisfy the BK conditions.

Thank you very much, professor. I will keep thinking about your word. :rose: