If a DSGE-VAR is estimated, check that the user do not try to estimate/calibrate correlations between structural innovations and that there is no measurement errors. Closes #521.
parent
b7ff4d9f75
commit
9238523c26
|
@ -35,7 +35,6 @@ function [fval,grad,hess,exit_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihoo
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global objective_function_penalty_base
|
||||
% Declaration of the persistent variables.
|
||||
persistent dsge_prior_weight_idx
|
||||
|
||||
grad=[];
|
||||
|
@ -53,11 +52,7 @@ if isempty(dsge_prior_weight_idx)
|
|||
end
|
||||
|
||||
% Get the number of estimated (dsge) parameters.
|
||||
ns = EstimatedParameters.nvx + ...
|
||||
EstimatedParameters.nvn + ...
|
||||
EstimatedParameters.ncx + ...
|
||||
EstimatedParameters.ncn;
|
||||
nx = ns + EstimatedParameters.np;
|
||||
nx = EstimatedParameters.nvx + EstimatedParameters.np;
|
||||
|
||||
% Get the number of observed variables in the VAR model.
|
||||
NumberOfObservedVariables = DynareDataset.info.nvobs;
|
||||
|
@ -107,20 +102,6 @@ for i=1:EstimatedParameters.nvx
|
|||
end
|
||||
offset = EstimatedParameters.nvx;
|
||||
|
||||
% Check that the user does not estimate measurment errors.
|
||||
% TODO Check that the user does not declare non estimated measurement errors...
|
||||
if EstimatedParameters.nvn
|
||||
disp('DsgeVarLikelihood :: Measurement errors are not implemented!')
|
||||
return
|
||||
end
|
||||
|
||||
% Check that the user does not estimate off diagonal elements in the covariance matrix of the structural innovation.
|
||||
% TODO Check that Q is a diagonal matrix...
|
||||
if EstimatedParameters.ncx
|
||||
disp('DsgeVarLikelihood :: Correlated structural innovations are not implemented!')
|
||||
return
|
||||
end
|
||||
|
||||
% Update Model.params and Model.Sigma_e.
|
||||
Model.params(EstimatedParameters.param_vals(:,1)) = xparam1(offset+1:end);
|
||||
Model.Sigma_e = Q;
|
||||
|
@ -169,10 +150,6 @@ else
|
|||
constant = zeros(1,NumberOfObservedVariables);
|
||||
end
|
||||
|
||||
% Dsge-VAR with deterministic trends is not implemented
|
||||
if BayesInfo.with_trend == 1
|
||||
error('DsgeVarLikelihood :: Linear trend is not yet implemented!')
|
||||
end
|
||||
|
||||
%------------------------------------------------------------------------------
|
||||
% 3. theoretical moments (second order)
|
||||
|
@ -224,7 +201,7 @@ if ~isinf(dsge_prior_weight)% Evaluation of the likelihood of the dsge-var model
|
|||
tmp1 = dsge_prior_weight*DynareDataset.info.ntobs*GYX + mYX;
|
||||
tmp2 = inv(dsge_prior_weight*DynareDataset.info.ntobs*GXX+mXX);
|
||||
SIGMAu = tmp0 - tmp1*tmp2*tmp1'; clear('tmp0');
|
||||
[SIGMAu_is_positive_definite, penalty] = ispd(SIGMAu)
|
||||
[SIGMAu_is_positive_definite, penalty] = ispd(SIGMAu);
|
||||
if ~SIGMAu_is_positive_definite
|
||||
fval = objective_function_penalty_base + penalty;
|
||||
info = 52;
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
function check_dsge_var_model(Model, EstimatedParameters, BayesInfo)
|
||||
|
||||
% Check if the dsge model can be estimated with the DSGE-VAR approach.
|
||||
|
||||
% Copyright (C) 2013 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 EstimatedParameters.nvn
|
||||
error('DsgeVarLikelihood:: Measurement errors are not allowed!')
|
||||
end
|
||||
|
||||
if EstimatedParameters.ncn
|
||||
error('DsgeVarLikelihood:: Measurement errors are not allowed!')
|
||||
end
|
||||
|
||||
if any(vec(Model.H))
|
||||
error('DsgeVarLikelihood:: Measurement errors are not allowed!')
|
||||
end
|
||||
|
||||
if EstimatedParameters.ncx
|
||||
error('DsgeVarLikelihood:: Structural innovations cannot be correlated using Dynare''s interface! Introduce the correlations in the model block instead.')
|
||||
end
|
||||
|
||||
if Model.exo_nbr>1 && any(vec(tril(Model.Sigma_e,-1)))
|
||||
error('DsgeVarLikelihood:: Structural innovations cannot be correlated using Dynare''s interface! Introduce the correlations in the model block instead.')
|
||||
end
|
||||
|
||||
if isequal(BayesInfo.with_trend,1)
|
||||
error('DsgeVarLikelihood :: Linear trend is not yet implemented!')
|
||||
end
|
|
@ -80,6 +80,10 @@ end
|
|||
|
||||
[dataset_,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list_, dname, [], M_, options_, oo_, estim_params_, bayestopt_);
|
||||
|
||||
if options_.dsge_var
|
||||
check_dsge_var_model(M_, estim_params_, bayestopt_);
|
||||
end
|
||||
|
||||
%check for calibrated covariances before updating parameters
|
||||
if ~isempty(estim_params_)
|
||||
estim_params_=check_for_calibrated_covariances(xparam1,estim_params_,M_);
|
||||
|
|
Loading…
Reference in New Issue