API Reference: Solvers & Solutions¶
Container for perturbation outputs.
Attributes:
| Name | Type | Description |
|---|---|---|
decision_rule |
RecursiveDecisionRule
|
First-order recursive decision rule. |
Source code in src/dyno/solver.py
VAR(1) representing a linearized model
Attributes:
| Name | Type | Description |
|---|---|---|
X, Y, Σ |
(N,N) Matrix
|
parameters of the stationary VAR process \(y_t = Xy_{t-1} + Yε_t\), where Σ is the covariance matrix of \(ε_t\) |
symbols |
dict[str, list[str]]
|
dictionary containing the symbols used in the model, the only allowed keys are "endogenous", "exogenous" and "parameters" |
x0 |
N Vector | None
|
the state around which the linearization is done, generally the steady state, by default None |
Source code in src/dyno/solver.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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 | |
simulate(T=40, mode='auto', N=1, units='deviation', shocks=None, initial_states=None, rng=None)
¶
Simulate the solved model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
int
|
Simulation horizon. |
40
|
mode
|
('auto', 'irf', 'random', 'transition', 'deterministic')
|
When |
'auto'
|
N
|
int
|
Number of Monte Carlo trajectories when |
1
|
units
|
('deviation', 'level', 'percent', 'log-deviation')
|
Default output units. |
'deviation'
|
rng
|
Generator | int | None
|
Generator or seed for the random shocks when |
None
|
Source code in src/dyno/solver.py
Solves AX² + BX + C = 0 for X using the chosen method
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
(N,N) Matrix
|
|
required |
B
|
(N,N) Matrix
|
|
required |
C
|
(N,N) Matrix
|
|
required |
method
|
str
|
chosen solver: either "ti" for fixed-point iteration or "qz" for generalized Schur decomposition, by default "qz" |
'qz'
|
options
|
dict
|
dictionary of optional parameters to pass to the chosen solver, by default {} |
None
|
Returns:
| Type | Description |
|---|---|
(X, evs) : tuple[(N,N) Matrix, 2N Vector|None]
|
solution of the equation as well as sorted list of associated generalized eigenvalues if the chosen method is "qz" and None otherwise |
Raises:
| Type | Description |
|---|---|
NoConvergence :
|
when the convergence threshold is not reached within the maximal allowed number of iterations (only in |
LinAlgError :
|
when a singular matrix is obtained during iterations in |
ValueError :
|
when a matrix containing a NaN is obtained |
Source code in src/dyno/solver.py
Solves AX² + BX + C = 0 for X using QZ decomposition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
(N,N) Matrix
|
|
required |
B
|
(N,N) Matrix
|
|
required |
C
|
(N,N) Matrix
|
|
required |
tol
|
float
|
error tolerance, by default 1e-15 |
1e-15
|
Returns:
| Type | Description |
|---|---|
(X, evs) : tuple[(N,N) Matrix, 2N Vector]
|
solution of the equation as well as sorted list of associated generalized eigenvalues |
Raises:
| Type | Description |
|---|---|
LinAlgError :
|
when Blanchard-Kahn conditions are not verified (less than N generalized eigenvalues inside the unit ball) |
Source code in src/dyno/solver.py
Solves AX² + BX + C = 0 for X using fixed-point iteration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
(N,N) Matrix
|
|
required |
B
|
(N,N) Matrix
|
|
required |
C
|
(N,N) Matrix
|
|
required |
T
|
int
|
Maximum number of iterations. If more are needed, |
10000
|
tol
|
float
|
convergence threshold, by default 1e-10 |
1e-10
|
Returns:
| Type | Description |
|---|---|
(X, evs) : tuple[(N,N) Matrix, None]
|
solution of the equation and None (necessary to have a common solver interface) |
Raises:
| Type | Description |
|---|---|
NoConvergence :
|
when the convergence threshold is not reached within the maximal allowed number of iterations |
LinAlgError :
|
when a singular matrix is obtained while iterating |
ValueError :
|
when a matrix containing a NaN is obtained while iterating |
Source code in src/dyno/solver.py
Source code in src/dyno/solver.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
Computes conditional and unconditional moments of stationary process \(y_t = X y_{t-1} + Y e_t\)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
(N,N) Matrix
|
Transition matrix defining the stochastic process. |
required |
Y
|
(N,N) Matrix
|
Shock impact matrix defining the stochastic process. |
required |
Sigma
|
(N,N) Matrix
|
Covariance matrix of the independent identically distributed error terms e_t. |
required |
Returns:
| Type | Description |
|---|---|
Gamma_0, Gamma : (N,N) Matrix
|
Conditional and unconditional covariance matrices of the stationary process y_t respectively. |
Notes
The unconditional covariance matrix Γ is computed in the following way:
Applying the linear covariance operator to both sides of the equation \(y_t = X y_{t-1} + Y e_t\) yields $$ \mathrm{Cov}(y_t) = X ⋅ \mathrm{Cov}(y_{t-1}) ⋅ X^* + Y ⋅ \mathrm{Cov}(e_t) ⋅ Y^* $$ By stationarity of \(y_t\), \(\mathrm{Cov}(y_t) = \mathrm{Cov}(y_{t-1}) := Γ\), so $$ Γ = X Γ X^* + Γ₀ $$ By applying the Vec-operator, we get the following equation: $$ \mathrm{Vec}(Γ) = (X ⊗ X) \mathrm{Vec}(Γ) + \mathrm{Vec}(Γ₀) $$ Which gives the following solution $$ \mathrm{Vec}(Γ) = (I_{N^2} - X ⊗ X)^{-1} \mathrm{Vec}(Γ₀) $$