2011-09-19 17:18:40 +02:00
|
|
|
function DynareResults = initial_estimation_checks(xparam1,DynareDataset,Model,EstimatedParameters,DynareOptions,BayesInfo,DynareResults)
|
Fixes for ticket #57
preprocessor:
* add a field "M_.orig_endo_nbr" containing the nbr of endogenous before adding aux vars
* always provide "M_.aux_vars" (define it to "[]" when there is no aux var)
* rename "M_.aux_vars().orig_endo_index" to "M_.aux_vars().orig_index"
M-files:
* for commands which accept a list of variables (stoch_simul, osr, estimation, dynasave, dynatype, datatomfile), when no variable is given, use only the set of original endogenous (without aux vars) as the default
* when displaying the decision rule, when there is aux vars in the state variables, replace them by their original name (with the right lag)
* in "steady", don't display aux vars
* special exception for ramsey policy: all vars (including aux vars) are displayed, because the system of aux vars from ramsey policy is not compatible with the aux vars from the preprocessor
git-svn-id: https://www.dynare.org/svn/dynare/trunk@3166 ac1d8469-bf42-47a9-8791-bf33cf982152
2009-11-25 11:22:39 +01:00
|
|
|
% function initial_estimation_checks(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations)
|
2008-01-21 13:17:46 +01:00
|
|
|
% Checks data (complex values, ML evaluation, initial values, BK conditions,..)
|
2011-09-19 16:38:38 +02:00
|
|
|
%
|
2008-01-21 13:17:46 +01:00
|
|
|
% INPUTS
|
|
|
|
% xparam1: vector of parameters to be estimated
|
|
|
|
% gend: scalar specifying the number of observations
|
|
|
|
% data: matrix of data
|
2011-09-19 16:38:38 +02:00
|
|
|
%
|
2008-01-21 13:17:46 +01:00
|
|
|
% OUTPUTS
|
|
|
|
% none
|
2011-09-19 16:38:38 +02:00
|
|
|
%
|
2008-01-21 13:17:46 +01:00
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
|
2011-02-04 17:27:33 +01:00
|
|
|
% Copyright (C) 2003-2011 Dynare Team
|
2008-08-01 14:40:33 +02:00
|
|
|
%
|
|
|
|
% 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/>.
|
2008-01-21 13:17:46 +01:00
|
|
|
|
2011-09-19 17:18:40 +02:00
|
|
|
if DynareDataset.info.nvobs>Model.exo_nbr+EstimatedParameters.nvn
|
2011-09-19 16:38:38 +02:00
|
|
|
error(['initial_estimation_checks:: Estimation can''t take place because there are less shocks than observed variables!'])
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
2011-09-19 17:18:40 +02:00
|
|
|
if DynareOptions.dsge_var
|
2011-09-22 11:17:31 +02:00
|
|
|
[fval,cost_flag,info] = DsgeVarLikelihood(xparam1,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
2011-09-19 17:18:40 +02:00
|
|
|
[fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2009-12-16 18:17:34 +01:00
|
|
|
% when their is an analytical steadystate, check that the values
|
|
|
|
% returned by *_steadystate match with the static model
|
2011-09-19 17:18:40 +02:00
|
|
|
if DynareOptions.steadystate_flag
|
|
|
|
[ys,check] = feval([Model.fname '_steadystate'],...
|
|
|
|
DynareResults.steady_state,...
|
|
|
|
[DynareResults.exo_steady_state; ...
|
|
|
|
DynareResults.exo_det_steady_state]);
|
|
|
|
if size(ys,1) < Model.endo_nbr
|
|
|
|
if length(Model.aux_vars) > 0
|
|
|
|
ys = add_auxiliary_variables_to_steadystate(ys,Model.aux_vars,...
|
|
|
|
Model.fname,...
|
|
|
|
DynareResults.exo_steady_state,...
|
|
|
|
DynareResults.exo_det_steady_state,...
|
|
|
|
Model.params,...
|
|
|
|
DynareOptions.bytecode);
|
2009-10-02 14:10:50 +02:00
|
|
|
else
|
2011-09-19 17:18:40 +02:00
|
|
|
error([Model.fname '_steadystate.m doesn''t match the model']);
|
2009-10-02 14:10:50 +02:00
|
|
|
end
|
|
|
|
end
|
2011-09-19 17:18:40 +02:00
|
|
|
DynareResults.steady_state = ys;
|
2011-09-19 16:38:38 +02:00
|
|
|
% Check if the steady state obtained from the _steadystate file is a
|
2007-10-01 13:53:28 +02:00
|
|
|
% steady state.
|
|
|
|
check1 = 0;
|
2011-09-19 17:18:40 +02:00
|
|
|
if isfield(DynareOptions,'unit_root_vars') && DynareOptions.diffuse_filter == 0
|
|
|
|
if isempty(DynareOptions.unit_root_vars)
|
|
|
|
if ~DynareOptions.bytecode
|
|
|
|
check1 = max(abs(feval([Model.fname '_static'],...
|
|
|
|
DynareResults.steady_state,...
|
|
|
|
[DynareResults.exo_steady_state; ...
|
|
|
|
DynareResults.exo_det_steady_state], Model.params))) > DynareOptions.dynatol ;
|
2010-11-20 15:21:27 +01:00
|
|
|
else
|
2011-09-19 17:18:40 +02:00
|
|
|
[info, res] = bytecode('static','evaluate',DynareResults.steady_state,...
|
|
|
|
[DynareResults.exo_steady_state; ...
|
|
|
|
DynareResults.exo_det_steady_state], Model.params);
|
|
|
|
check1 = max(abs(res)) > DynareOptions.dynatol;
|
2010-11-20 15:21:27 +01:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
if check1
|
2011-09-19 17:18:40 +02:00
|
|
|
error(['The seadystate values returned by ' Model.fname ...
|
2009-12-16 18:17:34 +01:00
|
|
|
'_steadystate.m don''t solve the static model!' ])
|
|
|
|
end
|
|
|
|
end
|
2007-10-01 13:53:28 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if info(1) > 0
|
|
|
|
disp('Error in computing likelihood for initial parameter values')
|
2011-09-19 17:18:40 +02:00
|
|
|
print_info(info, DynareOptions.noprint)
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
2011-09-19 17:51:03 +02:00
|
|
|
if any(abs(DynareResults.steady_state(BayesInfo.mfys))>1e-9) && (DynareOptions.prefilter==1)
|
2009-12-16 18:17:34 +01:00
|
|
|
disp(['You are trying to estimate a model with a non zero steady state for the observed endogenous'])
|
|
|
|
disp(['variables using demeaned data!'])
|
|
|
|
error('You should change something in your mod file...')
|
|
|
|
end
|
|
|
|
|
|
|
|
disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]);
|