From 9238523c2667d11982964e0810f3a43f34e864d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Sat, 16 Nov 2013 23:26:19 +0100 Subject: [PATCH] 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. --- matlab/DsgeVarLikelihood.m | 27 ++------------------- matlab/check_dsge_var_model.m | 44 +++++++++++++++++++++++++++++++++++ matlab/dynare_estimation_1.m | 4 ++++ 3 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 matlab/check_dsge_var_model.m diff --git a/matlab/DsgeVarLikelihood.m b/matlab/DsgeVarLikelihood.m index 9b57abcd2..322351a2c 100644 --- a/matlab/DsgeVarLikelihood.m +++ b/matlab/DsgeVarLikelihood.m @@ -35,7 +35,6 @@ function [fval,grad,hess,exit_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihoo % along with Dynare. If not, see . 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; diff --git a/matlab/check_dsge_var_model.m b/matlab/check_dsge_var_model.m new file mode 100644 index 000000000..b10815ac8 --- /dev/null +++ b/matlab/check_dsge_var_model.m @@ -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 . + +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 diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 6330dd87a..80dee69cf 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -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_);