1function [oo_,M_,options_,bayestopt_,Smoothed_variables_declaration_order_deviation_form]=evaluate_smoother(parameters,var_list,M_,oo_,options_,bayestopt_,estim_params_) 2% Evaluate the smoother at parameters. 3% 4% INPUTS 5% o parameters a string ('posterior mode','posterior mean','posterior median','prior mode','prior mean','mle_mode','calibration') or a vector of values for 6% the (estimated) parameters of the model. 7% o var_list subset of endogenous variables 8% o M_ [structure] Definition of the model 9% o oo_ [structure] Storage of results 10% o options_ [structure] Options 11% o bayestopt_ [structure] describing the priors 12% o estim_params_ [structure] characterizing parameters to be estimated 13% 14% OUTPUTS 15% o oo [structure] results: 16% - SmoothedVariables 17% - SmoothedShocks 18% - FilteredVariablesShockDecomposition 19% - UpdatedVariables 20% - FilteredVariables 21% - SmoothedMeasurementErrors 22% - FilteredVariablesKStepAhead 23% - FilteredVariablesKStepAheadVariances 24% o M_ [structure] Definition of the model 25% o options_ [structure] Options; returns options_.first_obs 26% o bayestopt_ [structure] describing the priors; returns fields like bayestopt_.smoother_var_list from the smoother 27% o Smoothed_variables_declaration_order_deviation_form 28% Smoothed variables from the Kalman smoother in 29% order of declaration of variables (M_.endo_names) 30% in deviations from their respective mean, i.e. 31% without trend and constant part (used for shock_decomposition) 32% 33% SPECIAL REQUIREMENTS 34% None 35% 36% REMARKS 37% [1] This function use persistent variables for the dataset and the description of the missing observations. Consequently, if this function 38% is called more than once (by changing the value of parameters) the sample *must not* change. 39 40% Copyright (C) 2010-2020 Dynare Team 41% 42% This file is part of Dynare. 43% 44% Dynare is free software: you can redistribute it and/or modify 45% it under the terms of the GNU General Public License as published by 46% the Free Software Foundation, either version 3 of the License, or 47% (at your option) any later version. 48% 49% Dynare is distributed in the hope that it will be useful, 50% but WITHOUT ANY WARRANTY; without even the implied warranty of 51% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 52% GNU General Public License for more details. 53% 54% You should have received a copy of the GNU General Public License 55% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 56 57% store qz_criterium 58qz_criterium_old=options_.qz_criterium; 59 60if ischar(parameters) && strcmp(parameters,'calibration') 61 options_.smoother=1; 62end 63 64[dataset_,dataset_info,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list, M_.fname, [], M_, options_, oo_, estim_params_, bayestopt_); 65 66% set the qz_criterium 67options_=select_qz_criterium_value(options_); 68 69if nargin==0 70 parameters = 'posterior_mode'; 71end 72 73if ischar(parameters) 74 switch parameters 75 case 'posterior_mode' 76 parameters = get_posterior_parameters('mode',M_,estim_params_,oo_,options_); 77 case 'posterior_mean' 78 parameters = get_posterior_parameters('mean',M_,estim_params_,oo_,options_); 79 case 'posterior_median' 80 parameters = get_posterior_parameters('median',M_,estim_params_,oo_,options_); 81 case 'mle_mode' 82 parameters = get_posterior_parameters('mode',M_,estim_params_,oo_,options_,'mle_'); 83 case 'prior_mode' 84 parameters = bayestopt_.p5(:); 85 case 'prior_mean' 86 parameters = bayestopt_.p1; 87 case 'calibration' 88 if isempty(oo_.dr) 89 error('You must run ''stoch_simul'' first.'); 90 end 91 parameters = []; 92 otherwise 93 disp('evaluate_smoother:: If the input argument is a string, then it has to be equal to:') 94 disp(' ''posterior_mode'', ') 95 disp(' ''posterior_mean'', ') 96 disp(' ''posterior_median'', ') 97 disp(' ''prior_mode'' or') 98 disp(' ''prior_mean''.') 99 disp(' ''calibration''.') 100 error 101 end 102end 103 104[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,options_,bayestopt_] = ... 105 DsgeSmoother(parameters,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_); 106[oo_]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty); 107 108if nargout>4 109 Smoothed_variables_declaration_order_deviation_form=atT(oo_.dr.inv_order_var(bayestopt_.smoother_var_list),:); 110end 111 112%reset qz_criterium 113options_.qz_criterium=qz_criterium_old; 114oo_.gui.ran_calib_smoother = true; 115