From 2cc8e061e6ec14fdaa850ca8ff728f6e1e76ad6a Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan.bastani@ens.fr>
Date: Mon, 23 May 2011 11:20:24 +0200
Subject: [PATCH] preprocessor: added dynare_sensitivity option

---
 doc/dynare.texi             | 5 +++++
 matlab/dynare_sensitivity.m | 1 +
 preprocessor/DynareBison.yy | 4 +++-
 preprocessor/DynareFlex.ll  | 1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doc/dynare.texi b/doc/dynare.texi
index e9efb9323..a469673a1 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -4915,6 +4915,11 @@ If equal to @code{1}, use Metropolis posterior sample.
 If equal to @code{0}, do not use Metropolis posterior sample. NB: This
 overrides any other sampling option. Default: @code{0}
 
+@item neighborhood_width = @var{DOUBLE}
+When @code{pprior=0} and @code{ppost=0}, allows for the sampling of
+parameters around the value specified in the @code{mode_file}, in the range
+@code{xparam1}@math{\pm\left|@code{xparam1}\times@code{neighborhood_width}\right|}. Default: @code{0}
+
 @end table
 @customhead{Stability Mapping Options}
 @table @code
diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m
index 1a07acea2..edf58996e 100644
--- a/matlab/dynare_sensitivity.m
+++ b/matlab/dynare_sensitivity.m
@@ -97,6 +97,7 @@ options_gsa = set_default_option(options_gsa,'redform',0);
 options_gsa = set_default_option(options_gsa,'pprior',1);
 options_gsa = set_default_option(options_gsa,'prior_range',1);
 options_gsa = set_default_option(options_gsa,'ppost',0);
+options_gsa = set_default_option(options_gsa,'neighborhood_width',0);
 options_gsa = set_default_option(options_gsa,'ilptau',1);
 options_gsa = set_default_option(options_gsa,'morris',0);
 options_gsa = set_default_option(options_gsa,'glue',0);
diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy
index e6fe81d91..10bd29d3e 100644
--- a/preprocessor/DynareBison.yy
+++ b/preprocessor/DynareBison.yy
@@ -160,7 +160,7 @@ class ParsingDriver;
 %token EXTERNAL_FUNCTION EXT_FUNC_NAME EXT_FUNC_NARGS FIRST_DERIV_PROVIDED SECOND_DERIV_PROVIDED
 %token SELECTED_VARIABLES_ONLY COVA_COMPUTE ESTIMATION_FILE_TAG SIMULATION_FILE_TAG
 %token ERROR_BANDS ERROR_BAND_PERCENTILES SHOCKS_PER_PARAMETER
-%token SHOCK_DRAWS FREE_PARAMETERS MEDIAN DATA_OBS_NBR
+%token SHOCK_DRAWS FREE_PARAMETERS MEDIAN DATA_OBS_NBR NEIGHBORHOOD_WIDTH
 %token FILTERED_PROBABILITIES FILTERED REAL_TIME_SMOOTHED
 %token PROPOSAL_TYPE MDD_PROPOSAL_DRAWS MDD_USE_MEAN_CENTER
 %token ADAPTIVE_MH_DRAWS THINNING_FACTOR COEFFICIENTS_PRIOR_HYPERPARAMETERS
@@ -1685,6 +1685,7 @@ dynare_sensitivity_option : o_gsa_identification
                           | o_gsa_namexo
                           | o_gsa_namlagendo
                           | o_gsa_var_rmse
+                          | o_gsa_neighborhood_width
                           | o_datafile
                           | o_nobs
                           | o_first_obs
@@ -1935,6 +1936,7 @@ o_gsa_sample_file : GSA_SAMPLE_FILE EQUAL INT_NUMBER
                   | GSA_SAMPLE_FILE EQUAL filename
                     { driver.option_str("gsa_sample_file", $3); }
                   ;
+o_gsa_neighborhood_width : NEIGHBORHOOD_WIDTH EQUAL non_negative_number { driver.option_num("neighborhood_width", $3); };
 o_load_ident_files : LOAD_IDENT_FILES EQUAL INT_NUMBER { driver.option_num("load_ident_files", $3); }
 o_useautocorr : USEAUTOCORR EQUAL INT_NUMBER { driver.option_num("useautocorr", $3); }
 o_prior_mc : PRIOR_MC EQUAL INT_NUMBER { driver.option_num("prior_mc", $3); }
diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll
index dd988128a..c47f83739 100644
--- a/preprocessor/DynareFlex.ll
+++ b/preprocessor/DynareFlex.ll
@@ -551,6 +551,7 @@ string eofbuff;
 <DYNARE_STATEMENT>alpha2_rmse {return token::ALPHA2_RMSE;}
 <DYNARE_STATEMENT>load_ident_files {return token::LOAD_IDENT_FILES;}
 <DYNARE_STATEMENT>useautocorr {return token::USEAUTOCORR;}
+<DYNARE_STATEMENT>neighborhood_width {return token::NEIGHBORHOOD_WIDTH;}
  /* end of GSA options */
 
  /* For identification() statement */
-- 
GitLab