Boehl-Hommes method#
The package also contains an alternative “shooting” method much aligned to the one introduced in Boehl & Hommes (2021). In the original paper we use this method to solve for chaotic asset price dynamics. The method can be understood as an extension to Fair & Taylor (1983) and is similar to a policy function iteration where the initial state is the only fixed grid point and all other grid points are chosen endogenously (as in a “reverse” EGM) to map the expected trajectory.
Assume the model is given by
f(x_{t-1}, x_t, x_{t+1}) = 0.
We iterate on the expected trajectory itself instead of the policy function. We hence require
d f(x_{t-1}, x_t, x_{t+1} ) < d x_{t-1},
d f(x_{t-1}, x_t, x_{t+1} ) < d x_{t+1}.
This is also the weakness of the method: not every DSGE model (that is determined in the Blanchard-Kahn sense) is such backward-and-forward contraction. Thus, unless you are interested in chaotic dynamics, the standard “stacking” method is to be prefered.
The following example shows how to use the shooting method to a numerically challenging example: the chaotic rational expectations model of Boehl & Hommes (2021). The YAML for this model can be found here.
import numpy as np
import matplotlib.pyplot as plt
import econpizza as ep
from econpizza import example_bh
# parse the yaml
mod = ep.load(example_bh, raise_errors=False)
_ = mod.solve_stst()
# choose an interesting initial state
state = np.zeros(len(mod.var_names))
state[:-1] = [.1, .2, 0.]
# solve and simulate
x, _, flag = ep.find_path_shooting(mod, state, T=500, max_horizon=1000, tol=1e-5)
# plotting
for i,v in enumerate(mod.var_names):
plt.figure()
plt.plot(x[:,i])
plt.title(v)
This will give you boom-bust cycles in asset pricing dynamics:

Below, find the documentation for the additional function:
- econpizza.PizzaModel.find_path_shooting(model, x0=None, shock=None, horizon=30, init_path=None, max_horizon=200, max_loops=100, max_iter=None, tol=1e-05, raise_error=False, verbose=True)#
Find the expected trajectory given an initial state. A good strategy is to first set tol to a low value (e.g. 1e-3) and check for a good max_horizon. Then, set max_horizon to a reasonable value and let max_loops be high.
NOTE: this is painfully slow since the migration to JAX.
- Parameters:
model (PizzaModel) – PizzaModel instance
x0 (array) – initial state
shock (tuple, optional) – shock in period 0 as in (shock_name_as_str, shock_size)
horizon (int, optional) – number of periods to actually simulate. This is NOT the expectations horizon of agents. Defaults to 30
init_path (array, optional) – an initial guess on the trajectory. This should not be necessary
max_horizon (int, optional) – number of periods until the system is assumed to be back in the steady state. A good idea to set this corresponding to the respective problem. Note that a horizon too far away may cause the accumulation of numerical errors. Defaults to 200
max_loops (int, optional) – number of repetitions to iterate over the whole trajectory. Should eventually be high. Defaults to 100
max_iter (int, optional) – number of iterations. Defaults to max_horizon. It should not be lower than that (and will raise an error). Normally it should not be higher, better use max_loops instead.
tol (float, optional) – convergence criterion, defaults to 1e-5
verbose (bool, optional) – degree of verbosity. 0/False is silent. Defualts to True
- Returns:
x_fin (array) – array of the trajectory
fin_flag (int) – error code