Page 2 of 3

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed Sep 26, 2012 10:34 am
by cfp
To implement both an upper bound and a lower bound on a variable you must include an additional variable that is equal to the upper bound minus the variable of interest. This new variable is then given a lower bound.

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Fri Sep 28, 2012 8:15 am
by cup
Hi
I am trying to find the effects of government spending shock using when the ZLB binds.

I am using a model based on Gali (2008) basic NKM with added government spending. When running the NKM_ZLB I get the following error message:
I am new to Dynare (and DSGE) and cannot find what it is i am doing wrong.

(I have tried to decrease the number of periods the XLB binds, but then I get another error message saying try to increase the nomber of periods the ZLB binds.)

Warning: There is only a guaranteed solution to the linear programming problem when the ZLB binds
for at most 6 periods.
> In INITIAL_CHECKS at 51
In NKM_ZLB at 1701
In dynare at 120

Computation time for set-up and initial feasibility checks:
Elapsed time is 1.023637 seconds.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
1.260768e-21.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.028441e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.651111e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
8.088044e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.588730e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
6.790571e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
4.574485e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
9.991333e-25.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
9.140634e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
6.366691e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.028441e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.651111e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
8.088044e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.588730e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
6.790571e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
4.574485e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
9.991333e-25.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
9.140634e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
6.366691e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.028441e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.651111e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
8.088044e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.588730e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
6.790571e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
4.574485e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
9.991333e-25.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
9.140634e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
6.366691e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.028441e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.651111e-24.
> In solve_quadprog at 51
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Exiting: One or more of the residuals, duality gap, or total relative error
has stalled:
the primal appears to be infeasible (and the dual unbounded).
(The dual residual < TolFun=1.49e-08.)
Warning: Failed to find initial feasible point.

> In solve_quadprog at 64
In STEADYSTATE_IRF_CONS at 38
In NKM_ZLB at 1704
In dynare at 120
Error using solve_quadprog (line 72)
Failed to solve quadratic programming problem. Try increasing TShadow.
Error in STEADYSTATE_IRF_CONS (line 38)
alpha = solve_quadprog( M, V, AlphaStart, TShadow, Accuracy, Options, ZeroVec, OneVec );
Error in NKM_ZLB (line 1704)
[ IRF_, IRF_CONS_ ] = STEADYSTATE_IRF_CONS( ZLBData );
Error in dynare (line 120)
evalin('base',fname) ;

I attach the mod file should anyone have the time to take a look at it. Grateful if anyone could help
>>

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Fri Sep 28, 2012 6:20 pm
by cfp
I'll have a look at this in the next few weeks. I'm extremely busy at the moment I'm afraid.

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Sun Oct 21, 2012 12:20 pm
by cup
cfp wrote:I'll have a look at this in the next few weeks. I'm extremely busy at the moment I'm afraid.


Hi ended up using a different model. But thank you for the reply.

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Sun Oct 21, 2012 12:27 pm
by cfp
Sorry.

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Fri Aug 09, 2013 4:31 am
by bretthclarke
I'm trying to implement this algorithm in a Smets&Wouters (2007) model. It's in levels. I want to look at the ZLB.

It seems this code is designed for a model in logs, and I did notice the footnote in the paper explaining that I'd need to convert to ratios instead of differences and then multiply by the exponetial of the shadow price shock, but I am having a small problem locating in the code the place to switch to ratios, and I was also wondering what you do for second order pertubations.

Also, do I mostly leave everything alone in the code? Do I simply put my own vars/varexos/parameters in, my model in the model block with the exponential of shadow_price multiplied to my interest rate rule, leaving all the parts defining shadow_price alone?

Any help you can offer would be of immense help. It is a road block in my research, but it isn't completely time urgent either, so I understand if you're busy at the moment. Also, if I work it out I promise to post on here so you don't do any work I won't need.

Brett

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed Aug 14, 2013 3:35 pm
by cfp
You can also just write the Taylor rule equation in logs. So log( R ) = phi_pi * log( PI ) + ... + shadow_price
Perhaps that's easier?

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed Aug 14, 2013 9:03 pm
by bretthclarke
That's great!

A second problem comes from the fact that I have a nonlinear model and I want to make dynare take a second order approximation of it. Instead of specifying "model( linear );", would I simply use "model;" and then "log( R ) = phi_pi * log( PI ) + ... + shadow_price^2" as my rule?

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed Aug 14, 2013 9:13 pm
by cfp
At second order, you have to use a different algorithm to impose the ZLB. Following some referee comments, we're currently working on improving this algorithm, so perhaps you should wait until the next draft of our paper if you want to do second order stuff.

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed Aug 14, 2013 10:48 pm
by bretthclarke
Thanks! I would be glad to read it. What is the condition for including shadow_price^2?

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed Aug 28, 2013 9:33 am
by dankaufmann
It seems like the code in the zip file contains a small bug. The lower bound on the simulated interest rate appears to amount to -log(1/beta), minus the steady state value of the interest rate.

Is it correct if I changeline 85 in SIMU_CONS.m as follows?

Code: Select all
      
%SIMU_CONS( order_var, i ) = dr.ghx*yhat + dr.ghu*transpose( ex_temp );
SIMU_CONS( order_var, i ) = Var_cons_steady + dr.ghx*yhat + dr.ghu*transpose( ex_temp );


Best, Daniel

Michael Paetz wrote:I also attached the Code for a sinlge country NKM for IRFs and Simulations, so that everyone can use it. Although the files should be selfexplaining, do not hesitate to contact me, if you experience any problems.

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed Aug 28, 2013 3:15 pm
by cfp
E-mail me and I'll share the latest code. (See http://www.tholden.org/ for my email.)

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Thu Oct 17, 2013 4:08 am
by johnbrown
Hi, I am working with a standard CGG model, trying to introduce a zero lower bound (i>=0) in a model with inflation targeting rule (inflation = 0). I want to do a deterministic simulation (simul). I don't understand how do you introduce this when you have inflation targeting rule. Any help would be appreciated. Thanks,

Code: Select all
(1/C)^sigma = beta/((C(+1))^sigma)*(1+i)/pibar(+1);
K = (theta/(theta-1)) * (L^(nu))*Y/Z + alpha * beta * (pibar(+1)^theta)*K(+1);
F = C^(-sigma) * Y + alpha*beta*(pibar(+1)^(theta-1))*(F(+1)) ; 
K = F*(((1-alpha*pibar^(theta-1))/(1-alpha))^(1/(1-theta))) ;
1/pstar = ((1-alpha)*(((1-alpha*(pibar)^(theta-1))/(1-alpha))^(theta/(theta-1))) + alpha*(pibar^theta)/pstar(-1));
Y/pstar = Z*L;
pibar = 1;
Y = C; //resource constraint
Z - 1 = 0.9*(Z(-1) - 1) + eps_Z;

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed May 14, 2014 9:42 am
by adi199283
HI. I try to replicate the code of paper "Market and Non-Market Monetary Policy Tools in a Calibrated DSGE Model for Mainland China"
But when I run the program, I am told that "Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Could you please give me some advice on this problem or sharing your code of this paper?
Thanks a lot.


Michael Paetz wrote:Finally, Tom and I have a working paper on the algortihm, used for simulations:

http://www.uni-hamburg.de/fachbereiche- ... uality.pdf

We simulated a two-country NKM and the Smets & Wouters(2003) Model using the shadow price method.

I also attached the Code for a sinlge country NKM for IRFs and Simulations, so that everyone can use it. Although the files should be selfexplaining, do not hesitate to contact me, if you experience any problems.

If someone is interested, here are two Papers, using the method for applications apart from monetary policy:

http://www.suomenpankki.fi/bofit_en/tut ... dp1112.pdf

http://www.suomenpankki.fi/bofit_en/tut ... dp1612.pdf

Best
Michael

Re: The Zero Lower Bound Constraint on Nominal Int. Rate

PostPosted: Wed May 14, 2014 11:41 am
by jpfeifer
(d_ss, e_ss, l_ss) are not set.