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:
Source code in src/dolo/algos/simulations.py
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)
Simulate a model using the specified decision rule.
Parameters¶
model: Model
dr: decision rule
process:
ndarray
initial state where all simulations start
ndarray
realization of exogenous driving process (drawn randomly if None)
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.
Source code in src/dolo/algos/simulations.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
Impulse response functions¶
For continuously valued exogenous shocks, one can perform an impulse response function:
Source code in src/dolo/algos/simulations.py
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.