The steady state#

The steady state search can be evoked by calling the function econpizza.PizzaModel.solve_stst() documented below. The function collects all available information from steady_state key of the YAML and attempts to find a set of variables and parameters that satisfies the aggregate equations using the routine outlined in the paper.

Upon failure, the function tries to be as informative as possible. If the search is not successful, a possible path to find the error is to set the function’s keyword argument raise_errors to False. The function then raises a warning instead of failing with an exception, and returns a dictionary containing the results from the root finding routine, such as, e.g. the last Jacobian matrix.


A classic complaint is “The Jacobian contains NaNs”. This is usually due to numerical errors somewhere along the way. While the package tries to provide more information about where the error occurred, a good idea is to follow JAX’s hints on how to debug NaNs.


  • A common gotcha for heterogeneous agent models is that the distribution contains negative values. The routine will be informative about that. This is usually due to rather excessive interpolation outside the grid and can often be fixed by using a grid with larger minimum/maximum values.

  • The steady state procedure is based on the pseudoinverse of the Jacobian. If the procedure fails, it will try to tell you the rank of the Jacobian and the number of degrees of freedom. More degrees of freedom than the Jacobian rank normally implies that you should fix more steady state values and vice versa.

  • If the desired precision is not reached, the error message will tell you in which equation the maximum error did arise. You can use the equations key to get the list of equations (as strings), e.g. print(model['equations'][17]) to get the equation with index 17.

econpizza.PizzaModel.solve_stst(self, tol=1e-08, maxit=15, tol_backwards=None, maxit_backwards=2000, tol_forwards=None, maxit_forwards=5000, force=False, raise_errors=True, check_rank=False, verbose=True, **newton_kwargs)#

Solves for the steady state.

  • tol (float, optional) – tolerance of the Newton method, defaults to 1e-8

  • maxit (int, optional) – maximum of iterations for the Newton method, defaults to 15

  • tol_backwards (float, optional) – tolerance required for backward iteration. Defaults to tol

  • maxit_backwards (int, optional) – maximum of iterations for the backward iteration. Defaults to 2000

  • tol_forwards (float, optional) – tolerance required for forward iteration. Defaults to tol*1e-2

  • maxit_forwards (int, optional) – maximum of iterations for the forward iteration. Defaults to 5000

  • force (bool, optional) – force recalculation of steady state, even if it is already evaluated. Defaults to False

  • raise_errors (bool, optional) – raise an error if Newton method does not converge. Useful for debuggin models. Defaults to True

  • check_rank (bool, optional) – force checking the rank of the Jacobian, even if the Newton method was successful. Defualts to False

  • verbose (bool, optional) – level of verbosity. Defaults to True

  • newton_kwargs (keyword arguments) – keyword arguments passed on to the Newton method


rdict – a dictionary containing information about the root finding result. Note that the results are added to the model (PizzaModel instance) automatically, rdict is hence only useful for model debugging.

Return type: