Merge pull request #726 from JohannesPfeifer/steady_linear

Prevent incorrect steady state from being accepted if model is not truly linear
time-shift
MichelJuillard 2015-07-20 14:06:03 +02:00
commit e174f5f00a
4 changed files with 44 additions and 7 deletions

View File

@ -207,9 +207,16 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
disp(['STEADY: numerical initial values or parameters incompatible with the following' ...
' equations'])
disp(ii')
disp('Check whether your model in truly linear')
disp('Check whether your model is truly linear. Put "resid(1);" before "steady;" to see the problematic equations.\n')
elseif isempty(ii) && max(abs(fvec)) > 1e-12
ys = ys_init-jacob\fvec;
resid = evaluate_static_model(ys,exo_ss,params,M,options);
if max(abs(resid)) > 1e-6
check=1;
fprintf('STEADY: No steady state for your model could be found\n')
fprintf('STEADY: Check whether your model is truly linear. Put "resid(1);" before "steady;" to see the problematic equations.\n')
end
else
ys = ys_init;
end
@ -225,7 +232,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
fprintf('STEADY: Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n',infrow(ii),deblank(M.endo_names(orig_var_index,:)),deblank(M.endo_names(orig_var_index,:)),ys_init(infcol(ii)))
end
end
disp('STEADY: Check whether your model in truly linear\n')
fprintf('Check whether your model is truly linear. Put "resid(1);" before "steady;" to see the problematic equations.\n')
end
end
end
@ -237,7 +244,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
if check
info(1)= 20;
resid = evaluate_static_model(ys_init,exo_ss,params,M,options);
resid = evaluate_static_model(ys,exo_ss,params,M,options);
info(2) = resid'*resid ;
if isnan(info(2))
info(1)=22;

View File

@ -75,9 +75,15 @@ if ~noprint
case 19
error('The steadystate file did not compute the steady state')
case 20
error(['Impossible to find the steady state. Either the model' ...
' doesn''t have a steady state, there are an infinity of steady states, ' ...
' or the guess values are too far from the solution'])
if DynareOptions.linear
error(['Impossible to find the steady state. Either the model' ...
' doesn''t have a steady state or there are an infinity of steady states.' ...
' Check whether your model is truly linear or whether there is a mistake in linearization.'])
else
error(['Impossible to find the steady state. Either the model' ...
' doesn''t have a steady state, there are an infinity of steady states,' ...
' or the guess values are too far from the solution'])
end
case 21
error('The steady state is complex')
case 22

View File

@ -231,7 +231,8 @@ MODFILES = \
XFAIL_MODFILES = ramst_xfail.mod \
estim_param_in_shock_value_xfail.mod \
optimal_policy/Ramsey/ramsey_ex_wrong_ss_file_xfail.mod
optimal_policy/Ramsey/ramsey_ex_wrong_ss_file_xfail.mod \
steady_state/run_linear_steady_state_fail_test.mod
MFILES = initval_file/ramst_initval_file_data.m

View File

@ -0,0 +1,23 @@
// Test whether a nonlinear equation specfied as a linear model is correctly filtered out
var A;
varexo epsilona;
parameters rho;
rho = .42;
model(linear);
log(A) = rho*log(A(-1)) + epsilona;
end;
initval;
A = 1.34;
end;
steady;