diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 5bde12c33..92dc4837d 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -8941,11 +8941,6 @@ Optimal policy under commitment (Ramsey) optimal policy for the first time and committing not to re-optimize in the future. - Because it entails computing at least a second order approximation, the - computation of the planner objective value is skipped with a message when - the model is too large (more than 180 state variables, including lagged - Lagrange multipliers). - .. command:: ramsey_policy [VARIABLE_NAME...]; ramsey_policy (OPTIONS...) [VARIABLE_NAME...]; @@ -9030,8 +9025,9 @@ Optimal policy under discretion under discretion. The algorithm implemented is essentially an LQ solver, and is described by *Dennis (2007)*. - You should ensure that your model is linear and your objective is - quadratic. Also, you should set the ``linear`` option of the + You must ensure that your objective is quadratic. Regarding the model, it must + either be linear or solved at first order with an analytical steady state provided. + In the first case, you should set the ``linear`` option of the ``model`` block. It is possible to use the :comm:`estimation` command after the diff --git a/matlab/discretionary_policy/discretionary_policy.m b/matlab/discretionary_policy/discretionary_policy.m index b2c67403d..e89de65d9 100644 --- a/matlab/discretionary_policy/discretionary_policy.m +++ b/matlab/discretionary_policy/discretionary_policy.m @@ -36,6 +36,8 @@ options_.discretionary_policy = 1; options_.order = 1; [info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list); +oo_.steady_state = oo_.dr.ys; + if ~options_.noprint disp_steady_state(M_,oo_) for i=M_.orig_endo_nbr:M_.endo_nbr @@ -44,7 +46,6 @@ if ~options_.noprint end end end - oo_.planner_objective_value = evaluate_planner_objective(M_,options_,oo_); options_.order = origorder; diff --git a/matlab/discretionary_policy/discretionary_policy_1.m b/matlab/discretionary_policy/discretionary_policy_1.m index c5aaa45da..c9424b57d 100644 --- a/matlab/discretionary_policy/discretionary_policy_1.m +++ b/matlab/discretionary_policy/discretionary_policy_1.m @@ -41,11 +41,13 @@ beta = get_optimal_policy_discount_factor(M_.params, M_.param_names); %call steady_state_file if present to update parameters if options_.steadystate_flag % explicit steady state file - [~,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ... + [ys,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ... options_,false); if info(1) return; end +else + ys=zeros(M_.endo_nbr,1); end [U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(M_.endo_nbr,1),[], M_.params); if any(any(isnan(Uy))) @@ -73,8 +75,10 @@ W=reshape(W,M_.endo_nbr,M_.endo_nbr); klen = M_.maximum_lag + M_.maximum_lead + 1; iyv=M_.lead_lag_incidence'; % Find the jacobian -z = repmat(zeros(M_.endo_nbr,1),1,klen); -z = z(nonzeros(iyv)) ; +z = repmat(ys,1,klen); +iyr0 = find(iyv(:)) ; + +z = z(iyr0); it_ = M_.maximum_lag + 1 ; if M_.exo_nbr == 0 @@ -82,10 +86,10 @@ if M_.exo_nbr == 0 end [junk,jacobia_] = feval([M_.fname '.dynamic'],z, [zeros(size(oo_.exo_simul)) ... - oo_.exo_det_simul], M_.params, zeros(M_.endo_nbr,1), it_); -if any(junk~=0) - info = 65; %the model must be written in deviation form and not have constant terms - return; + oo_.exo_det_simul], M_.params, ys, it_); +if max(abs(junk))>options_.solve_tolf + info = 65; %the model must be written in deviation form and not have constant terms or have a steady state provided + return; end Indices={'lag','contemp','lead'}; @@ -116,10 +120,12 @@ else end %write back solution to dr -dr.ys =zeros(M_.endo_nbr,1); +dr.ys =ys; dr=set_state_space(dr,M_,options_); T=H(dr.order_var,dr.order_var); dr.ghu=G(dr.order_var,:); -Selection=M_.lead_lag_incidence(1,dr.order_var)>0;%select state variables +if M_.maximum_endo_lag + Selection=M_.lead_lag_incidence(1,dr.order_var)>0;%select state variables +end dr.ghx=T(:,Selection); oo_.dr = dr; diff --git a/matlab/evaluate_planner_objective.m b/matlab/evaluate_planner_objective.m index 63ec0ab6a..a6df35326 100644 --- a/matlab/evaluate_planner_objective.m +++ b/matlab/evaluate_planner_objective.m @@ -37,11 +37,6 @@ dr = oo.dr; exo_nbr = M.exo_nbr; nstatic = M.nstatic; nspred = M.nspred; -if nspred > 180 - fprintf('\nevaluate_planner_objective: model too large, can''t evaluate planner objective\n') - planner_objective_value = NaN; - return -end beta = get_optimal_policy_discount_factor(M.params, M.param_names); Gy = dr.ghx(nstatic+(1:nspred),:); @@ -64,7 +59,13 @@ Uyygygu = A_times_B_kronecker_C(Uyy,gy,gu); Wbar =U/(1-beta); %steady state welfare Wy = Uy*gy/(eye(nspred)-beta*Gy); Wu = Uy*gu+beta*Wy*Gu; -Wyy = Uyygygy/(eye(nspred*nspred)-beta*kron(Gy,Gy)); +% Wyy = Uyygygy/(eye(nspred*nspred)-beta*kron(Gy,Gy)); %solve Wyy=Uyy*kron(gy,gy)+beta*Wyy*kron(Gy,Gy) +if isempty(options.qz_criterium) + options.qz_criterium = 1+1e-6; +end +%solve Lyapunuv equation Wyy=gy'*Uyy*gy+beta*Gy'Wyy*Gy +Wyy = reshape(lyapunov_symm(sqrt(beta)*Gy',reshape(Uyygygy,nspred,nspred),options.lyapunov_fixed_point_tol,options.qz_criterium,options.lyapunov_complex_threshold, 3, options.debug),1,nspred*nspred); + Wyygugu = A_times_B_kronecker_C(Wyy,Gu,Gu); Wyygygu = A_times_B_kronecker_C(Wyy,Gy,Gu); Wuu = Uyygugu+beta*Wyygugu; diff --git a/matlab/get_error_message.m b/matlab/get_error_message.m index c4ed1148a..8ba23678e 100644 --- a/matlab/get_error_message.m +++ b/matlab/get_error_message.m @@ -122,7 +122,7 @@ switch info(1) case 64 message = 'discretionary_policy: the derivatives of the objective function contain NaN.'; case 65 - message = 'discretionary_policy: the model must be written in deviation form and not have constant terms.'; + message = 'discretionary_policy: the model must be written in deviation form and not have constant terms or an analytical steady state meeds to be provided.'; case 66 message = 'discretionary_policy: the objective function must have zero first order derivatives.'; case 71 diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m index a7f10fd01..218d08179 100644 --- a/matlab/stoch_simul.m +++ b/matlab/stoch_simul.m @@ -79,7 +79,7 @@ oo_.dr=set_state_space(dr,M_,options_); if PI_PCL_solver [oo_.dr, info] = PCL_resol(oo_.steady_state,0); elseif options_.discretionary_policy - if ~options_.linear + if ~options_.order==1 error('discretionary_policy: only linear-quadratic problems can be solved'); end [~,info,M_,options_,oo_] = discretionary_policy_1(options_.instruments,M_,options_,oo_); diff --git a/tests/Makefile.am b/tests/Makefile.am index 3fdbcb9e6..fd050916a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -114,6 +114,8 @@ MODFILES = \ discretionary_policy/dennis_1.mod \ discretionary_policy/dennis_1_estim.mod \ discretionary_policy/Gali_discretion.mod \ + discretionary_policy/Gali_2015_chapter_3.mod \ + discretionary_policy/Gali_2015_chapter_3_nonlinear.mod \ histval_initval_file/ramst_initval_file.mod \ histval_initval_file/ramst_data.mod \ histval_initval_file/ramst_datafile.mod \ @@ -646,7 +648,8 @@ lmmcp/sw_newton.o.trs: lmmcp/sw_lmmcp.o.trs discretionary_policy/dennis_1_estim.m.trs: discretionary_policy/dennis_1.m.trs discretionary_policy/dennis_1_estim.o.trs: discretionary_policy/dennis_1.o.trs - +discretionary_policy/Gali_2015_chapter_3_nonlinear.m.trs: discretionary_policy/Gali_2015_chapter_3.m.trs +discretionary_policy/Gali_2015_chapter_3_nonlinear.o.trs: discretionary_policy/Gali_2015_chapter_3.o.trs observation_trends_and_prefiltering/MCMC: m/observation_trends_and_prefiltering/MCMC o/observation_trends_and_prefiltering/MCMC m/observation_trends_and_prefiltering/MCMC: $(patsubst %.mod, %.m.trs, $(filter observation_trends_and_prefiltering/MCMC/%.mod, $(MODFILES))) diff --git a/tests/discretionary_policy/Gali_2015_chapter_3.mod b/tests/discretionary_policy/Gali_2015_chapter_3.mod new file mode 100644 index 000000000..ac48a5eee --- /dev/null +++ b/tests/discretionary_policy/Gali_2015_chapter_3.mod @@ -0,0 +1,163 @@ +/* + * This file implements the baseline New Keynesian model of Jordi Galí (2015): Monetary Policy, Inflation, + * and the Business Cycle, Princeton University Press, Second Edition, Chapter 3 + * + * THIS MOD-FILE REQUIRES DYNARE 4.5 OR HIGHER + * + * Notes: + * - all model variables are expressed in deviations from steady state, i.e. in contrast to + * to the chapter, both the nominal interest rate and natural output are not in log-levels, but rather mean 0 + * + * This implementation was written by Johannes Pfeifer. In case you spot mistakes, + * email me at jpfeifer@gmx.de + * + * Please note that the following copyright notice only applies to this Dynare + * implementation of the model. + */ + +/* + * Copyright (C) 2016-20 Johannes Pfeifer + * Copyright (C) 2020 Dynare Team + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * It is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a copy of the GNU General Public License, + * see . + */ + + +var pi ${\pi}$ (long_name='inflation') + y_gap ${\tilde y}$ (long_name='output gap') + y_nat ${y^{nat}}$ (long_name='natural output') //(in contrast to the textbook defined in deviation from steady state) + y ${y}$ (long_name='output') + yhat ${\hat y}$ (long_name='output deviation from steady state') + r_nat ${r^{nat}}$ (long_name='natural interest rate') + r_real ${r^r}$ (long_name='real interest rate') + i ${i}$ (long_name='nominal interrst rate') + n ${n}$ (long_name='hours worked') + m_real ${m-p}$ (long_name='real money stock') + m_growth_ann ${\Delta m}$ (long_name='money growth annualized') + m_nominal ${m}$ (long_name='nominal money stock') + a ${a}$ (long_name='AR(1) technology shock process') + r_real_ann ${r^{r,ann}}$ (long_name='annualized real interest rate') + i_ann ${i^{ann}}$ (long_name='annualized nominal interest rate') + r_nat_ann ${r^{nat,ann}}$ (long_name='annualized natural interest rate') + pi_ann ${\pi^{ann}}$ (long_name='annualized inflation rate') + z ${z}$ (long_name='AR(1) preference shock process') + p ${p}$ (long_name='price level') + w ${w}$ (long_name='nominal wage') + c ${c}$ (long_name='consumption') + w_real ${\frac{w}{p}}$ (long_name='real wage') + mu ${\mu}$ (long_name='markup') + mu_hat ${\hat \mu}$ (long_name='markup gap') +; + +varexo eps_a ${\varepsilon_a}$ (long_name='technology shock') + eps_z ${\varepsilon_z}$ (long_name='preference shock innovation') + ; + +parameters alppha ${\alpha}$ (long_name='capital share') + betta ${\beta}$ (long_name='discount factor') + rho_a ${\rho_a}$ (long_name='autocorrelation technology shock') + rho_z ${\rho_{z}}$ (long_name='autocorrelation monetary demand shock') + siggma ${\sigma}$ (long_name='inverse EIS') + varphi ${\varphi}$ (long_name='inverse Frisch elasticity') + phi_pi ${\phi_{\pi}}$ (long_name='inflation feedback Taylor Rule') + phi_y ${\phi_{y}}$ (long_name='output feedback Taylor Rule') + eta ${\eta}$ (long_name='semi-elasticity of money demand') + epsilon ${\epsilon}$ (long_name='demand elasticity') + theta ${\theta}$ (long_name='Calvo parameter') + ; +%---------------------------------------------------------------- +% Parametrization, p. 67 and p. 113-115 +%---------------------------------------------------------------- +siggma = 1; +varphi=5; +phi_pi = 1.5; +phi_y = 0.125; +theta=3/4; +rho_z = 0.5; +rho_a = 0.9; +betta = 0.99; +eta =3.77; %footnote 11, p. 115 +alppha=1/4; +epsilon=9; + +%---------------------------------------------------------------- +% First Order Conditions +%---------------------------------------------------------------- + +model(linear); +//Composite parameters +#Omega=(1-alppha)/(1-alppha+alppha*epsilon); %defined on page 60 +#psi_n_ya=(1+varphi)/(siggma*(1-alppha)+varphi+alppha); %defined on page 62 +#lambda=(1-theta)*(1-betta*theta)/theta*Omega; %defined on page 61 +#kappa=lambda*(siggma+(varphi+alppha)/(1-alppha)); %defined on page 63 +[name='New Keynesian Phillips Curve eq. (22)'] +pi=betta*pi(+1)+kappa*y_gap; +[name='Dynamic IS Curve eq. (23)'] +y_gap=-1/siggma*(i-pi(+1)-r_nat)+y_gap(+1); +[name='Definition natural rate of interest eq. (24)'] +r_nat=-siggma*psi_n_ya*(1-rho_a)*a+(1-rho_z)*z; +[name='Definition real interest rate'] +r_real=i-pi(+1); +[name='Definition natural output, eq. (20)'] +y_nat=psi_n_ya*a; +[name='Definition output gap'] +y_gap=y-y_nat; +[name='TFP shock'] +a=rho_a*a(-1)+eps_a; +[name='Production function (eq. 14)'] +y=a+(1-alppha)*n; +[name='Preference shock, p. 54'] +z = rho_z*z(-1) - eps_z; +[name='Money growth (derived from eq. (4))'] +m_growth_ann=4*(y-y(-1)-eta*(i-i(-1))+pi); +[name='Real money demand (eq. 4)'] +m_real=y-eta*i; +[name='Annualized nominal interest rate'] +i_ann=4*i; +[name='Annualized real interest rate'] +r_real_ann=4*r_real; +[name='Annualized natural interest rate'] +r_nat_ann=4*r_nat; +[name='Annualized inflation'] +pi_ann=4*pi; +[name='Output deviation from steady state'] +yhat=y-steady_state(y); +[name='Definition price level'] +pi=p-p(-1); +[name='resource constraint, eq. (12)'] +y=c; +[name='FOC labor, eq. (2)'] +w-p=siggma*c+varphi*n; +[name='definition real wage'] +w_real=w-p; +[name='definition nominal money stock'] +m_nominal=m_real+p; +[name='average price markup, eq. (18)'] +mu=-(siggma+(varphi+alppha)/(1-alppha))*y+(1+varphi)/(1-alppha)*a; +[name='average price markup, eq. (20)'] +mu_hat=-(siggma+(varphi+alppha)/(1-alppha))*y_gap; +end; + + +%---------------------------------------------------------------- +% define shock variances +%--------------------------------------------------------------- +shocks; +var eps_a = 0.5^2; //unit shock to preferences +end; + +planner_objective 0.5*((siggma+(varphi+alppha)/(1-alppha))*yhat^2+epsilon/0.0215*pi^2)/100; +discretionary_policy(instruments=(i),irf=20,planner_discount=betta, periods=0) y_gap pi_ann y n w_real p yhat; + + diff --git a/tests/discretionary_policy/Gali_2015_chapter_3_nonlinear.mod b/tests/discretionary_policy/Gali_2015_chapter_3_nonlinear.mod new file mode 100644 index 000000000..d9153977c --- /dev/null +++ b/tests/discretionary_policy/Gali_2015_chapter_3_nonlinear.mod @@ -0,0 +1,229 @@ +/* + * This file implements the baseline New Keynesian model of Jordi Galí (2015): Monetary Policy, Inflation, + * and the Business Cycle, Princeton University Press, Second Edition, Chapter 3 + * + * Note that this mod-file implements the non-linear first order conditions and that the IRFs show the log-deviations + * from steady state. + * + * THIS MOD-FILE REQUIRES DYNARE 4.5 OR HIGHER + * + * Notes: + * - in the LOM for the discount rate shock z the shock enters with a minus sign in this mod-file to generate the + * IRF to a -0.5% shock + * + * This implementation was written by Johannes Pfeifer. In case you spot mistakes, + * email me at jpfeifer@gmx.de + * + * Please note that the following copyright notice only applies to this Dynare + * implementation of the model. + */ + +/* + * Copyright (C) 2016-20 Johannes Pfeifer + * Copyright (C) 2020 Dynare Team + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * It is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a copy of the GNU General Public License, + * see . + */ + +var C ${C}$ (long_name='Consumption') + W_real ${\frac{W}{P}}$ (long_name='Real Wage') + Pi ${\Pi}$ (long_name='inflation') + A ${A}$ (long_name='AR(1) technology process') + N ${N}$ (long_name='Hours worked') + R ${R^n}$ (long_name='Nominal Interest Rate') + realinterest ${R^{r}}$ (long_name='Real Interest Rate') + Y ${Y}$ (long_name='Output') + Q ${Q}$ (long_name='Bond price') + Z ${Z}$ (long_name='AR(1) preference shock process') + S ${S}$ (long_name='Price dispersion') + Pi_star ${\Pi^*}$ (long_name='Optimal reset price') + x_aux_1 ${x_1}$ (long_name='aux. var. 1 recursive price setting') + x_aux_2 ${x_2}$ (long_name='aux. var. 2 recursive price setting') + MC ${mc}$ (long_name='real marginal costs') + M_real ${M/P}$ (long_name='real money stock') + i_ann ${i^{ann}}$ (long_name='annualized nominal interest rate') + pi_ann ${\pi^{ann}}$ (long_name='annualized inflation rate') + r_real_ann ${r^{r,ann}}$ (long_name='annualized real interest rate') + P ${P}$ (long_name='price level') + log_m_nominal ${log(M)}$ (long_name='log nominal money stock') + log_y ${log(Y)}$ (long_name='log output') + log_W_real ${log(W/P)}$ (long_name='log real wage') + log_N ${log(N)}$ (long_name='log hours') + log_P ${log(P)}$ (long_name='log price level') + log_A ${log(A)}$ (long_name='log technology level') + log_Z ${log(Z)}$ (long_name='log preference shock') + y_hat + pi + ; + +varexo eps_a ${\varepsilon_a}$ (long_name='technology shock') + eps_z ${\varepsilon_z}$ (long_name='preference shock') + ; + +parameters alppha ${\alpha}$ (long_name='capital share') + betta ${\beta}$ (long_name='discount factor') + rho_a ${\rho_a}$ (long_name='autocorrelation technology shock') + rho_z ${\rho_{z}}$ (long_name='autocorrelation monetary demand shock') + siggma ${\sigma}$ (long_name='inverse EIS') + varphi ${\varphi}$ (long_name='inverse Frisch elasticity') + phi_pi ${\phi_{\pi}}$ (long_name='inflation feedback Taylor Rule') + phi_y ${\phi_{y}}$ (long_name='output feedback Taylor Rule') + eta ${\eta}$ (long_name='semi-elasticity of money demand') + epsilon ${\epsilon}$ (long_name='demand elasticity') + theta ${\theta}$ (long_name='Calvo parameter') + tau ${\tau}$ (long_name='labor subsidy') + ; + +%---------------------------------------------------------------- +% Parametrization, p. 67 and p. 113-115 +%---------------------------------------------------------------- +siggma = 1; +varphi=5; +phi_pi = 1.5; +phi_y = 0.125; +theta=3/4; +rho_z = 0.5; +rho_a = 0.9; +betta = 0.99; +eta =3.77; %footnote 11, p. 115 +alppha=1/4; +epsilon=9; +tau=0; //1/epsilon; + +%---------------------------------------------------------------- +% First Order Conditions +%---------------------------------------------------------------- + +model; + [name='FOC Wages, eq. (2)'] + W_real=C^siggma*N^varphi; + [name='Euler equation eq. (3)'] + Q=betta*(C(+1)/C)^(-siggma)*(Z(+1)/Z)/Pi(+1); + [name='Definition nominal interest rate), p. 22 top'] + R=1/Q; + [name='Aggregate output, above eq. (14)'] + Y=A*(N/S)^(1-alppha); + [name='Definition Real interest rate'] + R=realinterest*Pi(+1); +% @#if money_growth_rule==0 +% [name='Monetary Policy Rule, p. 26 bottom/eq. (22)'] +% R=1/betta*Pi^phi_pi*(Y/steady_state(Y))^phi_y; +% @#endif + [name='Market Clearing, eq. (15)'] + C=Y; + [name='Technology Shock, eq. (6)'] + log(A)=rho_a*log(A(-1))+eps_a; + [name='Preference Shock, p.54'] + log(Z)=rho_z*log(Z(-1))-eps_z; + [name='Definition marginal cost'] + MC=W_real/((1-alppha)*Y/N*S); + [name='LOM prices, eq. (7)'] + 1=theta*Pi^(epsilon-1)+(1-theta)*(Pi_star)^(1-epsilon); + [name='LOM price dispersion'] + S=(1-theta)*Pi_star^(-epsilon/(1-alppha))+theta*Pi^(epsilon/(1-alppha))*S(-1); + [name='FOC price setting'] + Pi_star^(1+epsilon*(alppha/(1-alppha)))=x_aux_1/x_aux_2*(1-tau)*epsilon/(epsilon-1); + [name='Auxiliary price setting recursion 1'] + x_aux_1=Z*C^(-siggma)*Y*MC+betta*theta*Pi(+1)^(epsilon+alppha*epsilon/(1-alppha))*x_aux_1(+1); + [name='Auxiliary price setting recursion 2'] + x_aux_2=Z*C^(-siggma)*Y+betta*theta*Pi(+1)^(epsilon-1)*x_aux_2(+1); + [name='Definition log output'] + log_y = log(Y); + [name='Definition log real wage'] + log_W_real=log(W_real); + [name='Definition log hours'] + log_N=log(N); + [name='Annualized inflation'] + pi_ann=4*log(Pi); + [name='Annualized nominal interest rate'] + i_ann=4*log(R); + [name='Annualized real interest rate'] + r_real_ann=4*log(realinterest); + [name='Real money demand, eq. (4)'] + M_real=Y/R^eta; + [name='definition nominal money stock'] + log_m_nominal=log(M_real*P); + [name='Definition price level'] + Pi=P/P(-1); + [name='Definition log price level'] + log_P=log(P); + [name='Definition log TFP'] + log_A=log(A); + [name='Definition log preference'] + log_Z=log(Z); + [mcp='a'] + y_hat=log(Y)-STEADY_STATE(log(Y)); + + pi=log(Pi)-STEADY_STATE(log(Pi)); +end; + +%---------------------------------------------------------------- +% Steady state values +%--------------------------------------------------------------- + +steady_state_model; +A=1; +Z=1; +S=1; +Pi_star=1; +P=1; +MC=(epsilon-1)/epsilon/(1-tau); +R=1/betta; +Pi=1; +Q=1/R; +realinterest=R; +N=((1-alppha)*MC)^(1/((1-siggma)*alppha+varphi+siggma)); +C=A*N^(1-alppha); +W_real=C^siggma*N^varphi; +Y=C; +money_growth=0; +money_growth_ann=0; +nu=0; +x_aux_1=C^(-siggma)*Y*MC/(1-betta*theta*Pi^(epsilon/(1-alppha))); +x_aux_2=C^(-siggma)*Y/(1-betta*theta*Pi^(epsilon-1)); +log_y = log(Y); +log_W_real=log(W_real); +log_N=log(N); +pi_ann=4*log(Pi); +i_ann=4*log(R); +r_real_ann=4*log(realinterest); +M_real=Y/R^eta; +log_m_nominal=log(M_real*P); +log_P=log(P); +log_A=0; +log_Z=0; +end; + +%---------------------------------------------------------------- +% define shock variances +%--------------------------------------------------------------- + +shocks; +var eps_a = 0.5^2; //unit shock to preferences +end; + +% steady; +% check; +% stoch_simul; +planner_objective 0.5*((siggma+(varphi+alppha)/(1-alppha))*y_hat^2+epsilon/0.0215*pi^2)/100; +discretionary_policy(order=1,instruments=(R),irf=20,planner_discount=betta, periods=0) y_hat pi_ann log_y log_N log_W_real log_P; + +temp=load('Gali_2015_chapter_3_results.mat'); +if abs(oo_.planner_objective_value-temp.oo_.planner_objective_value)>1e-6 + warning('Planner objective does not match linear model') +end +if max(max(abs([temp.oo_.irfs.y_eps_a; temp.oo_.irfs.w_real_eps_a; temp.oo_.irfs.n_eps_a; temp.oo_.irfs.pi_ann_eps_a]-... + [oo_.irfs.log_y_eps_a; oo_.irfs.log_W_real_eps_a; oo_.irfs.log_N_eps_a; oo_.irfs.pi_ann_eps_a])))>1e-6 + error('Policy is different') +end \ No newline at end of file