diff --git a/matlab/cli/prior.m b/matlab/cli/prior.m index c5c25330e435b8443406fd6450eac67301da7fd3..1fb8a01b2e926038c8d601b20cff841e318060c5 100644 --- a/matlab/cli/prior.m +++ b/matlab/cli/prior.m @@ -59,7 +59,7 @@ if (size(estim_params_.var_endo,1) || size(estim_params_.corrn,1)) end % Fill or update bayestopt_ structure -[xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_); +[xparam1, EstimatedParams, BayesOptions, lb, ub, Model] = set_prior(estim_params_, M_, options_); % Temporarly change qz_criterium option value @@ -69,24 +69,24 @@ if isempty(options_.qz_criterium) changed_qz_criterium_flag = 1; end -M_.dname = M_.fname; +Model.dname = Model.fname; % Temporarly set options_.order equal to one order = options_.order; options_.order = 1; if ismember('plot', varargin) - plot_priors(bayestopt_,M_,estim_params_,options_) + plot_priors(BayesOptions, Model, EstimatedParams, options_) donesomething = true; end if ismember('table', varargin) - print_table_prior(lb, ub, options_, M_, bayestopt_, estim_params_); + print_table_prior(lb, ub, options_, Model, BayesOptions, EstimatedParams); donesomething = true; end if ismember('simulate', varargin) % Prior simulations (BK). - results = prior_sampler(0,M_,bayestopt_,options_,oo_,estim_params_); + results = prior_sampler(0, Model, BayesOptions, options_, oo_, EstimatedParams); % Display prior mass info skipline(2) disp(['Prior mass = ' num2str(results.prior.mass)]) @@ -103,26 +103,27 @@ if ismember('simulate', varargin) % Prior simulations (BK). end if ismember('optimize', varargin) % Prior optimization. - optimize_prior(options_, M_, oo_, bayestopt_, estim_params_); + optimize_prior(options_, Model, oo_, BayesOptions, EstimatedParams); donesomething = true; end if ismember('moments', varargin) % Prior simulations (2nd order moments). % Set estimated parameters to the prior mode... - xparam1 = bayestopt_.p5; + xparam1 = BayesOptions.p5; % ... Except for uniform priors! k = find(isnan(xparam1)); - xparam1(k) = bayestopt_.p5(k); + xparam1(k) = BayesOptions.p5(k); % Update vector of parameters and covariance matrices - M_ = set_all_parameters(xparam1,estim_params_,M_); + Model = set_all_parameters(xparam1, EstimatedParams, Model); % Check model. - check_model(M_); + check_model(Model); % Compute state space representation of the model. - oo_.dr=set_state_space(oo_.dr, M_, options_); + oo__ = oo_; + oo__.dr = set_state_space(oo__.dr, Model, options_); % Solve model - [dr,info, M_ ,options_ , oo_] = resol(0, M_ , options_ ,oo_); + [dr, info, Model , options__ , oo__] = resol(0, Model , options_ ,oo__); % Compute and display second order moments - oo_=disp_th_moments(oo_.dr,[],M_,options_,oo_); + oo__ = disp_th_moments(oo__.dr, [], Model, options__, oo__); skipline(2) donesomething = true; end @@ -137,7 +138,7 @@ if ~donesomething error('prior: Unexpected arguments!') end -function format_string = build_format_string(PriorStandardDeviation,LowerBound,UpperBound) +function format_string = build_format_string(PriorStandardDeviation, LowerBound, UpperBound) format_string = ['%s & %s & %6.4f &']; if ~isnumeric(PriorStandardDeviation) format_string = [ format_string , ' %s &']; diff --git a/matlab/write_latex_prior_table.m b/matlab/write_latex_prior_table.m index 8d841605db0de04a467bec0e731ccc2a5ae2ef99..46a5e3bf5258d6f955c93fbfffb6794369869493 100644 --- a/matlab/write_latex_prior_table.m +++ b/matlab/write_latex_prior_table.m @@ -45,16 +45,16 @@ if (size(estim_params_.var_endo,1) || size(estim_params_.corrn,1)) end % Fill or update bayestopt_ structure -[xparam1, estim_params_, bayestopt_, lb, ub, M_] = set_prior(estim_params_, M_, options_); +[xparam1, EstimatedParameters, BayesOptions, lb, ub, Model] = set_prior(estim_params_, M_, options_); % Get untruncated bounds -bounds = prior_bounds(bayestopt_, options_.prior_trunc); +bounds = prior_bounds(BayesOptions, options_.prior_trunc); lb=bounds.lb; ub=bounds.ub; PriorNames = { 'Beta' , 'Gamma' , 'Gaussian' , 'Inv. Gamma' , 'Uniform' , 'Inv. Gamma -- 2', '', 'Weibull' }; -fidTeX = fopen([M_.fname '_priors_table.tex'],'w+'); +fidTeX = fopen([Model.fname '_priors_table.tex'],'w+'); fprintf(fidTeX,'%% TeX-table generated by Dynare write_latex_prior_table.m.\n'); fprintf(fidTeX,'%% Prior Information\n'); fprintf(fidTeX,['%% ' datestr(now,0)]); @@ -107,17 +107,17 @@ fprintf(fidTeX,'\\endlastfoot\n'); % Column 6: the upper bound of the prior density support. % Column 7: the lower bound of the interval containing 90% of the prior mass. % Column 8: the upper bound of the interval containing 90% of the prior mass. -PriorIntervals = prior_bounds(bayestopt_,(1-options_.prior_interval)/2) ; -for i=1:size(bayestopt_.name,1) - [tmp,TexName] = get_the_name(i,1,M_,estim_params_,options_); - PriorShape = PriorNames{ bayestopt_.pshape(i) }; - PriorMean = bayestopt_.p1(i); - PriorMode = bayestopt_.p5(i); - PriorStandardDeviation = bayestopt_.p2(i); - switch bayestopt_.pshape(i) +PriorIntervals = prior_bounds(BayesOptions,(1-options_.prior_interval)/2) ; +for i=1:size(BayesOptions.name,1) + [tmp,TexName] = get_the_name(i, 1, Model, EstimatedParameters, options_); + PriorShape = PriorNames{ BayesOptions.pshape(i) }; + PriorMean = BayesOptions.p1(i); + PriorMode = BayesOptions.p5(i); + PriorStandardDeviation = BayesOptions.p2(i); + switch BayesOptions.pshape(i) case { 1 , 5 } - LowerBound = bayestopt_.p3(i); - UpperBound = bayestopt_.p4(i); + LowerBound = BayesOptions.p3(i); + UpperBound = BayesOptions.p4(i); if ~isinf(lb(i)) LowerBound=max(LowerBound,lb(i)); end @@ -125,7 +125,7 @@ for i=1:size(bayestopt_.name,1) UpperBound=min(UpperBound,ub(i)); end case { 2 , 4 , 6, 8 } - LowerBound = bayestopt_.p3(i); + LowerBound = BayesOptions.p3(i); if ~isinf(lb(i)) LowerBound=max(LowerBound,lb(i)); end @@ -135,18 +135,18 @@ for i=1:size(bayestopt_.name,1) UpperBound = '$\infty$'; end case 3 - if isinf(bayestopt_.p3(i)) && isinf(lb(i)) + if isinf(BayesOptions.p3(i)) && isinf(lb(i)) LowerBound = '$-\infty$'; else - LowerBound = bayestopt_.p3(i); + LowerBound = BayesOptions.p3(i); if ~isinf(lb(i)) LowerBound=max(LowerBound,lb(i)); end end - if isinf(bayestopt_.p4(i)) && isinf(ub(i)) + if isinf(BayesOptions.p4(i)) && isinf(ub(i)) UpperBound = '$\infty$'; else - UpperBound = bayestopt_.p4(i); + UpperBound = BayesOptions.p4(i); if ~isinf(ub(i)) UpperBound=min(UpperBound,ub(i)); end