Zero lower bound with varexo_det and stochastic simulation

I am trying to introduce a zero lower bound on the central bank’s policy rate in a New Keynesian DSGE model:

(…)
varexo_det
impose_ZLB;
(…)
model;
(…)
i = (1-impose_zlb)*(forward-looking Taylor rule with interest rate smoothing);
(…)
end;
(…)
var impose_ZLB;
periods 1:20 21:32;
values 1 0;
(…)
stoch_simul(periods=0,order=1);
forecast;

The code runs smoothly, but the simulated path of the policy rate is NOT zero for the first 20 periods as it should be.
Any ideas how this could happen?
Thanks.

Here is a simple working example illustrating the problem:


var y i pi;  
varexo RES_pi RES_i;
varexo_det impose_ZLB RES_demand;

parameters coeff_y_ystarlag coeff_i_pi coeff_i_y coeff_pi_pilag 
           coeff_pi_ylag coeff_y_ylag coeff_y_igap;
                                                                                                                                           
// Taylor rule
coeff_i_pi              = 0.8;
coeff_i_y               = 0.2;
// Phillips curve
coeff_pi_pilag           = 0.5;
coeff_pi_ylag            = 0.02;
// IS curve
coeff_y_ylag             = 0.7;
coeff_y_igap             = -1;
coeff_y_ystarlag         = 0.03;

model(linear);                                                                                                                            
    i    =  (1-impose_ZLB)*(coeff_i_pi*pi + coeff_i_y*y + RES_i); 
    y    =  coeff_y_igap*(i-pi) + coeff_y_ylag*y(-1) + RES_demand; 
    pi   =  coeff_pi_ylag*y(-1) + coeff_pi_pilag*pi(+1) + RES_pi;
end;

shocks;
    var RES_pi ; stderr 0.1;
    var RES_i; stderr 0.3;
    var impose_ZLB;
    periods 0:20;
    values 1;
    var RES_demand;
    periods 0:5;
    values -0.5;
end;

steady;
stoch_simul(nograph,order=1);
forecast;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//prepare plots
names   =   strvcat(M_.endo_names,M_.exo_det_names);
results =   [oo_.forecast.Mean.y'; oo_.forecast.Mean.i';oo_.forecast.Mean.pi'; oo_.forecast.Exogenous.impose_ZLB(2:end)'; oo_.forecast.Exogenous.RES_demand(2:end)'];

disp_horizon  = 20;
early_periods = 0;
time          = -early_periods:1:disp_horizon-early_periods-1;

for hh=1:4,
    subplot(2,2,hh);
    plot(time,[zeros(1,early_periods),results(hh,1:disp_horizon-early_periods)],'b.-',time,results(hh,1)+zeros(1,disp_horizon),'k:','MarkerSize',8); 
    title(names(hh,:));
    axis tight
end
orient landscape
drawnow
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

It is impossible to simulate a ZLB model with stoch_simul (i.e. with a stochastic perturbation method). The constraint will not be enforced, as you noted. The reason is that the approximated policy function is either linear or polynomial around the steady state, but in any case it does not incorporate the constraint.

You should either use simul (perfect foresight) or extended path for correctly simulating ZLB models.

Thanks for your response. What do you think of setting up a sequence of monetary policy shocks (in a deterministic simulation) that counteracts the endogenous response of the policy rate, which would then look as if a zero lower bound existed?