imcforecast.m: make sure qz_criterium is properly set
parent
f553f893c6
commit
c68038dfc8
|
@ -123,29 +123,7 @@ if isequal(options_.diffuse_filter,1) || (options_.kalman_algo>2)
|
|||
end
|
||||
end
|
||||
|
||||
% If options_.lik_init == 1
|
||||
% set by default options_.qz_criterium to 1-1e-6
|
||||
% and check options_.qz_criterium < 1-eps if options_.lik_init == 1
|
||||
% Else
|
||||
% set by default options_.qz_criterium to 1+1e-6
|
||||
if isequal(options_.lik_init,1)
|
||||
if isempty(options_.qz_criterium)
|
||||
options_.qz_criterium = 1-1e-6;
|
||||
elseif options_.qz_criterium > 1-eps
|
||||
error(['Estimation: option qz_criterium is too large for estimating ' ...
|
||||
'a stationary model. If your model contains unit roots, use ' ...
|
||||
'option diffuse_filter'])
|
||||
end
|
||||
else
|
||||
if isempty(options_.qz_criterium)
|
||||
options_.qz_criterium = 1+1e-6;
|
||||
else
|
||||
if options_.qz_criterium <= 1;
|
||||
fprintf('\ndynare_estimation_init:: diffuse filter is incompatible with a qz_criterium<=1. Resetting it to 1+1e-6.\n')
|
||||
options_.qz_criterium = 1+1e-6;
|
||||
end
|
||||
end
|
||||
end
|
||||
options_=select_qz_criterium_value(options_);
|
||||
|
||||
% Set options related to filtered variables.
|
||||
if ~isequal(options_.filtered_vars,0) && isempty(options_.filter_step_ahead)
|
||||
|
|
|
@ -119,6 +119,10 @@ if estimated_model
|
|||
data_index = dataset_info.missing.aindex;
|
||||
gend = dataset_.nobs;
|
||||
missing_value = dataset_info.missing.state;
|
||||
|
||||
%store qz_criterium
|
||||
qz_criterium_old=options_.qz_criterium;
|
||||
options_=select_qz_criterium_value(options_);
|
||||
[atT,innov,measurement_error,filtered_state_vector,ys,trend_coeff,aK,T,R,P,PK,decomp,trend_addition] = DsgeSmoother(xparam,gend,data,data_index,missing_value);
|
||||
%get constant part
|
||||
if options_.noconstant
|
||||
|
@ -146,16 +150,16 @@ if estimated_model
|
|||
trend = constant(oo_.dr.order_var,:);
|
||||
InitState(:,1) = atT(:,end);
|
||||
else
|
||||
qz_criterium_old=options_.qz_criterium;
|
||||
if isempty(options_.qz_criterium)
|
||||
options_.qz_criterium = 1+1e-6;
|
||||
end
|
||||
graph_title='Calibration';
|
||||
if ~isfield(oo_.dr,'kstate')
|
||||
error('You need to call stoch_simul before conditional_forecast')
|
||||
end
|
||||
end
|
||||
|
||||
if isempty(options_.qz_criterium)
|
||||
options_.qz_criterium = 1+1e-6;
|
||||
end
|
||||
|
||||
[T,R,ys,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
|
||||
|
||||
if ~isdiagonal(M_.Sigma_e)
|
||||
|
@ -273,4 +277,7 @@ end
|
|||
forecasts.graph.title=graph_title;
|
||||
forecasts.graph.fname=M_.fname;
|
||||
|
||||
%reset qz_criterium
|
||||
options_.qz_criterium=qz_criterium_old;
|
||||
|
||||
save('conditional_forecasts.mat','forecasts');
|
|
@ -0,0 +1,56 @@
|
|||
function options_=select_qz_criterium_value(options_)
|
||||
% function options_=select_qz_criterium_value(options_)
|
||||
% set the value of options_.qz_criterium depending on the Kalman filter used
|
||||
%
|
||||
% INPUTS
|
||||
% options_: Dynare options structure
|
||||
%
|
||||
% OUTPUTS
|
||||
% options_: Dynare options structure
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2016 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
% If options_.lik_init == 1
|
||||
% set by default options_.qz_criterium to 1-1e-6
|
||||
% and check options_.qz_criterium < 1-eps if options_.lik_init == 1
|
||||
% Else
|
||||
% set by default options_.qz_criterium to 1+1e-6
|
||||
stack = dbstack;
|
||||
|
||||
if isequal(options_.lik_init,1)
|
||||
if isempty(options_.qz_criterium)
|
||||
options_.qz_criterium = 1-1e-6;
|
||||
elseif options_.qz_criterium > 1-eps
|
||||
error([stack(2).file ': option qz_criterium is too large for estimating/smoothing ' ...
|
||||
'a stationary model. If your model contains unit roots, use ' ...
|
||||
'option diffuse_filter'])
|
||||
end
|
||||
else
|
||||
if isempty(options_.qz_criterium)
|
||||
options_.qz_criterium = 1+1e-6;
|
||||
else
|
||||
if options_.qz_criterium <= 1
|
||||
fprintf('\n%s:: diffuse filter is incompatible with a qz_criterium<=1. Resetting it to 1+1e-6.\n',stack(2).file)
|
||||
options_.qz_criterium = 1+1e-6;
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue