Error using the resol function

Hello
when running the following code

dynare NKbaseline.mod
NKbaseline.mod (5.6 KB)

phi_pi_vec=linspace(0,5,100);
phi_y_vec=linspace(0,1.5,100);
[phi_pi_mat,phi_y_mat]=meshgrid(phi_pi_vec,phi_y_vec);
%Z_plot_total=zeros(size(phi_pi_mat));
info_mat=NaN(size(phi_pi_mat));

for j=1:length(phi_pi_vec)
for k=1:length(phi_y_vec)
set_param_value(‘phi_pi’,phi_pi_mat(j,k));
set_param_value(‘phi_y’,phi_y_mat(j,k));
[dr,info,params]=resol(0,M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
info_mat(j,k)=info(1);
stoch_simul(var_list_);
end
end

Z_plot=zeros(size(info_mat));
Z_plot(info_mat==0)=1;
figure
contourf(phi_pi_mat,phi_y_mat,Z_plot,1)
xlabel(‘\phi_\pi’)
ylabel(‘\phi_y’)

I keep getting the error:
Unrecognized field name “kstate”.
Error in stochastic_solvers (line 195)
kstate = dr.kstate;
Error in resol (line 115)
[dr, info] = stochastic_solvers(dr, check_flag,
M_, options_, exo_steady_state,
exo_det_steady_state);
Error in untitled (line 20)
[dr,info,params]=resol(0,M_,options_,oo_.dr,
oo_.steady_state, oo_.exo_steady_state,
oo_.exo_det_steady_state);

I use dynare 6.0. I simply cannot work out how to solve the above error, so it would be very much appreciated if anyone would be able to help. Thank you in advance!

1 Like

Having a similar issue – I can’t remember how to restore compatibility of the resol function due to the changes between Dynare 4, 5, and 6.

For example, the Ascari and Sbordone (2014) replication (for determinacy plots) do not work on Dynare 6.

1 Like

OK, seems like you need to specify the following in Dynare 6 (and 5 too I think):

if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
end

So I have:

phi_pi_vec=linspace(0,2,200);
phi_y_vec=linspace(0,2,200);
[phi_pi_mat,phi_y_mat]=ndgrid(phi_pi_vec,phi_y_vec);
info_mat=NaN(size(phi_pi_mat));
if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
end
for phi_pi_iter=1:length(phi_pi_vec)
for phi_y_iter=1:length(phi_y_vec)
set_param_value(‘phi_pi’,phi_pi_mat(phi_pi_iter,phi_y_iter));
set_param_value(‘phi_y’,phi_y_mat(phi_pi_iter,phi_y_iter));
[oo_.dr,info]=resol(0,M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
info_mat(phi_pi_iter,phi_y_iter)=info(1);
end
end
Z_plot=zeros(size(info_mat));
Z_plot(info_mat==0)=1;
figure(‘Name’,‘Determinacy Region in the Baseline NK Model’)
contourf(phi_y_mat,phi_pi_mat,Z_plot,1)
xlabel(‘\phi_y’)
ylabel(‘\phi_\pi’)

Which I use with Johannes’ replication of the baseline NK model to replicate Figure 4.1 in Gali (2015).

1 Like

Dear Murakami thank you so much for your help! It works when I use the specification you provided. I did, however, also try it with Dynare 5.5 where it didn’t solve the problem but yielded an error message about “too many inputs”. But for Dynare version 6 it solved the problem - thanks again :slight_smile:

A version-proof code should be

phi_pi_vec=linspace(0,2,200);
phi_y_vec=linspace(0,2,200);
[phi_pi_mat,phi_y_mat]=ndgrid(phi_pi_vec,phi_y_vec);
info_mat=NaN(size(phi_pi_mat));
if isempty(options_.qz_criterium)
    options_.qz_criterium = 1+1e-6;
end
dyn_ver = dynare_version;
for phi_pi_iter=1:length(phi_pi_vec)
    for phi_y_iter=1:length(phi_y_vec)
        set_param_value('phi_pi',phi_pi_mat(phi_pi_iter,phi_y_iter));
        set_param_value('phi_y',phi_y_mat(phi_pi_iter,phi_y_iter));
        if str2double(dyn_ver(1))< 5
            [oo_.dr, info, M_, options_, oo_] = resol(0, M_, options_, oo_); %get decision rules
        elseif str2double(dyn_ver(1))< 6
            [oo_.dr,info,M_,oo_] = resol(0,M_,options_,oo_); %get decision rules
        else
            [oo_.dr,info] = resol(0,M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_steady_state); %get decision rules
        end

        info_mat(phi_pi_iter,phi_y_iter)=info(1);
    end
end
Z_plot=zeros(size(info_mat));
Z_plot(info_mat==0)=1;
figure('Name','Determinacy Region in the Baseline NK Model')
contourf(phi_y_mat,phi_pi_mat,Z_plot,1)
xlabel('\phi_y')
ylabel('\phi_\pi')
2 Likes