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
, process=None
, 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.
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=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
)