From cf19df92efb751913c77ef41eae96590c3b17f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Mon, 5 Mar 2012 15:03:55 +0100 Subject: [PATCH] Added an option fot the mode_check plots for defining the size of the neighbourhood around the estimated posterior mode. --- matlab/global_initialization.m | 2 ++ matlab/mode_check.m | 58 +++++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index c16e7729b..d01977716 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -57,6 +57,8 @@ options_.solve_tolf = eps^(1/3); options_.solve_tolx = eps^(2/3); options_.solve_maxit = 500; +options_.mode_check_neighbourhood_size = 0.5; + % Default number of threads for parallelized mex files. options_.threads.kronecker.A_times_B_kronecker_C = 1; options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = 1; diff --git a/matlab/mode_check.m b/matlab/mode_check.m index 36d516c89..fe62d6ddd 100644 --- a/matlab/mode_check.m +++ b/matlab/mode_check.m @@ -1,4 +1,43 @@ function mode_check(fun,x,hessian,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults) +% Checks the estimated ML mode or Posterior mode. + +%@info: +%! @deftypefn {Function File} {@var{y}, @var{y_} =} sequential_importance_particle_filter (@var{ReducedForm},@var{Y}, @var{start}, @var{DynareOptions}) +%! @anchor{particle/sequential_importance_particle_filter} +%! @sp 1 +%! Checks the estimated ML mode or Posterior mode by plotting sections of the likelihood/posterior kernel. +%! Each plot shows the variation of the likelihood implied by the variations of a single parameter, ceteris paribus) +%! @sp 2 +%! @strong{Inputs} +%! @sp 1 +%! @table @ @var +%! @item ReducedForm +%! Structure describing the state space model (built in @ref{non_linear_dsge_likelihood}). +%! @item Y +%! p*smpl matrix of doubles (p is the number of observed variables), the (detrended) data. +%! @item start +%! Integer scalar, likelihood evaluation starts at observation 'start'. +%! @item DynareOptions +%! Structure specifying Dynare's options. +%! @end table +%! @sp 2 +%! @strong{Outputs} +%! @sp 1 +%! @table @ @var +%! @item LIK +%! double scalar, value of (minus) the logged likelihood. +%! @item lik +%! smpl*1 vector of doubles, density of the observations at each period. +%! @end table +%! @sp 2 +%! @strong{This function is called by:} +%! @ref{non_linear_dsge_likelihood} +%! @sp 2 +%! @strong{This function calls:} +%! +%! @end deftypefn +%@eod: + % function mode_check(x,fval,hessian,gend,data,lb,ub) % Checks the maximum likelihood mode @@ -18,7 +57,7 @@ function mode_check(fun,x,hessian,DynareDataset,DynareOptions,Model,EstimatedPar % SPECIAL REQUIREMENTS % none -% Copyright (C) 2003-2010 Dynare Team +% Copyright (C) 2003-2010, 2012 Dynare Team % % This file is part of Dynare. % @@ -62,6 +101,8 @@ if TeX fprintf(fidTeX,' \n'); end +ll = DynareOptions.mode_check_neighbourhood_size; + for plt = 1:nbplt, if TeX NAMES = []; @@ -82,9 +123,18 @@ for plt = 1:nbplt, end end xx = x; - l1 = max(BayesInfo.lb(kk),0.5*x(kk)); - l2 = min(BayesInfo.ub(kk),1.5*x(kk)); - z = [l1:(l2-l1)/20:l2]; + l1 = max(BayesInfo.lb(kk),(1-ll)*x(kk)); m1 = 0; + l2 = min(BayesInfo.ub(kk),(1+ll)*x(kk)); + if l2<(1+ll)*x(kk) + l1 = x(kk) - (l2-x(kk)); + m1 = 1; + end + if ~m1 && (l1>(1-ll)*x(kk)) && (x(kk)+(x(kk)-l1)