Page 1 of 1

NaN in the list of eigenvalues

PostPosted: Mon Jul 28, 2008 5:26 pm
by Ansgar
Dear all,
it seems that sometimes the eigenvalues listed in oo_.dr.eigval (or in dr.eigval if you use dynare 3) often contain entries like " Inf + NaNi " Now I am aware that infinite eigenvalues are not a problem but the "NaNi" part seems strange. The NaN stands for "not a number" I guess, so does it read "not a number times imaginary"?
The Check command seems to treat those eigenvalues just simply as infinite ones and then uses them to check the Blanchar-Kahn condition. Is this correct? And is an infinite eigenvalue the only occasion on which "NaNi " will appear in a row of oo_.dr.eigval ?

Many Thanks for your help!
Best,
Ansgar

Re: NaN in the list of eigenvalues

PostPosted: Wed Apr 21, 2010 3:23 pm
by jpfeifer
Dear all,

I am currently having the same problem in Dynare 4.1.1 and was wondering how the NaNi in the eigenvalues are treated. Obviously, the check command ignores the NaN,but subsequently my impulse responses in oo.irfs contain only NaNs. Has anyone experience with this issue? I would appreciate any comments.

Best, Johannes

Re: NaN in the list of eigenvalues

PostPosted: Fri Apr 23, 2010 7:14 pm
by jpfeifer
Here is a simple example for the issue. The model is from Fernandez-Villaverde/Rubio-Ramírez "Econometrics of DSGE-models" as detailled in "A Baseline DSGE model" (http://www.econ.upenn.edu/~jesusfv/benchmark_DSGE.pdf). The model has been calibrated according to the estimated parameters given in the first paper. The detrended FOCs and the steady state are taken exactly as given in the latter paper (apart from a few obvious typos in the paper). Some of the last eigenvalues contain a "NaNi" part. While the first-order approximation works and produces sensible impulse responses, the second order approximation fails. Considering that this is an off the shelve New-Keynesian model, Dynare should have no trouble solving it.

Re: NaN in the list of eigenvalues

PostPosted: Fri May 07, 2010 3:13 pm
by jpfeifer
Hi everyone,
while I still have not solved the problem with the baseline DSGE-model, the NaNi issue seems to regularly occur in New Keynesian models. It is also the case in the Schmitt-Grohé and Uribe (2007) model found as an example in the Dynare wiki http://www.dynare.org/DynareWiki/OrderTwo. However, here the impulse responses work without problem, while for the baseline DSGE-model they only work for the first order approximation. So there seems to be a deeper underlying issue.

Any comments would be appreciated.

Re: NaN in the list of eigenvalues

PostPosted: Thu May 13, 2010 9:37 am
by StephaneAdjemian
Hi Johannes, I tried your mod file with dynare branch/4.1 and the snapshot version and I was unable to obtain NaNs for the imaginary part of any generalized eigenvalues. Can you post your log file and your oo_ structure ? If the NaNs appear on the infinite eigenvalues I don't think that this can affect the impulse response function. The problem you have at order two may be instead related to the size of the shocks. Did you try to reduce the size of the innovations?

Best, Stéphane.

Re: NaN in the list of eigenvalues

PostPosted: Thu May 13, 2010 2:42 pm
by jpfeifer
Hi Stéphane,
thanks a lot for your help. You are right that the size of the shocks was too large and prevents the IRFs from popping up in the second order approximation. I was not aware of this potential problem.
However, the NaNi-issue is still there. I attached the oo_-structure. As the forum does not allow .mat file endings, you have to rename the file. I could not attache the log-file as the forum software constantly told me "The upload was rejected because the uploaded file was identified as a possible attack vector."
Apparently, NaNi only appear in the Inf-part of the generalized eigenvalues and hence do not affect the IRFs. However, the problem with the eig-routine of Matlab seems to be have been known around the internet some time ago, see http://student.ulb.ac.be/~claugero/index.html. However, if I try the example posted on the webpage on my machine, everything is fine, no NaNis.
This book http://www.uacg.bg/UACEG_site/acadstaff/userfiles/publ_bg_356_na-new.pdf indicates on page 176 that Matlab sometimes gives Inf as Inf+NaNi for no special reason. Maybe I shouldn't bother, but the absolute value of a Inf+NaNi eigenvalue is NaN, so I am not sure if it leads to further trouble.


Code: Select all

<a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'eqn_solved','CSHelpWindow');">Equation solved</a>.

fsolve completed because the vector of function values is near zero
as measured by the default value of the <a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'fcn_tolerance_fsolve','CSHelpWindow');">function tolerance</a>, and
the <a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'appears_regular','CSHelpWindow');">problem appears regular</a> as measured by the gradient.

<<a href = "matlab: createExitMsg('trustnleqn',1.000000e+000,true,true,'fsolve',3.453271e-013,'default',1.000000e-006,5.207715e-027,'default',1.000000e-003);">stopping criteria details</a>>

 
STEADY-STATE RESULTS:
 
d              1
c              0.40819
zprime         1.00446
lambda         2.58777
R              1.01654
PI             1.01
r              0.0348988
x              0.0884579
u              1
muprime        1.00341
q              1
f              2.55673
ld             0.317845
wstar          1.13352
w              1.11127
PIstarw        1.02002
g1             7.64784
g2             8.4976
yd             0.496648
PIstar         1.01869
mc             0.89825
k              2.71161
m              0
Aprime         1.0028
vp             1.00222
vw             1.00305
l              0.318814
phi            1

<a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'eqn_solved','CSHelpWindow');">Equation solved</a>.

fsolve completed because the vector of function values is near zero
as measured by the default value of the <a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'fcn_tolerance_fsolve','CSHelpWindow');">function tolerance</a>, and
the <a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'appears_regular','CSHelpWindow');">problem appears regular</a> as measured by the gradient.

<<a href = "matlab: createExitMsg('trustnleqn',1.000000e+000,true,true,'fsolve',3.453271e-013,'default',1.000000e-006,5.207715e-027,'default',1.000000e-003);">stopping criteria details</a>>

 
EIGENVALUES:
         Modulus             Real        Imaginary

      1.704e-014      -1.704e-014                0
            0.12             0.12                0
           0.627            0.627                0
          0.7383           0.7383                0
          0.7717            0.769          0.06453
          0.7717            0.769         -0.06453
          0.8609           0.8608           0.0135
          0.8609           0.8608          -0.0135
            0.93             0.93                0
          0.9679           0.9679                0
          0.9866           0.9866                0
           1.017            1.012           0.0962
           1.017            1.012          -0.0962
           1.027            1.027         0.006791
           1.027            1.027        -0.006791
           1.039            1.039                0
           1.123            1.123                0
           1.245            1.245                0
           1.446            1.446                0
             Inf              Inf                0
             Inf              Inf                0
             Inf              Inf                0
             Inf              Inf                0
             Inf              Inf                0
             Inf              Inf                0
             Inf             -Inf                0


There are 15 eigenvalue(s) larger than 1 in modulus
for 15 forward-looking variable(s)
 
The rank condition is verified.
 

<a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'eqn_solved','CSHelpWindow');">Equation solved</a>.

fsolve completed because the vector of function values is near zero
as measured by the default value of the <a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'fcn_tolerance_fsolve','CSHelpWindow');">function tolerance</a>, and
the <a href = "matlab: helpview([docroot '/toolbox/optim/msg_csh/optim_msg_csh.map'],'appears_regular','CSHelpWindow');">problem appears regular</a> as measured by the gradient.

<<a href = "matlab: createExitMsg('trustnleqn',1.000000e+000,true,true,'fsolve',3.453271e-013,'default',1.000000e-006,5.207715e-027,'default',1.000000e-003);">stopping criteria details</a>>

 
MODEL SUMMARY
 
  Number of variables:         28
  Number of stochastic shocks: 5
  Number of state variables:   11
  Number of jumpers:           15
  Number of static variables:  6


MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS

Variables    epsd      epsphi    epsmu     epsA      epsm     
epsd         0.000000  0.000000  0.000000  0.000000  0.000000
epsphi       0.000000  0.000000  0.000000  0.000000  0.000000
epsmu        0.000000  0.000000  0.000000  0.000000  0.000000
epsA         0.000000  0.000000  0.000000  0.000000  0.000000
epsm         0.000000  0.000000  0.000000  0.000000  0.000000
 
POLICY AND TRANSITION FUNCTIONS
                                 yd              R               r               PI     
Constant                    0.496648        1.016536        0.034899        1.010000
R(-1)                      -0.104721        0.746975       -0.000274       -0.045738
w(-1)                       0.045136        0.020074        0.000638        0.053702
yd(-1)                      0.012165       -0.086770        0.000032        0.005313
k(-1)                      -0.039592       -0.004256       -0.000440       -0.002393
vp(-1)                      0.092814        0.010669        0.001028        0.007926
phi(-1)                    -0.008700        0.002324               0        0.010389
d(-1)                       0.001988        0.000224        0.000004        0.000154
c(-1)                       1.131161        0.117028        0.002283        0.053082
PI(-1)                     -0.057558        0.171244       -0.000164        0.590690
x(-1)                       1.157886        0.120785        0.002352        0.057660
epsd                        0.016569        0.001865        0.000037        0.001284
epsphi                     -0.009354        0.002499               0        0.011171
epsmu                      -0.029008        0.004595        0.001016       -0.015468
epsA                       -0.649361       -0.033072       -0.000850       -0.104553
epsm                       -0.138250        0.986139       -0.000361       -0.060382


Again, thanks a lot for your help,

Johannes

Re: NaN in the list of eigenvalues

PostPosted: Fri May 14, 2010 7:09 pm
by StephaneAdjemian
Hi Johannes, The bug has been fixed today. The next release (4.1.2) will contain the correction but you can also get it from the snapshot version (maybe tomorrow and I think you will have to (re)compile the mex files). The mex file mjdgges, which computes the generalized schur decomposition, was buggy. Note that this bug was not affecting the results but only the (inifinte) numbers saved in oo_.dr.eigval.

Best, Stéphane.