# NK\_model

**URL:** <https://forum.dynare.org/t/nk-model/4352>\
**Category:** Dynare help (legacy posts)\
**Created:** [14 December 2014 08:24 UTC](https://forum.dynare.org/t/nk-model/4352 "2014-12-14T08:24:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gondal](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/e0b2c6/32.png) [@gondal](https://forum.dynare.org/u/gondal)\
**Post date:** [14 December 2014 08:24 UTC](https://forum.dynare.org/t/nk-model/4352/1 "2014-12-14T08:24:48Z")

</div>

Hi…  
I am doing my M.phil thesis thesis on optimal inflation rate through New Keynesian DSGE models with monopolistic competitive firms. I have solved the model and now i am unable to write its coding in dynare. Please give me direction how to write the model in dynare which equation and which variables i have to be write in dynare.  
Nasir Gondal

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [14 December 2014 10:35 UTC](https://forum.dynare.org/t/nk-model/4352/2 "2014-12-14T10:35:40Z")

</div>

Take a look at Gali’s textbook and the corresponding mod-file on my homepage.

---

<div class="post-metadata">

**Author:** ![gondal](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/e0b2c6/32.png) [@gondal](https://forum.dynare.org/u/gondal)\
**Post date:** [15 December 2014 04:15 UTC](https://forum.dynare.org/t/nk-model/4352/3 "2014-12-15T04:15:47Z")

</div>

I found the error titled:  
"STEADY: The Jacobian contains Inf or NaN. The problem arises from:  
STEADY: Derivative of Equation 4 with respect to Variable y (initial value of y: 0.56)  
STEADY: Derivative of Equation 1 with respect to Variable c (initial value of c: 0.98)  
STEADY: Derivative of Equation 2 with respect to Variable c (initial value of c: 0.98)  
STEADY: Derivative of Equation 3 with respect to Variable c (initial value of c: 0.98)  
STEADY: Derivative of Equation 5 with respect to Variable c (initial value of c: 0.98)  
STEADY: Derivative of Equation 2 with respect to Variable m (initial value of m: 0.68)  
STEADY: Derivative of Equation 2 with respect to Variable p (initial value of p: 0.56)  
STEADY: Derivative of Equation 5 with respect to Variable p (initial value of p: 0.56)  
STEADY: Derivative of Equation 1 with respect to Variable i (initial value of i: 0.92)  
STEADY: Derivative of Equation 4 with respect to Variable i (initial value of i: 0.92)  
STEADY: Derivative of Equation 3 with respect to Variable n (initial value of n: 50)  
STEADY: Derivative of Equation 6 with respect to Variable n (initial value of n: 50)  
STEADY: Derivative of Equation 10 with respect to Variable n (initial value of n: 50)  
STEADY: Derivative of Equation 5 with respect to Variable w (initial value of w: 20)  
STEADY: Derivative of Equation 12 with respect to Variable pi (initial value of pi: 0.85)  
STEADY: Derivative of Equation 12 with respect to Variable psi (initial value of psi: 0.77)

STEADY: The problem most often occurs, because a variable with  
STEADY: exponent smaller than 1 has been initialized to 0. Taking the derivative  
STEADY: and evaluating it at the steady state then results in a division by 0.  
??? Error using ==\> dynare\_solve at 60  
An element of the Jacobian is not finite or NaN

Error in ==\> evaluate\_steady\_state at 66  
[ys,check] = dynare\_solve([M.fname ‘\_static’],…

Error in ==\> resol at 104  
[dr.ys,M.params,info] = evaluate\_steady\_state(oo.steady\_state,M,options,oo,0);

Error in ==\> stoch\_simul at 88  
[oo\_.dr,info,M\_,options\_,oo\_] = resol(0,M\_,options\_,oo\_);

Error in ==\> yasir1 at 221  
info = stoch\_simul(var\_list\_);

Error in ==\> dynare at 180  
evalin(‘base’,fname) ;

How can I solve it. Any suggestion.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [16 December 2014 18:42 UTC](https://forum.dynare.org/t/nk-model/4352/4 "2014-12-16T18:42:45Z")

</div>

Use an initval block. If that does not help, post the mod-file

---

<div class="post-metadata">

**Author:** ![gondal](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/e0b2c6/32.png) [@gondal](https://forum.dynare.org/u/gondal)\
**Post date:** [17 December 2014 18:24 UTC](https://forum.dynare.org/t/nk-model/4352/5 "2014-12-17T18:24:02Z")

</div>

Hi.  
I am facing the same problem after incorporating the initval.  
New Keynesian model with monopolistic competitive firms as developed by Carl E Walsh.  
I attached the .mod file with name yasir1.mod  
[yasir1.mod](https://forum.dynare.org/uploads/default/original/2X/e/eb75e206ec4a4647fbb92721759b7b0193b33862.mod) (848 Bytes)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [18 December 2014 06:24 UTC](https://forum.dynare.org/t/nk-model/4352/6 "2014-12-18T06:24:55Z")

</div>

Dynare is case-sensitive. You get the message

[quote]Warning: Some of the parameters have no value (alpha, rho, eta, zeta, gamma, sigma, phi) when using stoch\_simul. If these parameters are not initialized in a  
steadystate file or a steady\_state\_model-block, Dynare may not be able to solve the model… [/quote]

You need to fix this. For example, you use alpha, but you only set the parameter Alpha.

---

<div class="post-metadata">

**Author:** ![gondal](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/e0b2c6/32.png) [@gondal](https://forum.dynare.org/u/gondal)\
**Post date:** [30 December 2014 07:43 UTC](https://forum.dynare.org/t/nk-model/4352/7 "2014-12-30T07:43:13Z")

</div>

Hi…  
i got the error option  
The Jacobian contains Inf or NaN. The problem arises from:  
will be thankful for assistance.  
Mod file is attached.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [31 December 2014 16:11 UTC](https://forum.dynare.org/t/nk-model/4352/8 "2014-12-31T16:11:42Z")

</div>

There is nothing attached.
