Inspecting the solution

The output of most solution methods is a decision rule for the controls as a function of the exogenous and endogenous states: dr. This decision rule can be called using one of the following methods:

  • dr.eval_s(s: array): function of endogenous state. Works only if exgogenous process is i.i.d.
  • dr.eval_ms(m: array,s: array): function of exogenous and endogenous values. Works only if exogenous process is continuous.
  • dr.eval_is(i: int,s: array): function of exognous index and endogenous values. Works only if some indexed discrete values are associated with exogenous process.

There is also a __call__ function, which tries to make the sensible call based on argument types. Hence dr(0, s) will behave as the third example.

Tabulating a decision rule

Dolo provides a convenience function to plot the values of a decision rule against different values of a state:

dolo.algos.simulations.tabulate(model, dr, state, bounds=None, n_steps=100, s0=None, i0=None, m0=None, **kwargs)

Stochastic simulations

Given a model object and a corresponding decision rule, one can get a N stochastic simulation for T periods, using the simulate function. The resulting object is an 3-dimensional DataArray, with the following labelled axes: - T: date of the simulation (range(0,T)) - N: index of the simulation (range(0,N)) - V: variables of the model (model.variables)

dolo.algos.simulations.simulate(model, dr, N=1, T=40, s0=None, i0=None, m0=None, driving_process=None, seed=42, stochastic=True)

Simulate a model using the specified decision rule.

Parameters:
model: NumericModel
dr: decision rule
s0: ndarray

initial state where all simulations start

driving_process: ndarray

realization of exogenous driving process (drawn randomly if None)

N: int

number of simulations

T: int

horizon for the simulations

seed: int

used to initialize the random number generator. Use it to replicate exact same results among simulations

discard: boolean (False)

if True, then all simulations containing at least one non finite value are discarded

Returns:
xarray.DataArray:
returns a T x N x n_v array where n_v

is the number of variables.

Impulse response functions

For continuously valued exogenous shocks, one can perform an impulse response function:

dolo.algos.simulations.response(model, dr, varname, T=40, impulse: float = None)

Graphing nonstochastic simulations

Given one or many nonstochstic simulations of a model, obtained with response, or deterministic_solve it is possible to quickly create an irf for multiple variables.

dolo.misc.graphs.plot_irfs(sims, variables=None, titles=None, layout=None, horizon=None, figsize=None, plot_options={}, line_options=None)