From a1aa2bcd6ec6cfea13b85fefc3a55fd62db6e39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Sat, 5 Dec 2015 11:18:01 +0100 Subject: [PATCH] Changed second input of prior_bounds routine. Do not pass options_ structure but only the required field (prior_trunc). --- matlab/PosteriorIRF_core1.m | 2 +- matlab/dynare_estimation_1.m | 2 +- matlab/dynare_estimation_init.m | 2 +- matlab/evaluate_likelihood.m | 2 +- matlab/gsa/prior_draw_gsa.m | 2 +- matlab/gsa/redform_map.m | 2 +- matlab/gsa/stab_map_.m | 2 +- matlab/identification_analysis.m | 2 +- matlab/print_table_prior.m | 2 +- matlab/prior_bounds.m | 3 +-- matlab/prior_draw.m | 27 +++++++++++++++------------ 11 files changed, 25 insertions(+), 23 deletions(-) diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m index cbfe2ee31..5213637b9 100644 --- a/matlab/PosteriorIRF_core1.m +++ b/matlab/PosteriorIRF_core1.m @@ -77,7 +77,7 @@ if options_.dsge_var NumberOfLagsTimesNvobs = myinputs.NumberOfLagsTimesNvobs; Companion_matrix = myinputs.Companion_matrix; stock_irf_bvardsge = zeros(options_.irf,nvobs,M_.exo_nbr,MAX_nirfs_dsgevar); - bounds = prior_bounds(bayestopt_,options_); + bounds = prior_bounds(bayestopt_,options_.prior_trunc); end diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 55b40654c..58ee4fef4 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -427,7 +427,7 @@ end if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ... (any(bayestopt_.pshape >0 ) && options_.load_mh_file) %% not ML estimation - bounds = prior_bounds(bayestopt_,options_); + bounds = prior_bounds(bayestopt_, options_.prior_trunc); outside_bound_pars=find(xparam1 < bounds.lb | xparam1 > bounds.ub); if ~isempty(outside_bound_pars) for ii=1:length(outside_bound_pars) diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m index 8aac9ef33..81e0b7e04 100644 --- a/matlab/dynare_estimation_init.m +++ b/matlab/dynare_estimation_init.m @@ -315,7 +315,7 @@ if ~isempty(estim_params_) && ~all(strcmp(fieldnames(estim_params_),'full_calibr plot_priors(bayestopt_,M_,estim_params_,options_) end % Set prior bounds - bounds = prior_bounds(bayestopt_,options_); + bounds = prior_bounds(bayestopt_, options_.prior_trunc); bounds.lb = max(bounds.lb,lb); bounds.ub = min(bounds.ub,ub); else % estimated parameters but no declared priors diff --git a/matlab/evaluate_likelihood.m b/matlab/evaluate_likelihood.m index 7e6c1f087..39affdc5e 100644 --- a/matlab/evaluate_likelihood.m +++ b/matlab/evaluate_likelihood.m @@ -70,6 +70,6 @@ if isempty(dataset) [dataset, dataset_info] = makedataset(options_); end -llik = -dsge_likelihood(parameters,dataset,dataset_info,options_,M_,estim_params_,bayestopt_,prior_bounds(bayestopt_,options_),oo_); +llik = -dsge_likelihood(parameters,dataset,dataset_info,options_,M_,estim_params_,bayestopt_,prior_bounds(bayestopt_,options_.prior_trunc),oo_); ldens = evaluate_prior(parameters); llik = llik - ldens; \ No newline at end of file diff --git a/matlab/gsa/prior_draw_gsa.m b/matlab/gsa/prior_draw_gsa.m index 5dc30b79f..cbde56e5d 100644 --- a/matlab/gsa/prior_draw_gsa.m +++ b/matlab/gsa/prior_draw_gsa.m @@ -58,7 +58,7 @@ if init [junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0) % Set prior bounds - bounds = prior_bounds(bayestopt_,options_); + bounds = prior_bounds(bayestopt_, options_.prior_trunc); bounds.lb = max(bounds.lb,lb); bounds.ub = min(bounds.ub,ub); else % estimated parameters but no declared priors diff --git a/matlab/gsa/redform_map.m b/matlab/gsa/redform_map.m index 448b1a634..1bb76f401 100644 --- a/matlab/gsa/redform_map.m +++ b/matlab/gsa/redform_map.m @@ -56,7 +56,7 @@ pvalue_corr = options_gsa_.alpha2_redform; pnames = M_.param_names(estim_params_.param_vals(:,1),:); fname_ = M_.fname; -bounds = prior_bounds(bayestopt_,options_); +bounds = prior_bounds(bayestopt_, options_.prior_trunc); if nargin==0, dirname=''; diff --git a/matlab/gsa/stab_map_.m b/matlab/gsa/stab_map_.m index c52b381e4..767d82fa6 100644 --- a/matlab/gsa/stab_map_.m +++ b/matlab/gsa/stab_map_.m @@ -99,7 +99,7 @@ p4 = bayestopt_.p4(nshock+1:end); [junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0) % Set prior bounds - bounds = prior_bounds(bayestopt_,options_); + bounds = prior_bounds(bayestopt_, options_.trunc); bounds.lb = max(bounds.lb,lb); bounds.ub = min(bounds.ub,ub); else % estimated parameters but no declared priors diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m index 7eac2d199..b948d91a1 100644 --- a/matlab/identification_analysis.m +++ b/matlab/identification_analysis.m @@ -147,7 +147,7 @@ if info(1)==0, info = stoch_simul(char(options_.varobs)); dataset_ = dseries(oo_.endo_simul(options_.varobs_id,100+1:end)',dates('1Q1'), options_.varobs); derivatives_info.no_DLIK=1; - bounds = prior_bounds(bayestopt_,options_); + bounds = prior_bounds(bayestopt_, options_.prior_trunc); [fval,DLIK,AHess,cost_flag,ys,trend_coeff,info,M_,options_,bayestopt_,oo_] = dsge_likelihood(params',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_,derivatives_info); % fval = DsgeLikelihood(xparam1,data_info,options_,M_,estim_params_,bayestopt_,oo_); options_.analytic_derivation = analytic_derivation; diff --git a/matlab/print_table_prior.m b/matlab/print_table_prior.m index 26e60fc4b..605adfabf 100644 --- a/matlab/print_table_prior.m +++ b/matlab/print_table_prior.m @@ -38,7 +38,7 @@ T2 = strvcat(T2, l2); prior_trunc_backup = DynareOptions.prior_trunc ; DynareOptions.prior_trunc = (1-DynareOptions.prior_interval)/2 ; -PriorIntervals = prior_bounds(BayesInfo,DynareOptions) ; +PriorIntervals = prior_bounds(BayesInfo, DynareOptions.prior_trunc) ; DynareOptions.prior_trunc = prior_trunc_backup ; RESIZE = false; diff --git a/matlab/prior_bounds.m b/matlab/prior_bounds.m index 66baf8494..c9f302b55 100644 --- a/matlab/prior_bounds.m +++ b/matlab/prior_bounds.m @@ -1,4 +1,4 @@ -function bounds = prior_bounds(bayestopt,options) +function bounds = prior_bounds(bayestopt, prior_trunc) %@info: %! @deftypefn {Function File} {@var{bounds} =} prior_bounds (@var{bayesopt},@var{option}) @@ -69,7 +69,6 @@ p3 = bayestopt.p3; p4 = bayestopt.p4; p6 = bayestopt.p6; p7 = bayestopt.p7; -prior_trunc = options.prior_trunc; bounds.lb = zeros(length(p6),1); bounds.ub = zeros(length(p6),1); diff --git a/matlab/prior_draw.m b/matlab/prior_draw.m index 1436406c0..600e6881f 100644 --- a/matlab/prior_draw.m +++ b/matlab/prior_draw.m @@ -51,7 +51,7 @@ if nargin>0 && init p7 = evalin('base', 'bayestopt_.p7'); p3 = evalin('base', 'bayestopt_.p3'); p4 = evalin('base', 'bayestopt_.p4'); - bounds = evalin('base', 'prior_bounds(bayestopt_,options_)'); + bounds = evalin('base', 'prior_bounds(bayestopt_, options_.prior_trunc)'); lb = bounds.lb; ub = bounds.ub; number_of_estimated_parameters = length(p6); @@ -173,6 +173,9 @@ if weibull_draws end end + + + %@test:1 %$ %% Initialize required structures %$ options_.prior_trunc=0; @@ -190,17 +193,17 @@ end %$ estim_params_.param_vals = [1, NaN, (-Inf), Inf, 1, 0.356, 0.02, NaN, NaN, NaN ]; %$ %$ %% beta -%$ estim_params_.param_vals(1,3)= -Inf;%LB -%$ estim_params_.param_vals(1,4)= +Inf;%UB -%$ estim_params_.param_vals(1,5)= 1;%Shape +%$ estim_params_.param_vals(1,3)= -Inf; % LB +%$ estim_params_.param_vals(1,4)= +Inf; % UB +%$ estim_params_.param_vals(1,5)= 1; % Shape %$ estim_params_.param_vals(1,6)=0.5; %$ estim_params_.param_vals(1,7)=0.01; %$ estim_params_.param_vals(1,8)=NaN; %$ estim_params_.param_vals(1,9)=NaN; %$ -%$ [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_); -%$ -%$ pdraw = prior_draw(1,0); +%$ [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_) +%$ +%$ pdraw = prior_draw(1,0); pdraw %$ pdraw_vec=NaN(ndraws,1); %$ for ii=1:ndraws %$ pdraw_vec(ii)=prior_draw(0,0); @@ -437,7 +440,7 @@ end %$ estim_params_.param_vals(1,9)=3; %$ %$ [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_); -%$ bounds = prior_bounds(bayestopt_,options_)'; +%$ bounds = prior_bounds(bayestopt_,options_.prior_trunc)'; %$ %$ pdraw = prior_draw(1,0); %$ pdraw_vec=NaN(ndraws,1); @@ -459,7 +462,7 @@ end %$ estim_params_.param_vals(1,9)=NaN; %$ %$ [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_); -%$ bounds = prior_bounds(bayestopt_,options_)'; +%$ bounds = prior_bounds(bayestopt_,options_.prior_trunc)'; %$ %$ pdraw = prior_draw(1,0); %$ pdraw_vec=NaN(ndraws,1); @@ -481,7 +484,7 @@ end %$ estim_params_.param_vals(1,9)=NaN; %$ %$ [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_); -%$ bounds = prior_bounds(bayestopt_,options_)'; +%$ bounds = prior_bounds(bayestopt_,options_.prior_trunc)'; %$ %$ pdraw = prior_draw(1,0); %$ pdraw_vec=NaN(ndraws,1); @@ -503,7 +506,7 @@ end %$ estim_params_.param_vals(1,9)=NaN; %$ %$ [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_); -%$ bounds = prior_bounds(bayestopt_,options_)'; +%$ bounds = prior_bounds(bayestopt_,options_.prior_trunc)'; %$ %$ pdraw = prior_draw(1,0); %$ pdraw_vec=NaN(ndraws,1); @@ -526,7 +529,7 @@ end %$ estim_params_.param_vals(1,9)=NaN; %$ %$ [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_); -%$ bounds = prior_bounds(bayestopt_,options_)'; +%$ bounds = prior_bounds(bayestopt_,options_.prior_trunc)'; %$ %$ pdraw = prior_draw(1,0); %$ pdraw_vec=NaN(ndraws,1);