FRBNY-DSGE / DSGE-2015-Apr

Replication files for Liberty Street Economics blog post "The FRBNY DSGE Model Forecast--April 2015"

Home Page:http://libertystreeteconomics.newyorkfed.org/2015/05/the-frbny-dsge-model-forecast-april-2015.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

negative diagonal in hessian

lnsongxf opened this issue · comments

When I try to run the command in main.m, error happened, and I don't whether it is my setting fault of something else, the error information shown below:

gibb
Previous mode found, reading in...
Re-computing Hessian

Hessian Element: ( 1 1) incorrect use of hessizero (line 51)
negative diagonal in hessian

errorgibb (line 120)
hessian = hessizero('objfcndsge',[params,para_mask],1,...

Looking forward your reply, thanks for your time.

Are you sure that you're reading in the provided mode file correctly? Otherwise, if you had set reoptimize = 1 and re-ran csminwel before computing the Hessian, it's possible that you haven't found a true mode (perhaps because not enough iterations were used).

let me know if you can not find the mode this week, IRIS will find it in 10 minutes

@pearlzli Thanks for your reply, I checked the settings, and actually I use the default setting reoptimize = 0, I downloaded the master branch hours ago, and use the default settings, so I think it is not a old problem, would you please run the master branch code, and tell me whether you experience the same problem like me.

@ikarib Thanks for your kind reply

Computing the Hessian should work with the mode that we provide (reoptimize = 0). I ran the code on master a few days ago, and it did manage to successfully compute the Hessian. What version of MATLAB are you using? This code was written for MATLAB 09a, and we can't guarantee that base MATLAB functionality hasn't changed between versions.

@pearlzli My matlab version is 15b, maybe this is why I experienced such a problem, thank you so much for patience and kindness, wish you a great day

It turns out that the saved mode file we had previously included in the repository was calculated using an older version of the discrete-time Lyapunov equation solver (dlyap) found in the Control Toolbox. I've recalculated the mode using the newer version of dlyap, which should correspond to the version you are using. The new mode is in commit bfee953. The Hessian computation should work on this parameter vector - please let us know if it doesn't!

**__Dear pearlzli_
@pearlzli @ikarib I got the similar error,

_After downloaded the new mode, I ran the Main.m file, the error is following:__**

"""

Main()
Previous mode found, reading in...
Re-computing Hessian
Hessian Element: ( 1 1) error using hessizero (line 51)
negative diagonal in hessian
error gibb (line 120)
hessian = hessizero('objfcndsge',[params,para_mask],1,...
error Main (line 37)
gibb
"""

as the notes of Troubleshooting, I set the reoptimize = 1 and re-ran the csminwel.m file ,
the command in matlab command window is :

"""
csminwel('objfcndsge_2part',x0,H0,[],crit,nit,...
YY,nobs,nlags,nvar, mspec,npara,trspec,pmean,pstdd,pshape,para_mask,...
para_fix,marglh,coint,cointadd,cointall,MIN, nant, antlags);
"""

!!! Then I got the error as follows:

"""

csminwel('objfcndsge_2part',x0,H0,[],crit,nit,...
YY,nobs,nlags,nvar, mspec,npara,trspec,pmean,pstdd,pshape,para_mask,...
para_fix,marglh,coint,cointadd,cointall,MIN, nant, antlags);
Exiting fzero: Terminate search for intervals containing symbol changes
Because the NaN or Inf function value was encountered during the search.
(The function value at 7.74077 is Inf。)
Please check the function or try again with a different starting value.
NaN values in G0 or G1
Exiting fzero: Terminate search for intervals containing symbol changes
Because the NaN or Inf function value was encountered during the search.
(The function value at 7.74077 is Inf。)
Please check the function or try again with a different starting value.
NaN values in G0 or G1
"""

_Question:**
May you have any idea to solve this error?
thank you for your help

PS(my matlab version is 2015b)

Hi @caimichael, could you look into this?

When I try to run the command in main.m, error happened, and I don't whether it is my setting fault of something else, the error information shown below:

gibb
Previous mode found, reading in...
Re-computing Hessian

Hessian Element: ( 1 1) incorrect use of hessizero (line 51)
negative diagonal in hessian

errorgibb (line 120)
hessian = hessizero('objfcndsge',[params,para_mask],1,...

Looking forward your reply, thanks for your time.

@lnsongxf Hi lnsongxf:
I think we get the same problem, so what 's your solution to solve this error?
thank you very much

Hi @caimichael, could you look into this?

@pearlzli @caimichael
Hi, may I ask some ideas to done this error?

Hi @xiaohaomao. I'll take a look at this and get back to you sometime early next week

Hi @xiaohaomao. I'll take a look at this and get back to you sometime early next week

Thanks for u reply, I look forward to hearing from u early next week.

@caimichael
Hi,Dear Michael:

I ran Mark Song's adjusted code, The re-optimizing seems fine, but the re-computing Hessian still is not work. is number of iteration not enough large? or others parameter setting?

**### _

Matlab Command Window:

<<Main

Previous mode found, reading in...
Re-optimizing
-----------------
-----------------
f at the beginning of new iteration,       738.6837617664
Predicted improvement:   589268.045281305, Norm of gradient:   108560.402106966
lambda =          1; f =  10000000267.7245674
lambda =    0.33333; f =         1363.0298365
lambda =    0.11111; f =          841.0785497
lambda =   0.037037; f =          749.5507078
lambda =   0.012346; f =          739.9205504
lambda =  0.0041152; f =          738.8338075
lambda =  0.0013717; f =          738.6992802
lambda = 0.00045725; f =          738.6846744
lambda = 0.00015242; f =          738.6830384
lambda = 5.0805e-05; f =          738.6829541
lambda = 1.6935e-05; f =          738.6808791
lambda =  5.645e-06; f =          738.6992185
lambda = 1.8817e-06; f =          738.6818263
lambda = 6.2723e-07; f =          738.6824373
lambda = 2.0908e-07; f =          738.6833750
lambda = 6.9692e-08; f =          738.6698939
lambda = 2.3231e-08; f =          738.6776913
lambda = 7.7435e-09; f =          738.6831573
lambda = 2.5812e-09; f =          738.7095473
Norm of dx     10.856
ih = 1
----
Improvement on iteration 1 =        0.013867860
smallest step still improving too slow
max percentage change in the parameters,         0.0000724048
-----------------
-----------------

f at the beginning of new iteration,       738.6698939061
Predicted improvement:   966445.236657376, Norm of gradient:   157034.198248388
Indeterminacy.  2 loose endog errors.
lambda =          1; f =  10000087370.3886261
Indeterminacy.  2 loose endog errors.
lambda =    0.33333; f =  10000001389.2608528
Indeterminacy.  1 loose endog errors.
lambda =    0.11111; f =  10000000175.5333672
lambda =   0.037037; f =  10000000086.8830204
lambda =   0.012346; f =          746.8116089
lambda =  0.0041152; f =          739.6546294
lambda =  0.0013717; f =          738.7934247
lambda = 0.00045725; f =          738.7088530
lambda = 0.00015242; f =          738.6842495
lambda = 5.0805e-05; f =          738.6752594
lambda = 1.6935e-05; f =          738.6829211
lambda =  5.645e-06; f =          738.6777697
lambda = 1.8817e-06; f =          738.6824460
lambda = 6.2723e-07; f =          738.6817974
lambda = 2.0908e-07; f =          738.6830808
lambda = 6.9692e-08; f =          738.6786438
lambda = 2.3231e-08; f =          738.6679321
lambda = 7.7435e-09; f =          738.6830638
lambda = 2.5812e-09; f =          738.6826985
Norm of dx      22.59
ih = 1
----
Improvement on iteration 2 =        0.001961801
smallest step still improving too slow
max percentage change in the parameters,         0.0000586530
-----------------
-----------------
f at the beginning of new iteration,       738.6679321050
Predicted improvement:  1127536.436616009, Norm of gradient:   115602.907150050
Indeterminacy.  1 loose endog errors.
lambda =          1; f =  10000006059.6477070
Indeterminacy.  1 loose endog errors.
lambda =    0.33333; f =  10000000496.9136887
Indeterminacy.  2 loose endog errors.
lambda =    0.11111; f =  10000000133.0478649
Indeterminacy.  1 loose endog errors.
lambda =   0.037037; f =  10000000083.8248272
lambda =   0.012346; f =          796.6142782
lambda =  0.0041152; f =          743.5454359
lambda =  0.0013717; f =          739.2102570
lambda = 0.00045725; f =          738.7350774
lambda = 0.00015242; f =          738.6894285
lambda = 5.0805e-05; f =          738.6804537
lambda = 1.6935e-05; f =          738.6828687
lambda =  5.645e-06; f =          738.6823540
lambda = 1.8817e-06; f =          738.6830193
lambda = 6.2723e-07; f =          738.6827235
lambda = 2.0908e-07; f =          738.6538785
lambda = 6.9692e-08; f =          738.6828159
lambda = 2.3231e-08; f =          738.6829478
lambda = 7.7435e-09; f =          738.6854670
lambda = 2.5812e-09; f =          738.6832638
Norm of dx     30.333
ih = 1
----
Improvement on iteration 3 =        0.014053603
smallest step still improving too slow
max percentage change in the parameters,         0.0006990327
-----------------
-----------------
f at the beginning of new iteration,       738.6538785018
Predicted improvement: 23033662.621742751, Norm of gradient:   153704.543583404
Warning: The matrix is close to a singular value, or a scaling error. Results may be inaccurate。RCOND =  5.306552e-18。 
> In gensys (line 203)
  In dsgesolv (line 96)
  In dsgelh (line 39)
  In objfcndsge (line 15)
  In csminit (line 110)
  In csminwel (line 83)
  In gibb (line 78)
  In Main (line 37) 
lambda =          1; f = 118655575526227706904576.0000000
lambda =    0.33333; f = 247411581256694.5000000
lambda =    0.11111; f =  10096091456.1209183
Indeterminacy.  1 loose endog errors.
lambda =   0.037037; f =  10000003025.5093460
Indeterminacy.  1 loose endog errors.
lambda =   0.012346; f =  10000000343.1721745
Indeterminacy.  2 loose endog errors.
lambda =  0.0041152; f =  10000000111.3540783
lambda =  0.0013717; f =  10000000080.8420582
lambda = 0.00045725; f =          759.1804572
lambda = 0.00015242; f =          740.9799943
lambda = 5.0805e-05; f =          738.9495247
lambda = 1.6935e-05; f =          738.7061400
lambda =  5.645e-06; f =          738.6895686
lambda = 1.8817e-06; f =          738.7151615
lambda = 6.2723e-07; f =          738.6884052
lambda = 2.0908e-07; f =          738.6974255
lambda = 6.9692e-08; f =          738.6835434
lambda = 2.3231e-08; f =          738.7038582
lambda = 7.7435e-09; f =          738.6726205
lambda = 2.5812e-09; f =          738.6828875
lambda = -6.2723e-07; f =          738.6830248
lambda = -2.0908e-07; f =          738.6583343
lambda = -6.9692e-08; f =          738.6828261
lambda = -2.3231e-08; f =          738.7034469
lambda = -7.7435e-09; f =          738.6873627
lambda = -2.5812e-09; f =          738.6839190
Norm of dx     623.36
ih = 1
----
Improvement on iteration 4 =        0.000000000
improvement < crit termination
smallest step still improving too slow, reversed gradient
max percentage change in the parameters,         0.0000000000
Re-computing Hessian

 Hessian Element: ( 1  1)
 Value Used: 231301085.971383 
 Hessian Element: ( 2  2)
 Value Used: 697544011.804410 
 Hessian Element: ( 3  3)
 Value Used: 472217313.015067 
 Hessian Element: ( 5  5)
 Value Used: 878086342.503396 
 Hessian Element: ( 6  6)
 Value Used: 775089637.902060 
 Hessian Element: ( 7  7)
 Value Used: 775295632.096799 
 Hessian Element: ( 8  8)
 Value Used: 777246514.643411 
 Hessian Element: ( 9  9)
 Value Used: 760782286.770350 
 Hessian Element: (10 10)
 Value Used: 631146892.205928 
 Hessian Element: (11 11)
 Value Used: 802289766.005927 
 Hessian Element: (12 12)
 Value Used: 766684186.727237 
 Hessian Element: (13 13)
 Value Used: 734353965.322541 
 Hessian Element: (14 14)
 Value Used: 930397487.402692 
 Hessian Element: (15 15)
 Value Used: 267872887.402914 
 Hessian Element: (17 17)
 Value Used: 769955097.358011 
 Hessian Element: (18 18)
 Value Used: 838851644.290245 
 Hessian Element: (20 20)
 Value Used: 701162509.449684 
 Hessian Element: (21 21)
 Value Used: 529921270.591332 
 Hessian Element: (23 23)
 Value Used: 1011906738.571800 
 Hessian Element: (24 24)
 Value Used: 1.135904 
 Hessian Element: (25 25)
 Value Used: 769390718.841686 
 Hessian Element: (26 26)
 Value Used: 542511043.510841 
 Hessian Element: (27 27)
 Value Used: 979266714.797427 
 Hessian Element: (28 28)
 Value Used: 843295324.882997 
 Hessian Element: (29 29)
 Value Used: 684246789.653854 
 Hessian Element: (30 30)
 Value Used: 377824504.600095 
 Hessian Element: (31 31)
 Value Used: 673274622.495453 
 Hessian Element: (32 32)
 Value Used: 739336611.676397 
 Hessian Element: (36 36)
 Value Used: 44.773250 
 Hessian Element: (37 37)
 Value Used: 916099292.675727 
 Hessian Element: (38 38)
 Value Used: 260.824483 
 Hessian Element: (39 39)
 Value Used: 216.986204 
 Hessian Element: (40 40)
 Value Used: 68.206305 
 Hessian Element: (41 41)
 Value Used: 54660042.654016 
 Hessian Element: (42 42)
 Value Used: 17184645.951098 
 Hessian Element: (43 43)Error using hessizero (line 51)
negative diagonal in hessian

Error gibb (line 121)
    hessian = hessizero('objfcndsge',[params,para_mask],1,...

Error Main (line 37)
gibb

_**