diff --git a/NEWS b/NEWS index 3fcc13c7e..3ad74e2f2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,49 @@ +Announcement for Dynare 4.5.6 (on 2018-07-25) +============================================= + +We are pleased to announce the release of Dynare 4.5.6. + +This is a bugfix release. + +The Windows packages are already available for download at: + + http://www.dynare.org/download/dynare-stable + +The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. + +This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2018a) +and with GNU Octave versions 4.4. + +Here is a list of the problems identified in version 4.5.5 and that have been +fixed in version 4.5.6: + + - TaRB sampler: incorrect last posterior was returned if the last draw was + rejected. + + - Fixed online particle filter by drawing initial conditions in the prior + distribution. + + - Fixed evaluation of the likelihood in non linear / particle filters. + + - Added missing documented `montecarlo` option in Gaussian Filter and + Nonlinear Kalman Filter. + + - Added back a flag to deal with errors on Cholesky decomposition in the + Conditional Particle Filter. + + - Macroprocessor `length()` operator was returning 1 when applied to a + string. Macroprocessor now raises an error when `length()` operator is + called on an integer and return the number of characters when applied to a + string. + + - `mode_compute=8`: the error code during mode-finding was not correctly + handled, resulting in crashes. + + - Identification was not correctly displaying a message for collinear parameters + if there was no unidentified parameter present. + + + Announcement for Dynare 4.5.5 (on 2018-06-08) ============================================= diff --git a/matlab/particles b/matlab/particles index 857168ddf..66867386e 160000 --- a/matlab/particles +++ b/matlab/particles @@ -1 +1 @@ -Subproject commit 857168ddf8c2d386dac875da1ede31fd689be309 +Subproject commit 66867386ef5c70e8db69293af8a0e051488196f1 diff --git a/matlab/posterior_sampler_iteration.m b/matlab/posterior_sampler_iteration.m index 5b54e785e..a6366c1c2 100644 --- a/matlab/posterior_sampler_iteration.m +++ b/matlab/posterior_sampler_iteration.m @@ -4,16 +4,29 @@ function [par, logpost, accepted, neval] = posterior_sampler_iteration(TargetFu % posterior samplers % % INPUTS -% posterior_sampler_options: posterior sampler options -% options_: structure storing the options - +% TargetFun: string storing the objective function (e.g. 'dsge_likelihood.m') +% last_draw: parameter vector in last iteration +% last_posterior: value of the posterior in last iteration +% sampler_options: posterior sampler options +% dataset_: the dataset after required transformation +% dataset_info: Various informations about the dataset (descriptive statistics and missing observations). +% options_: structure storing the options +% M_: structure storing the model information +% estim_params_: structure storing information about estimated parameters +% bayestopt_: structure storing information about priors +% mh_bounds: structure containing prior bounds +% oo_: structure storing the results +% % OUTPUTS -% posterior_sampler_options: checked posterior sampler options +% par: last accepted parameter vector +% logpost: value of the posterior after current iteration +% accepted: share of proposed draws that were accepted +% neval: number of evaluations (>1 only for slice) % % SPECIAL REQUIREMENTS % none -% Copyright (C) 2015-16 Dynare Team +% Copyright (C) 2015-18 Dynare Team % % This file is part of Dynare. % @@ -121,28 +134,31 @@ switch posterior_sampling_method else logpost = -inf; end - %get ratio of proposal densities, required because proposal depends - %on current mode via Hessian and is thus not symmetric anymore - if strcmpi(sampler_options.proposal_distribution,'rand_multivariate_normal') - proposal_density_proposed_move_forward=multivariate_normal_pdf(proposed_par,xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); - proposal_density_proposed_move_backward=multivariate_normal_pdf(par_start_current_block',xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); - elseif strcmpi(sampler_options.proposal_distribution,'rand_multivariate_student') - proposal_density_proposed_move_forward=multivariate_student_pdf(proposed_par,xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); - proposal_density_proposed_move_backward=multivariate_student_pdf(par_start_current_block',xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); - end - accprob=logpost-last_posterior+ log(proposal_density_proposed_move_backward)-log(proposal_density_proposed_move_forward); %Formula (6), Chib/Ramamurthy - - if (logpost > -inf) && (log(rand) < accprob) - current_draw(indices(blocks==block_iter,1))=proposed_par; - last_posterior=logpost; - accepted_draws_counter =accepted_draws_counter +1; - else %no updating - %do nothing, keep old value + + if (logpost > -inf) + %get ratio of proposal densities, required because proposal depends + %on current mode via Hessian and is thus not symmetric anymore + if strcmpi(sampler_options.proposal_distribution,'rand_multivariate_normal') + proposal_density_proposed_move_forward=multivariate_normal_pdf(proposed_par,xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); + proposal_density_proposed_move_backward=multivariate_normal_pdf(par_start_current_block',xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); + elseif strcmpi(sampler_options.proposal_distribution,'rand_multivariate_student') + proposal_density_proposed_move_forward=multivariate_student_pdf(proposed_par,xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); + proposal_density_proposed_move_backward=multivariate_student_pdf(par_start_current_block',xopt_current_block',proposal_covariance_Cholesky_decomposition_upper,n); + end + accprob=logpost-last_posterior+ log(proposal_density_proposed_move_backward)-log(proposal_density_proposed_move_forward); %Formula (6), Chib/Ramamurthy + if (log(rand) < accprob) + current_draw(indices(blocks==block_iter,1))=proposed_par; + last_posterior=logpost; + accepted_draws_counter =accepted_draws_counter +1; + else %no updating + %do nothing, keep old value + end end end accepted=accepted_draws_counter/blocked_draws_counter; par = current_draw; neval=1; + logpost = last_posterior; %make sure not a temporary draw is returned; case 'independent_metropolis_hastings' neval = 1; ProposalFun = sampler_options.proposal_distribution; diff --git a/preprocessor b/preprocessor index 49e1c43ae..762f25abe 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 49e1c43aed1acd80237d7fe911603ac4dd52d67d +Subproject commit 762f25abe9ad2681c2a049ddcb0be85bcfcf1306 diff --git a/tests/Makefile.am b/tests/Makefile.am index 75741f226..0fc82c89b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -65,7 +65,7 @@ MODFILES = \ example1_with_tags.mod \ example1_irf_shocks.mod \ example1_abs_sign.mod \ - example1_macroif.mod \ + example1_macro.mod \ example1long.mod \ example2long.mod \ example2long_use_dll.mod \ diff --git a/tests/example1_macroif.mod b/tests/example1_macro.mod similarity index 58% rename from tests/example1_macroif.mod rename to tests/example1_macro.mod index 02749cc3b..34a81277f 100644 --- a/tests/example1_macroif.mod +++ b/tests/example1_macro.mod @@ -1,4 +1,5 @@ -// Example 1 from Collard's guide to Dynare +// Various tests for the macroprocessor + var y, c, k, a, h, b; varexo e, u; @@ -21,6 +22,39 @@ theta = 2.95; phi = 0.1; @#endif +@#define a = 5 +@#define b = 2*(a + 3)/4-1 +@#if b != 3 +@#error "Arithmetic problem" +@#endif + +@#define v = [ "a", 1, 2:3] +@#define empty = [] +@#define z = v[2:3] +@#if z != [ 1, [ 2, 3 ]] || length(v) != 3 || 5 in v || !("a" in v) || length(empty) != 0 +@#error "Array problem" +@#endif + +@#define w = [ 1 ] +@#for elt in v +@#define w = w + [ elt ] +@#endfor +@#if w != [ 1, "a", 1, 2:3] +@#error "For loop problem" +@#endif + +@#define s = "abcde" +@#if length(s) != 5 || s[3:4] != "cd" +@#error "String problem" +@#endif + +@#define f(y, z) = "@{y}bar@{z}" +@#if f("foo", "baz") != "foobarbaz" +@#error "Function problem" +@#endif + + + model; c*theta*h^(1+psi)=(1-alpha)*y; k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))