Save the following mod-file
- Code: Select all
var z pi p i u;
varexo u_init;
parameters beta rho sigma delta_pi theta delta_z omega;
beta = 0.99;
rho = 0.8;
sigma = 1;
delta_pi = 1.5;
theta = 1.16;
delta_z = 0.5;
model(linear);
# kappa= ((1-omega)*(1-omega*beta))/omega;
z = z(+1)-1/sigma*(i-pi(+1));
i = delta_pi*pi+delta_z*z;
pi = beta*pi(+1)+(sigma+theta)*kappa*z+u;
pi = p-p(-1);
u = rho*u(-1)+u_init(-@{antic_horizon}); // anticipated cost shock, antic_horizon periods before materialization
end;
shocks;
var u_init = 1;
end;
@#for omega_val in ["0.8","0.75","0.70"]
omega = @{omega_val};
stoch_simul(irf=100, nograph);
@#endfor
and call it using
- Code: Select all
dynare Antic_loop -Dantic_horizon=2
where the -D switch sets the anticipation horizon, which is a macroprocessor variable used within the mod-file (see the macroprocessor.pdf in the Dynare/doc-folder). You can essentially loop over it by calling
- Code: Select all
for ii=1:10
eval(['dynare Antic_loop -Dantic_horizon=',num2str(ii),' noclearall'])
end
You still need to do the saving of the results. Depending on what you want to do, you will need the
- Code: Select all
noclearall
option to not erase the workspace in every call.