2009-10-16 23:01:52 +02:00
|
|
|
function [llik,parameters] = evaluate_likelihood(parameters)
|
|
|
|
% Evaluate the logged likelihood at parameters.
|
|
|
|
%
|
|
|
|
% INPUTS
|
2011-09-17 12:33:07 +02:00
|
|
|
% o parameters a string ('posterior mode','posterior mean','posterior median','prior mode','prior mean') or a vector of values for
|
2009-10-16 23:01:52 +02:00
|
|
|
% the (estimated) parameters of the model.
|
2011-09-17 12:33:07 +02:00
|
|
|
%
|
|
|
|
%
|
2009-10-16 23:01:52 +02:00
|
|
|
% OUTPUTS
|
|
|
|
% o ldens [double] value of the sample logged density at parameters.
|
|
|
|
% o parameters [double] vector of values for the estimated parameters.
|
2011-09-17 12:33:07 +02:00
|
|
|
%
|
2009-10-16 23:01:52 +02:00
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% None
|
|
|
|
%
|
|
|
|
% REMARKS
|
|
|
|
% [1] This function cannot evaluate the likelihood of a dsge-var model...
|
2011-09-17 12:33:07 +02:00
|
|
|
% [2] This function use persistent variables for the dataset and the description of the missing observations. Consequently, if this function
|
2009-10-16 23:01:52 +02:00
|
|
|
% is called more than once (by changing the value of parameters) the sample *must not* change.
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2012-06-08 18:22:34 +02:00
|
|
|
% Copyright (C) 2009-2012 Dynare Team
|
2009-10-16 23:01:52 +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/>.
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2011-10-22 15:30:23 +02:00
|
|
|
global options_ M_ bayestopt_ oo_ estim_params_
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2014-06-23 17:11:01 +02:00
|
|
|
persistent dataset dataset_info
|
2009-12-16 18:17:34 +01:00
|
|
|
|
|
|
|
if nargin==0
|
|
|
|
parameters = 'posterior mode';
|
|
|
|
end
|
|
|
|
|
|
|
|
if ischar(parameters)
|
|
|
|
switch parameters
|
|
|
|
case 'posterior mode'
|
|
|
|
parameters = get_posterior_parameters('mode');
|
|
|
|
case 'posterior mean'
|
|
|
|
parameters = get_posterior_parameters('mean');
|
|
|
|
case 'posterior median'
|
|
|
|
parameters = get_posterior_parameters('median');
|
|
|
|
case 'prior mode'
|
|
|
|
parameters = bayestopt_.p5(:);
|
|
|
|
case 'prior mean'
|
|
|
|
parameters = bayestopt_.p1;
|
|
|
|
otherwise
|
|
|
|
disp('eval_likelihood:: If the input argument is a string, then it has to be equal to:')
|
|
|
|
disp(' ''posterior mode'', ')
|
|
|
|
disp(' ''posterior mean'', ')
|
|
|
|
disp(' ''posterior median'', ')
|
|
|
|
disp(' ''prior mode'' or')
|
|
|
|
disp(' ''prior mean''.')
|
|
|
|
error
|
2009-10-16 23:01:52 +02:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
2011-10-22 15:30:23 +02:00
|
|
|
if isempty(dataset)
|
2014-06-23 17:11:01 +02:00
|
|
|
[dataset, dataset_info] = makedataset(options_);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
2015-12-05 11:18:01 +01:00
|
|
|
llik = -dsge_likelihood(parameters,dataset,dataset_info,options_,M_,estim_params_,bayestopt_,prior_bounds(bayestopt_,options_.prior_trunc),oo_);
|
2012-05-31 14:40:23 +02:00
|
|
|
ldens = evaluate_prior(parameters);
|
2014-06-23 17:11:01 +02:00
|
|
|
llik = llik - ldens;
|