Merge pull request #816 from JohannesPfeifer/loglinear_steady_error

Integrate error from negative steady state with loglinear model into pri...
time-shift
Stéphane Adjemian 2015-03-01 16:30:29 +01:00
commit ba2c4db88c
3 changed files with 25 additions and 17 deletions

View File

@ -70,6 +70,8 @@ function [fval,DLIK,Hess,exit_flag,SteadyState,trend_coeff,info,Model,DynareOpti
%! M_.params has been updated in the steadystate routine and has complex valued scalars. %! M_.params has been updated in the steadystate routine and has complex valued scalars.
%! @item info==24 %! @item info==24
%! M_.params has been updated in the steadystate routine and has some NaNs. %! M_.params has been updated in the steadystate routine and has some NaNs.
%! @item info==26
%! M_.params has been updated in the steadystate routine and has negative/0 values in loglinear model.
%! @item info==30 %! @item info==30
%! Ergodic variance can't be computed. %! Ergodic variance can't be computed.
%! @item info==41 %! @item info==41
@ -266,7 +268,7 @@ if info(1) == 1 || info(1) == 2 || info(1) == 5 || info(1) == 7 || info(1) == 8
DLIK=ones(length(xparam1),1); DLIK=ones(length(xparam1),1);
end end
return return
elseif info(1) == 3 || info(1) == 4 || info(1)==6 || info(1) == 20 || info(1) == 21 || info(1) == 23 elseif info(1) == 3 || info(1) == 4 || info(1)==6 || info(1) == 20 || info(1) == 21 || info(1) == 23 || info(1)==26
fval = objective_function_penalty_base+info(2); fval = objective_function_penalty_base+info(2);
info = info(1); info = info(1);
exit_flag = 0; exit_flag = 0;

View File

@ -88,6 +88,8 @@ if ~noprint
error('Some updated params contain NaN or Inf') error('Some updated params contain NaN or Inf')
case 25 case 25
error('The solution to the static equations is not a steady state of the dynamic model: verify that the equations tagged by [static] and [dynamic] are consistent') error('The solution to the static equations is not a steady state of the dynamic model: verify that the equations tagged by [static] and [dynamic] are consistent')
case 26
error('The loglinearization of the model cannot be performed, because the steady state is not strictly positive.')
case 30 case 30
error('Variance can''t be computed') error('Variance can''t be computed')
case 41 case 41

View File

@ -111,23 +111,27 @@ if options.loglinear
% Find variables with non positive steady state. % Find variables with non positive steady state.
idx = find(dr.ys<1e-9); idx = find(dr.ys<1e-9);
if length(idx) if length(idx)
variables_with_non_positive_steady_state = M.endo_names(idx,:); if options.debug
skipline() variables_with_non_positive_steady_state = M.endo_names(idx,:);
fprintf('You are attempting to simulate/estimate a loglinear approximation of a model, but\n') skipline()
fprintf('the steady state level of the following variables is not strictly positive:\n') fprintf('You are attempting to simulate/estimate a loglinear approximation of a model, but\n')
for var_iter=1:length(idx) fprintf('the steady state level of the following variables is not strictly positive:\n')
fprintf(' - %s (%s)\n',deblank(variables_with_non_positive_steady_state(var_iter,:)), num2str(dr.ys(idx(var_iter)))) for var_iter=1:length(idx)
fprintf(' - %s (%s)\n',deblank(variables_with_non_positive_steady_state(var_iter,:)), num2str(dr.ys(idx(var_iter))))
end
if isestimation()
fprintf('You should check that the priors and/or bounds over the deep parameters are such\n')
fprintf('that the steady state levels of all the variables are strictly positive, or consider\n')
fprintf('a linearization of the model instead of a log linearization.\n')
else
fprintf('You should check that the calibration of the deep parameters is such that the\n')
fprintf('steady state levels of all the variables are strictly positive, or consider\n')
fprintf('a linearization of the model instead of a log linearization.\n')
end
end end
if isestimation() info(1)=26;
fprintf('You should check that the priors and/or bounds over the deep parameters are such\n') info(2)=sum(dr.ys(dr.ys<1e-9).^2);
fprintf('that the steady state levels of all the variables are strictly positive, or consider\n') return
fprintf('a linearization of the model instead of a log linearization.\n')
else
fprintf('You should check that the calibration of the deep parameters is such that the\n')
fprintf('steady state levels of all the variables are strictly positive, or consider\n')
fprintf('a linearization of the model instead of a log linearization.\n')
end
error('stoch_simul::resol: The loglinearization of the model cannot be performed, because the steady state is not strictly positive!')
end end
end end