2014-06-23 10:55:08 +02:00
|
|
|
function bvar = dsgevar_posterior_density(deep,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults)
|
2011-09-22 11:17:31 +02:00
|
|
|
% This function characterizes the posterior distribution of a bvar with
|
|
|
|
% a dsge prior (as in Del Negro and Schorfheide 2003) for a given value
|
|
|
|
% of the deep parameters (structural parameters + the size of the
|
2008-03-10 17:08:02 +01:00
|
|
|
% shocks + dsge_prior_weight).
|
2011-09-22 11:17:31 +02:00
|
|
|
%
|
2008-03-10 17:08:02 +01:00
|
|
|
% INPUTS
|
|
|
|
% deep: [double] a vector with the deep parameters.
|
2011-09-22 11:17:31 +02:00
|
|
|
%
|
2008-03-10 17:08:02 +01:00
|
|
|
% OUTPUTS
|
2011-09-22 11:17:31 +02:00
|
|
|
% bvar: a matlab structure with prior and posterior densities.
|
|
|
|
%
|
2008-03-10 17:08:02 +01:00
|
|
|
% ALGORITHM
|
|
|
|
% ...
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
2011-09-22 11:17:31 +02:00
|
|
|
%
|
2008-08-01 14:40:33 +02:00
|
|
|
|
2012-06-08 18:22:34 +02:00
|
|
|
% Copyright (C) 1996-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/>.
|
|
|
|
|
2014-07-15 11:12:14 +02:00
|
|
|
gend = DynareDataset.nobs;
|
2008-03-10 17:08:02 +01:00
|
|
|
dsge_prior_weight = M_.params(strmatch('dsge_prior_weight',M_.param_names));
|
|
|
|
DSGE_PRIOR_WEIGHT = floor(gend*(1+dsge_prior_weight));
|
|
|
|
|
|
|
|
bvar.NumberOfLags = options_.varlag;
|
2013-05-21 16:38:17 +02:00
|
|
|
bvar.NumberOfVariables = length(options_.varobs);
|
2008-03-10 17:08:02 +01:00
|
|
|
bvar.Constant = 'no';
|
2011-09-22 11:17:31 +02:00
|
|
|
bvar.NumberOfEstimatedParameters = bvar.NumberOfLags*bvar.NumberOfVariables;
|
2008-03-18 11:28:53 +01:00
|
|
|
if ~options_.noconstant
|
2008-03-10 17:08:02 +01:00
|
|
|
bvar.Constant = 'yes';
|
|
|
|
bvar.NumberOfEstimatedParameters = bvar.NumberOfEstimatedParameters + ...
|
2011-09-22 11:17:31 +02:00
|
|
|
bvar.NumberOfVariables;
|
2008-03-10 17:08:02 +01:00
|
|
|
end
|
|
|
|
|
2015-10-09 14:21:26 +02:00
|
|
|
[fval,cost_flag,info,PHI,SIGMAu,iXX,prior] = dsge_var_likelihood(deep',DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
|
2008-03-10 17:08:02 +01:00
|
|
|
|
|
|
|
% Conditionnal posterior density of the lagged matrices (given Sigma) ->
|
|
|
|
% Matric-variate normal distribution.
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.posterior.density = 'matric-variate normal';
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.posterior.arg1 = PHI;
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.posterior.arg2 = 'Sigma';
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.posterior.arg3 = iXX;
|
|
|
|
|
2011-09-22 11:17:31 +02:00
|
|
|
% Marginal posterior density of the covariance matrix -> Inverted Wishart.
|
2008-03-10 17:08:02 +01:00
|
|
|
bvar.Sigma.posterior.density = 'inverse wishart';
|
|
|
|
bvar.Sigma.posterior.arg1 = SIGMAu*DSGE_PRIOR_WEIGHT;
|
|
|
|
bvar.Sigma.posterior.arg2 = DSGE_PRIOR_WEIGHT-bvar.NumberOfEstimatedParameters;
|
|
|
|
|
2011-09-22 11:17:31 +02:00
|
|
|
% Marginal posterior density of the lagged matrices -> Generalized
|
2008-03-10 17:08:02 +01:00
|
|
|
% Student distribution (See appendix B.5 in Zellner (1971)).
|
|
|
|
bvar.LaggedMatrices.posterior.density = 'matric-variate student';
|
|
|
|
bvar.LaggedMatrices.posterior.arg1 = inv(iXX);%P
|
|
|
|
bvar.LaggedMatrices.posterior.arg2 = SIGMAu*DSGE_PRIOR_WEIGHT;%Q
|
|
|
|
bvar.LaggedMatrices.posterior.arg3 = PHI;%M (posterior mean)
|
|
|
|
bvar.LaggedMatrices.posterior.arg4 = DSGE_PRIOR_WEIGHT;%(sample size)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
% Conditionnal posterior density of the lagged matrices (given Sigma) ->
|
|
|
|
% Matric-variate normal distribution.
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.prior.density = 'matric-variate normal';
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.prior.arg1 = prior.PHIstar;
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.prior.arg2 = 'Sigma';
|
|
|
|
bvar.LaggedMatricesConditionalOnSigma.prior.arg3 = prior.iGXX;
|
|
|
|
|
2011-09-22 11:17:31 +02:00
|
|
|
% Marginal posterior density of the covariance matrix -> Inverted Wishart.
|
2008-03-10 17:08:02 +01:00
|
|
|
bvar.Sigma.prior.density = 'inverse wishart';
|
|
|
|
bvar.Sigma.prior.arg1 = prior.SIGMAstar*prior.ArtificialSampleSize;
|
|
|
|
bvar.Sigma.prior.arg2 = prior.DF;
|
|
|
|
|
2011-09-22 11:17:31 +02:00
|
|
|
% Marginal posterior density of the lagged matrices -> Generalized
|
2008-03-10 17:08:02 +01:00
|
|
|
% Student distribution (See appendix B.5 in Zellner (1971)).
|
|
|
|
bvar.LaggedMatrices.prior.density = 'matric-variate student';
|
2008-03-18 11:28:53 +01:00
|
|
|
bvar.LaggedMatrices.prior.arg1 = inv(prior.iGXX);%P
|
2008-03-10 17:08:02 +01:00
|
|
|
bvar.LaggedMatrices.prior.arg2 = prior.SIGMAstar*prior.ArtificialSampleSize;%Q
|
|
|
|
bvar.LaggedMatrices.prior.arg3 = prior.PHIstar;%M (posterior mean)
|
|
|
|
bvar.LaggedMatrices.prior.arg4 = prior.ArtificialSampleSize;%(sample size)
|