From 1983dc13a3df86d0df0499f6d7bb983c300c4c29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Guts=29?= <stepan@adjemian.eu>
Date: Thu, 14 Dec 2023 12:09:09 +0100
Subject: [PATCH] Make examples/fs2000.mod closer to the original code.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 - Use (old default) mode_compute=4 which is closer to the algorithm
   used by Frank Schorfheide and ensures that the hessian matrix is well
   behaved (contrary to the new default, because of the asymptote at 0
   in the beta prior for autoregressive parameter ρ).

 - Change parameterization for mst. A normal prior on mst is not
   equivalent to a normal prior on log(mst) (which is done the
   parameterization in the JAE paper).

Closes #2177.
---
 examples/fs2000.mod    | 50 +++++++++++++++++++++---------------------
 examples/fs2000_data.m |  8 +++----
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/examples/fs2000.mod b/examples/fs2000.mod
index 391fc2f1c3..13b95f0714 100644
--- a/examples/fs2000.mod
+++ b/examples/fs2000.mod
@@ -1,17 +1,17 @@
 /*
- * This file replicates the estimation of the cash in advance model (termed M1 
- * in the paper) described in Frank Schorfheide (2000): "Loss function-based 
+ * This file replicates the estimation of the cash in advance model (termed M1
+ * in the paper) described in Frank Schorfheide (2000): "Loss function-based
  * evaluation of DSGE models", Journal of Applied Econometrics, 15(6), 645-670.
  *
- * The data are taken from the replication package at 
+ * The data are taken from the replication package at
  * http://dx.doi.org/10.15456/jae.2022314.0708799949
  *
  * The prior distribution follows the one originally specified in Schorfheide's
  * paper. Note that the elicited beta prior for rho in the paper
  * implies an asymptote and corresponding prior mode at 0. It is generally
- * recommended to avoid this extreme type of prior. 
+ * recommended to avoid this extreme type of prior.
  *
- * Because the data are already logged and we use the loglinear option to conduct 
+ * Because the data are already logged and we use the loglinear option to conduct
  * a full log-linearization, we need to use the logdata option.
  *
  * The equations are taken from J. Nason and T. Cogley (1994): "Testing the
@@ -62,20 +62,20 @@ varexo e_a  ${\epsilon_A}$      (long_name='TFP shock')
     e_m     ${\epsilon_M}$      (long_name='Money growth shock')
     ;
 
-parameters alp  ${\alpha}$      (long_name='capital share')
-    bet         ${\beta}$       (long_name='discount factor')
-    gam         ${\gamma}$      (long_name='long-run TFP growth')
-    mst         ${m^*}$         (long_name='long-run money growth')
-    rho         ${\rho}$        (long_name='autocorrelation money growth')
-    phi         ${\phi}$        (long_name='labor weight in consumption')
-    del         ${\delta}$      (long_name='depreciation rate')
+parameters alp  ${\alpha}$       (long_name='capital share')
+    bet         ${\beta}$        (long_name='discount factor')
+    gam         ${\gamma}$       (long_name='long-run TFP growth')
+    logmst         ${\log(m^*)}$ (long_name='long-run money growth')
+    rho         ${\rho}$         (long_name='autocorrelation money growth')
+    phi         ${\phi}$         (long_name='labor weight in consumption')
+    del         ${\delta}$       (long_name='depreciation rate')
     ;
 
 % roughly picked values to allow simulating the model before estimation
 alp = 0.33;
 bet = 0.99;
 gam = 0.003;
-mst = 1.011;
+logmst = log(1.011);
 rho = 0.7;
 phi = 0.787;
 del = 0.02;
@@ -84,7 +84,7 @@ model;
 [name='NC before eq. (1), TFP growth equation']
 dA = exp(gam+e_a);
 [name='NC eq. (2), money growth rate']
-log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
+log(m) = (1-rho)*logmst + rho*log(m(-1))+e_m;
 [name='NC eq. (A1), Euler equation']
 -P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
 [name='NC below eq. (A1), firm borrowing constraint']
@@ -119,25 +119,25 @@ end;
 steady_state_model;
   dA = exp(gam);
   gst = 1/dA;
-  m = mst;
+  m = exp(logmst);
   khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
-  xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
-  nust = phi*mst^2/( (1-alp)*(1-phi)*bet*gst^alp*khst^alp );
+  xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/m )^(-1);
+  nust = phi*m^2/( (1-alp)*(1-phi)*bet*gst^alp*khst^alp );
   n  = xist/(nust+xist);
   P  = xist + nust;
   k  = khst*n;
 
-  l  = phi*mst*n/( (1-phi)*(1-n) );
-  c  = mst/P;
-  d  = l - mst + 1;
+  l  = phi*m*n/( (1-phi)*(1-n) );
+  c  = m/P;
+  d  = l - m + 1;
   y  = k^alp*n^(1-alp)*gst^alp;
-  R  = mst/bet;
+  R  = m/bet;
   W  = l/n;
   ist  = y-c;
   q  = 1 - d;
 
   e = 1;
-  
+
   gp_obs = m/dA;
   gy_obs = dA;
 end;
@@ -151,7 +151,7 @@ estimated_params;
 alp, beta_pdf, 0.356, 0.02;
 bet, beta_pdf, 0.993, 0.002;
 gam, normal_pdf, 0.0085, 0.003;
-mst, normal_pdf, 1.0002, 0.007;
+logmst, normal_pdf, 0.0002, 0.007;
 rho, beta_pdf, 0.129, 0.223;
 phi, beta_pdf, 0.65, 0.05;
 del, beta_pdf, 0.01, 0.005;
@@ -161,8 +161,8 @@ end;
 
 varobs gp_obs gy_obs;
 
-estimation(order=1, datafile=fs2000_data, loglinear,logdata, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8, mode_check);
+estimation(order=1, datafile=fs2000_data, loglinear,logdata, mode_compute=4, mh_replic=20000, nodiagnostic, mh_nblocks=2, mh_jscale=0.8, mode_check);
 
 %uncomment the following lines to generate LaTeX-code of the model equations
 %write_latex_original_model(write_equation_tags);
-%collect_latex_files;
\ No newline at end of file
+%collect_latex_files;
diff --git a/examples/fs2000_data.m b/examples/fs2000_data.m
index 9c4ea3d6d1..281b2d8eb1 100644
--- a/examples/fs2000_data.m
+++ b/examples/fs2000_data.m
@@ -1,6 +1,6 @@
 %This file is a direct Matlab implementation of the loaddata.g and data.prn files
-%of Schorfheide, Frank (2000): Loss function-based evaluation of DSGE models 
-%(replication data). Version: 1. Journal of Applied Econometrics. Dataset. 
+%of Schorfheide, Frank (2000): Loss function-based evaluation of DSGE models
+%(replication data). Version: 1. Journal of Applied Econometrics. Dataset.
 %http://dx.doi.org/10.15456/jae.2022314.0708799949
 % Copyright: 2000-2022 Frank Schorfheide
 % Copyright: 2023 Dynare Team
@@ -210,6 +210,6 @@ data_q=[18.02 1474.5 150.2
 
 %Compute growth rates: from 1950:I to 1997:IV
 gy_obs=1000*data_q(:,2)./data_q(:,3); %real GDP per capita
-gy_obs=diff(log(gy_obs)); 
+gy_obs=diff(log(gy_obs));
 
-gp_obs = diff(log(data_q(:,1))); %GDP deflator inflation
\ No newline at end of file
+gp_obs = diff(log(data_q(:,1))); %GDP deflator inflation
-- 
GitLab