Commit 73944a10 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Finish implementation of mcmc_jumping_covariance option

Closes #112, #514
parent 7dee2507
......@@ -4486,8 +4486,8 @@ value of that function as the posterior mode.
@noindent
Default value is @code{4}.
@item MCMC_jumping_covariance = hessian|prior_variance|identity_matrix|@var{filename}
Tells Dynare which covariance to use for the proposal density of the MCMC sampler. @code{MCMC_jumping_covariance} can be one of the following:
@item mcmc_jumping_covariance = hessian|prior_variance|identity_matrix|@var{FILENAME}
Tells Dynare which covariance to use for the proposal density of the MCMC sampler. @code{mcmc_jumping_covariance} can be one of the following:
@table @code
@item hessian
......@@ -4499,12 +4499,12 @@ Uses the prior variances. No infinite prior variances are allowed in this case.
@item identity_matrix
Uses an identity matrix.
@item filename
Loads an arbitrary user-specified covariance matrix from @code{filename.mat}. The covariance matrix must be saved in a variable named @code{jumping_covariance}, must be square, positive definite, and have the same dimension as the number of estimated parameters.
@item @var{FILENAME}
Loads an arbitrary user-specified covariance matrix from @code{@var{FILENAME}.mat}. The covariance matrix must be saved in a variable named @code{jumping_covariance}, must be square, positive definite, and have the same dimension as the number of estimated parameters.
@end table
@noindent
Note that the covariance matrices are stil scaled with @ref{mh_jscale}. Default value is @code{hessian}.
Note that the covariance matrices are still scaled with @ref{mh_jscale}. Default value is @code{hessian}.
@item mode_check
Tells Dynare to plot the posterior density for values around the
......
......@@ -113,7 +113,7 @@ class ParsingDriver;
%token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT
%token MFS MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER MIN MINIMAL_SOLVING_PERIODS
%token MODE_CHECK MODE_CHECK_NEIGHBOURHOOD_SIZE MODE_CHECK_SYMMETRIC_PLOTS MODE_CHECK_NUMBER_OF_POINTS MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL MCMC_JUMPING_COVARIANCE
%token <string_val> NAME
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS
%token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS
......@@ -151,7 +151,7 @@ class ParsingDriver;
%token VLISTLOG VLISTPER
%token RESTRICTION RESTRICTION_FNAME CROSS_RESTRICTIONS NLAGS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST
%token DUMMY_OBS NSTATES INDXSCALESSTATES NO_BAYESIAN_PRIOR SPECIFICATION SIMS_ZHA
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM EPS PDF FIG DR NONE PRIOR
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM EPS PDF FIG DR NONE PRIOR PRIOR_VARIANCE HESSIAN IDENTITY_MATRIX
%token GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD
%token INDXPARR INDXOVR INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
%token INDXESTIMA INDXGDLS EQ_MS FILTER_COVARIANCE FILTER_DECOMPOSITION
......@@ -1558,6 +1558,7 @@ estimation_options : o_datafile
| o_qz_zero_threshold
| o_taper_steps
| o_geweke_interval
| o_mcmc_jumping_covariance
;
list_optim_option : QUOTED_STRING COMMA QUOTED_STRING
......@@ -2677,6 +2678,14 @@ o_discretionary_tol: DISCRETIONARY_TOL EQUAL non_negative_number { driver.option
o_analytic_derivation : ANALYTIC_DERIVATION { driver.option_num("analytic_derivation", "1"); }
o_endogenous_prior : ENDOGENOUS_PRIOR { driver.option_num("endogenous_prior", "1"); }
o_use_univariate_filters_if_singularity_is_detected : USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED EQUAL INT_NUMBER { driver.option_num("use_univariate_filters_if_singularity_is_detected", $3); }
o_mcmc_jumping_covariance : MCMC_JUMPING_COVARIANCE EQUAL HESSIAN
{ driver.option_str("MCMC_jumping_covariance", $3); } | MCMC_JUMPING_COVARIANCE EQUAL PRIOR_VARIANCE
{ driver.option_str("MCMC_jumping_covariance", $3); }
| MCMC_JUMPING_COVARIANCE EQUAL IDENTITY_MATRIX
{ driver.option_str("MCMC_jumping_covariance", $3); }
| MCMC_JUMPING_COVARIANCE EQUAL filename
{ driver.option_str("MCMC_jumping_covariance", $3); }
;
range : symbol ':' symbol
{
......
......@@ -439,6 +439,19 @@ string eofbuff;
<DYNARE_STATEMENT>random_parameter_convergence_criterion {return token::RANDOM_PARAMETER_CONVERGENCE_CRITERION;}
<DYNARE_STATEMENT>tolf {return token::TOLF;}
<DYNARE_STATEMENT>instruments {return token::INSTRUMENTS;}
<DYNARE_STATEMENT>hessian {
yylval->string_val = new string(yytext);
return token::HESSIAN;
}
<DYNARE_STATEMENT>prior_variance {
yylval->string_val = new string(yytext);
return token::PRIOR_VARIANCE;
}
<DYNARE_STATEMENT>identity_matrix {
yylval->string_val = new string(yytext);
return token::IDENTITY_MATRIX;
}
<DYNARE_STATEMENT>mcmc_jumping_covariance {return token::MCMC_JUMPING_COVARIANCE;}
/* These four (var, varexo, varexo_det, parameters) are for change_type */
<DYNARE_STATEMENT>var { return token::VAR; }
......
......@@ -3,6 +3,7 @@ MODFILES = \
estimation/fs2000_mc4_mf.mod \
estimation/fs2000_mc6.mod \
estimation/fs2000_mc6_mf.mod \
estimation/fs2000_MCMC_jumping_covariance.mod \
gsa/ls2003.mod \
ramst.mod \
ramst_a.mod \
......@@ -309,7 +310,8 @@ EXTRA_DIST = \
third_order/comparison_policy_functions_dynare_mathematica.m \
third_order/policyfunctions.mat \
shock_decomposition/example1_calib_shock_decomp_data.mat \
shock_decomposition/fsdat_simul.m
shock_decomposition/fsdat_simul.m \
estimation/fs2000_MCMC_jumping_covariance_steadystate.m
TARGETS =
......@@ -417,3 +419,5 @@ clean-local:
ms-sbvar/*.dat \
ms-sbvar/tmv_rr_sr \
ms-sbvar/tmv_rr_tr
rm -f estimation/test_matrix.mat
......@@ -73,14 +73,13 @@ varobs gp_obs gy_obs;
options_.solve_tolf = 1e-12;
options_.mode_compute=4;
options_.plot_priors=0;
options_.MCMC_jumping_covariance='hessian';
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.8);
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.8,mcmc_jumping_covariance=hessian);
load fs2000_MCMC_jumping_covariance_mode hh;
jumping_covariance=diag(diag(hh));
save test_matrix jumping_covariance;
options_.MCMC_jumping_covariance='prior_variance';
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.01);
options_.MCMC_jumping_covariance='identity_matrix';
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.0001);
options_.MCMC_jumping_covariance='test_matrix';
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.8);
save test_matrix.mat jumping_covariance;
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.01,mcmc_jumping_covariance=prior_variance);
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.0001,mcmc_jumping_covariance=identity_matrix);
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.8,mcmc_jumping_covariance='test_matrix');
......@@ -18,7 +18,7 @@
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
function [ys,check] = fs2000_steadystate(ys,exe)
function [ys,check] = fs2000_MCMC_jumping_covariance_steadystate(ys,exe)
global M_
alp = M_.params(1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment