Perfect foresight¶
Consider a series for the exogenous process \((m_t)_{0 \leq t \leq T}\) given exogenously.
The perfect foresight problem consists in finding the path of optimal controls \((x_t)_{0 \leq t \leq T}\) and corresponding states \((s_t)_{0 \leq t \leq T}\) such that:
Special conditions apply for the initial state and controls. Initial state (\({m_0}, {s_0})\) is given exogenously. Final states and controls are determined by assuming the exogenous process satisfies \(m_t=m_T\) for all \(t\geq T\) and optimality conditions are satisfied in the last period:
We assume that \(\underline{u}\) and \(\overline{u}\) are constants. This is not a big restriction since the model can always be reformulated in order to meet that constraint, by adding more equations.
The stacked system of equations satisfied by the solution is:
| Transitions | Arbitrage |
|---|---|
| \(s_0\) exogenous | \(f(m_0, s_0, x_0, m_1, s_1, x_1) \perp \underline{u} <= x_0 <= \overline{u}\) |
| \(s_1 = g(m_0, s_0, x_0, m_1)\) | \(f(s_1, x_1, s_2, x_2) \perp \underline{u} <= x_1 <= \overline{u}\) |
| .... | ... |
| \(s_T = g(m_{T-1}, s_{T-1}, x_{T-1}, m_T)\) | \(f(m_T, s_T, x_T, m_T, s_T, x_T) \perp \underline{u} <= x_T <= \overline{u}\) |
The system is solved using a nonlinear solver.
Computes a perfect foresight simulation using a stacked-time algorithm.
Typical simulation exercises are:
- start from an out-of-equilibrium exogenous and/or endogenous state: specify s0 and or m0. Missing values are taken from the calibration (model.calibration).
- specify an exogenous path for shocks exogenous. Initial exogenous state m0 is then first value of exogenous values. Economy is supposed to have been at the equilibrium for \(t<0\), which pins
down initial endogenous state s0. x0 is a jump variable.
If \(s0\) is not specified it is then set equal to the steady-state consistent with the first value
The initial state is specified either by providing a series of exogenous shocks and assuming the model is initially in equilibrium with the first value of the shock, or by specifying an initial value for the states.
Parameters¶
model : Model
Model to be solved
exogenous : array-like, dict, or pandas.DataFrame
A specification for the path of exogenous variables (aka shocks). Can be any of the
following (note by "declaration order" below we mean the order
of model.symbols["exogenous"]):
- A 1d numpy array-like specifying a time series for a single
exogenous variable, or all exogenous variables stacked into a single array.
- A 2d numpy array where each column specifies the time series
for one of the shocks in declaration order. This must be an
`N` by number of shocks 2d array.
- A dict where keys are strings found in
`model.symbols["exogenous"]` and values are a time series of
values for that shock. For exogenous variables that do not appear in
this dict, the shock is set to the calibrated value. Note
that this interface is the most flexible as it allows the user
to pass values for only a subset of the model shocks and it
allows the passed time series to be of different lengths.
- A DataFrame where columns map shock names into time series.
The same assumptions and behavior that are used in the dict
case apply here
If nothing is given here, `exogenous` is set equal to the
calibrated values found in `model.calibration["exogenous"]` for
all periods.
If the length of any time-series in shocks is less than `T`
(see below) it is assumed that that particular shock will
remain at the final given value for the duration of the
simulation.
s0 : None or ndarray or dict
If vector with the value of initial states
If an exogenous timeseries is given for exogenous shocks, s0 will be computed as the steady-state value that is consistent with its first value.
int
horizon for the perfect foresight simulation
maxit : int maximum number of iteration for the nonlinear solver verbose : boolean if True, the solver displays iterations tol : float stopping criterium for the nonlinear solver ignore_constraints : bool if True, complementarity constraints are ignored. keep_steady_state : bool if True, initial steady-states and steady-controls are appended to the simulation with date -1. Returns
pandas dataframe a dataframe with T+1 observations of the model variables along the simulation (states, controls, auxiliaries). The simulation should return to a steady-state consistent with the last specified value of the exogenous shocks.
Source code in src/dolo/algos/perfect_foresight.py
53 54 55 56 57 58 59 60 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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |