Issue with finding steady state in an e DSGE_lsqnonlin function

Hi all,

I am trying to solve using Fsolve and lsqnonlin functions, an environmental DSGE with an output damage function, an energy sector, a fossil fuel stock reserve and a pollution stock, along with some environmental policy rules, and although the lsqnonlin functions seems to find a steady state, when i populate them in dynare the sum of squared residuals of the static equations is close to 0 → 0.9034 and i receive the message:

"Calling Dynare with arguments: none
Starting preprocessing of the model file ... 
Found 26 equation(s). 
Evaluating expressions... 
Computing static model derivatives (order 1). 
Normalizing the static model... 
Finding the optimal block decomposition of the static model... 
9 block(s) found: 
  8 recursive block(s) and 1 simultaneous block(s). 
  the largest simultaneous block has 18 equation(s) 
                                 and 18 feedback variable(s). 
Computing dynamic model derivatives (order 1). 
Normalizing the dynamic model... 
Finding the optimal block decomposition of the dynamic model... 
2 block(s) found: 
  1 recursive block(s) and 1 simultaneous block(s). 
  the largest simultaneous block has 18 equation(s) 
                                 and 11 feedback variable(s). 
Preprocessing completed. 
Preprocessing time: 0h00m01s.

Residuals of the static equations:
Equation number  1: 1        :      -0.309102
Equation number  2: 2        :       1.108777
Equation number  3: 3        :       3.150875
Equation number  4: k_fossil :      -0.000227
Equation number  5: k_rest   :      -0.089422
Equation number  6: k_total  :      -5.303200
Equation number  7: E        :       1.293382
Equation number  8: E_fossil :       5.471022
Equation number  9: E_renew  :      -0.491174
Equation number 10: X        :      -0.694450
Equation number 11: Z        :      -0.314455
Equation number 12: F        :      -0.151172
Equation number 13: y        :       0.935226
Equation number 14: g        :      -8.619432
Equation number 15: G        :       2.322530
Equation number 16: r        :       0.421466
Equation number 17: w        :      -1.044351
Equation number 18: d        :       0.215754
Equation number 19: 19       :      -5.717700
Equation number 20: a        :      -0.000075
Equation number 21: z        :       0.094200
Equation number 22: tau      :       0.010480
Equation number 23: T_tax    :       0.191910
Equation number 24: cap      :      -0.008940
Equation number 25: A_x      :       0.100000
Equation number 26: ND       :       0.030000

DYNARE_SOLVE (solve_algo=2|4): number of blocks = 9
Nonlinear solver routine returned errorcode=0.

MODEL_DIAGNOSTICS: The steady state cannot be computed


Residuals of the static equations:
Equation number  1: 1        :      -0.290122
Equation number  2: 2        :      -0.029605
Equation number  3: 3        :      -0.063965
Equation number  4: k_fossil :      -0.052717
Equation number  5: k_rest   :      -0.052833
Equation number  6: k_total  :      -0.012239
Equation number  7: E        :      -0.010098
Equation number  8: E_fossil :       0.005844
Equation number  9: E_renew  :      -0.000878
Equation number 10: X        :      -0.141675
Equation number 11: Z        :      -0.112894
Equation number 12: F        :       0.000000
Equation number 13: y        :       0.192982
Equation number 14: g        :      -0.317202
Equation number 15: G        :      -0.472537
Equation number 16: r        :      -0.486529
Equation number 17: w        :       0.041995
Equation number 18: d        :      -0.068860
Equation number 19: 19       :      -0.413802
Equation number 20: a        :       0.000000
Equation number 21: z        :       0.000000
Equation number 22: tau      :       0.000000
Equation number 23: T_tax    :       0.000000
Equation number 24: cap      :       0.000000
Equation number 25: A_x      :       0.000000
Equation number 26: ND       :       0.000000


Error using print_info
Impossible to find the steady state (the sum of squared residuals of the static equations is 0.9034). Either the model doesn't have a steady
state, there are an infinity of steady states, or the guess values are too far from the solution.
Error in steady (line 143)
    print_info(info,options_.noprint, options_);
Error in test_env.driver (line 822)
steady;
Error in dynare (line 310)
    evalin('base',[fname '.driver']);" 

Any idea on how to proceed and what to look for?

Attached you may find the model in Dynare as well as the two .m files used to run lsqnonlin function.
energy_env_steady_equations_lsqnonlin.m (2.6 KB)
run_lsqnonlin_energy_env_L.m (1.2 KB)
test_env.mod (3.5 KB)

Kind regards

Michael

1 Like

The fact that you compute the steady state manually in a separate file but Dynare shows residuals in pretty much every single equation suggests that there is still a problem in your computation and potentially the entered model equations. You should continue debugging them.

Thanks @jpfeifer for your answer. You mean there is a problem in the entered model equations in the .mod file as a structure? or a difference between the model equations in .mod file and .m file?

At any case i tried to reconstruct the model and make it more simple so that i can calculate the steady state easier and then enhance it more. Attach is the .mod file as well as .m file to solve it, but again i receive very small residuals in three equation (-0.000019, 0.000001, 0.000002) , that doesn’t allow dynare to run.

Any idea on how to proceed, or if for example i can set in Dynare less strict rules for the steady state solution (if this is a possible workaround)?

The output message is "Starting Dynare (version 6.1).
Calling Dynare with arguments: none
Starting preprocessing of the model file ... 
Found 12 equation(s). 
Evaluating expressions... 
Computing static model derivatives (order 1). 
Normalizing the static model... 
Normalization failed with cutoff, trying symbolic normalization... 
Finding the optimal block decomposition of the static model... 
3 block(s) found: 
  2 recursive block(s) and 1 simultaneous block(s). 
  the largest simultaneous block has 10 equation(s) 
                                 and 10 feedback variable(s). 
Computing dynamic model derivatives (order 2). 
Normalizing the dynamic model... 
Normalization failed with cutoff, trying symbolic normalization... 
Finding the optimal block decomposition of the dynamic model... 
3 block(s) found: 
  2 recursive block(s) and 1 simultaneous block(s). 
  the largest simultaneous block has 10 equation(s) 
                                 and 4 feedback variable(s). 
Preprocessing completed. 
Preprocessing time: 0h00m00s.


Residuals of the static equations:
Equation number  1: 1        :       0.000000
Equation number  2: l        :       0.000000
Equation number  3: 3        :      -0.000019
Equation number  4: k_fossil :       0.000000
Equation number  5: k_rest   :       0.000000
Equation number  6: E_fossil :       0.000000
Equation number  7: E_renew  :       0.000000
Equation number  8: E        :       0.000000
Equation number  9: y        :      -0.000000
Equation number 10: w        :       0.000001
Equation number 11: X        :      -0.000000
Equation number 12: Z        :       0.000002


MODEL_DIAGNOSTICS: The steady state cannot be computed


Residuals of the static equations:
Equation number  1: 1        :       0.000000
Equation number  2: l        :       0.000000
Equation number  3: 3        :      -0.000019
Equation number  4: k_fossil :       0.000000
Equation number  5: k_rest   :       0.000000
Equation number  6: E_fossil :       0.000000
Equation number  7: E_renew  :       0.000000
Equation number  8: E        :       0.000000
Equation number  9: y        :      -0.000000
Equation number 10: w        :       0.000001
Equation number 11: X        :      -0.000000
Equation number 12: Z        :       0.000002


Error using print_info
The steadystate file did not compute the steady state

Error in steady (line 143)
    print_info(info,options_.noprint, options_);

Error in energy_model.driver (line 429)
steady;

Error in dynare (line 310)
    evalin('base',[fname '.driver']);" 

energy_model.mod (1.8 KB)
steady_state_energy_model.m (4.4 KB)

You can verify that the solver you call in your m-file terminates prematurely without solving the equation system. It is then no wonder that Dynare tells you the solution could not be found.