1.5. Higher-order perturbation
You can solve for higher-order perturbation if you are in one of the following cases:
You are using symbolic derivatives and those derivatives have been precomputed at parse time via the
max_deriv_orderoption to the model factory.You are using automatic derivatives.
You are using numerical derivatives.
You are using matlab derivatives.
And you are able to solve the generalized system of Sylvester equations.
1.5.1. Choosing the derivatives
To change the type of derivatives, use the option
solve_derivatives_type. RISE implements four types:
symbolicnumericalautomaticmatlab
1.5.2. Solving the system of generalized Sylvester equations
The complicated linear problem is solved using a solver with the syntax:
[X, flag, relres, iter, resvec] = linsolver(A, b, ...
TolFun, Maxiter, ...
M1, M2, x0, vargs{:});
Inputs:
A– either a square matrix or a function handle returning the result of the operation \(A \times x\) without explicitly forming and storing \(A\).b– the right-hand side of \(A x = b\).TolFun– tolerance.Maxiter– maximum number of iterations.M1 = []– not set.M2 = []– not set.x0– initial guess.vargs– any additional arguments.
Outputs:
X– the final solution.flag–0if the problem solves;1if the maximum number of iterations is reached; another number otherwise.relres– the relative residualnorm(b - A*x) / norm(b).iter– the iteration number at which the final solution was computed.resvec– vector of residual norms at each half iteration, including the firstnorm(b - A*x0).
Change the default with the option solve_linsyst_solver, a cell
{algo, opts} whose default is
{'tfqmr', struct('TolFun', sqrt(eps), 'MaxIter', 1000)}.
Some of the algorithms usable in MATLAB:
'tfqmr'(default)'bicg''bicgstab''bicgstabl''cgs''gmres'
The tolerance at order 2 and above
The same linear solver solves the systems of the second- and
higher-order coefficients. These systems take the conditioning of the
model’s dynamics, and in heterogeneous-agent models their error is
about a million times the solver’s tolerance. Left at its default,
solve_linsyst_solver is therefore used with TolFun 1e-12 at
orders 2 and above (sqrt(eps) at order 1). On the HANK course’s
hank1 this keeps the risk (\(\sigma^2\)) terms within 1e-3 of
their exact value, at about twice the iterations; at sqrt(eps) they
were 2.4 percent off on a 6 x 2 grid and 6.6 percent on 9 x 2. A value
you set yourself is used as given at every order.
1.5.3. Anticipated shocks
With anticipated shocks the risk terms (the coefficients in
\(\sigma^2\), \(\sigma^3\), …) are made of the moments of the
revisions of the announcements (see How an announcement evolves: pages and revisions). Each page
\(b=0,\dots,h_j\) of each shock \(j\), \(h_j\) its
solve_shock_horizon, receives its own independent innovation with the
law of the shock: \(\sum_j (h_j+1)\) innovations in all, and a joint
moment of any order is the product of single-innovation moments. A shock
that is not anticipated takes one innovation, whatever the horizons of
the other shocks; the constraint-enforcing shocks take none. The state
vector does not change; only the list of innovations grows. Both
higher-order engines (hops and recursive) use the same list. The
first-order solution and the coefficients without \(\sigma\) do not
depend on it.
Tests: models/dsge/solving/anticipated_revisions (closed forms of
\(\sigma^2\), \(\sigma^3\) and \(x\sigma^2\) terms at order 3
in both engines, the residual of the order-2 equation, and a model with
the pages as explicit states).
1.5.4. Higher orders when the steady state switches
Under perturbation M the higher-order engines carry the displacement
between regime anchors in the \(\sigma\)-column of the state
transition, so that the expansion around the isolated steady states is
a consistent Taylor expansion at every order. Under the self-consistent
linearization (solve_perturbation_type='m', see Solving)
the anchors are the rest points of the switching economy and the
displacement is already in the evaluation points; the higher orders are
then computed with the Taylor shift, in which regime \(j\)’s
polynomial is re-expanded at regime \(i\)’s rest point and its
shifted jets replace \(T_j\) in the lead of the pair
\((i,j)\). Order 2 runs through hops (option
solve_perturbation_engine='hops'), any order through the recursive
engine ('recursive', selected automatically above order 2). The two
routes agree at order 2. Rest points, slopes and all higher-order
coefficients are solved jointly, so the low-order coefficients depend on
the order of approximation.