1.7. Perturbation types for regime-switching models
Use 'm' for the default: self-consistent expansion points with
curvature higher orders. M comes in three variants, chosen by position:
{'m','isolated'}, {'m','curvature'} and {'m','joint'}. Bare
'm' is {'m','curvature'}. 'maih' is the full name of 'm'
and means exactly the same. The isolated variant expands each regime at
its own steady state; it preserves isolated regime steady states and the
existing sstate_unique behavior.
A perturbation of a constant-parameter model names one thing, the scale \(\sigma\) of the shocks, and expands the policy function around the deterministic steady state, the point the economy rests at when \(\sigma = 0\). A regime-switching model adds a second source of variation, the Markov chain, and when the switching parameters move the steady state there is no longer one point to expand around. Each perturbation type in RISE is a different answer to that problem, and the answers differ in three places:
What is perturbed. The shock scale alone (
{'m','isolated'},'bm','m'), the shock scale and the off-diagonal transition probabilities ('mw'), or the shock scale and the switching parameters themselves ('frwz').What the economy is at the origin of the perturbation. The switching economy without shocks (
{'m','isolated'},'m','bm'), the regimes in isolation ('mw'), or one economy with common parameters ('frwz').Where the derivatives are taken. At the isolated steady states with the lead of the pair \((i,j)\) evaluated at regime \(j\)’s steady state (
{'m','isolated'},'mw'), at the P-weighted anchors of Barthélemy and Marx ('bm'), at the rest points of the shock-free switching economy with the lead at the transition point ('m'), or at the steady state of the common-parameter economy ('frwz').
The type is selected with the solve_perturbation_type option of
solve (or set); the syntax of each value is given in its
section below. On a constant-parameter model every type returns the
standard perturbation. With a common steady state across regimes,
{'m','isolated'}, 'bm', 'm' and 'frwz' with an
empty partition return the same solution, the standard perturbation;
'mw', which tilts the transition matrix, and
'frwz' with a switching parameter in its partition do not (see
their sections). The other differences below are about what happens
when the steady state switches.
1.7.1. The types at a glance
Value |
Perturbed |
Economy at the origin |
Anchors |
Lead of pair \((i,j)\) at |
First-order constant |
|---|---|---|---|---|---|
|
\(\sigma\) |
switching, shock-free |
isolated steady states \(\bar x_i\) |
\(\bar x_j\) |
the expected residual and the lead shift, when the regime steady states differ |
|
\(\sigma\) and \(P(\sigma)=(1-\sigma)I+\sigma P\) |
regimes in isolation |
isolated steady states |
\(\bar x_j\) |
from the tilt of \(P\) |
|
\(\sigma\) and \(\theta_i(\chi)=\bar\theta+\chi(\theta_i-\bar\theta)\) |
common parameters \(\bar\theta\) (ergodic mean) |
one steady state \(\bar x(\bar\theta)\) |
\(\bar x\) |
from the parameter gap |
|
\(\sigma\) |
switching, shock-free |
P-weighted anchors (their Assumption 2) |
\(\bar z_j\) |
none |
|
\(\sigma\) |
switching, shock-free |
rest points \(\hat x_i\) of that economy |
transition point \(T_j(\hat x_i)\) |
none (certainty equivalence) |
Two relations hold between them and are checked in the test suite.
With a common steady state {'m','isolated'}, 'bm' and 'm' are
identical at every order, and 'frwz' with an empty partition is
{'m','isolated'}. With P = I (regimes that never communicate) 'm' is
'mw' at first order, and {'mw',{'*none'}} is {'m','isolated'}.
1.7.2. M with regime-steady-state expansion points
In this explicit configuration only the shock scale is perturbed, the transition matrix
stays active in the first-order slopes, and regime \(i\)’s policy is
expanded around its own isolated steady state \(\bar x_i\), the
solution of the model with the parameters of regime \(i\) held
forever. The derivatives of the pair \((i,j)\) are evaluated with
next period’s variables at \(\bar x_j\) and the current and lagged
variables at \(\bar x_i\). When the steady states differ across
regimes, the isolated steady states are not rest points of the switching
economy, and the first-order constant carries the two terms of a switch
at the expansion point: the residual of the expected system,
\(\sum_j d_{ij}\) with next period’s variables at \(\bar x_j\),
and the lead after a switch, regime \(j\)’s policy from today’s state,
which differs from \(\bar x_j\) by \(T_j(\bar x_i-\bar x_j)\). On
an affine model the expansion is then exact. The higher orders are the
standard ones, computed by the hops engine or the recursive engine.
This is exactly right when the steady state does not switch, which is
the case of switching volatilities, switching policy-rule coefficients
and switching persistences, and it is what most of the estimation
literature uses. When a switching parameter moves the steady state (a
productivity level, an inflation target, a tax rate), the isolated steady
state is not a rest point of the switching economy, because agents in
regime \(i\) anticipate the switch: the expansion point is then a
point the reference economy never visits. The first-order constant
corrects the level, and the error falls with the order (the Euler-error
test below gives a monotone verdict on the growth model with a 5
percent gap: \(-3.9\) and \(-5.4\) at orders 1 and 2), but the
self-consistent default 'm', which expands at the rest points
themselves, is more accurate at every order (\(-4.9\) and
\(-6.1\)). Until 8 November 2026 the constant carried neither term,
and the error stayed at the level of the gap whatever the order.
This is the former plain M. It retains the existing sstate_unique
behavior; it does not redefine that configuration as an ergodic-mean
expansion. M takes inline settings, not a partition list.
When the steady state or the growth rate switches, change the type
The isolated variant expands at a rest point only when every regime has
the same steady state; when the steady states differ, its first-order
constant corrects the level, but the default 'm' is more accurate.
On a balanced growth path (solve_bgp true), every regime must also
have the same growth rates. When they differ across regimes, solve the
model with 'mw' or with 'm':
m = solve(m,'solve_perturbation_type','mw');
m = solve(m,'solve_perturbation_type','m');
Plain 'm' now selects self-consistent expansion points by default.
The reason is where perturbation M takes its derivatives. For the pair of regimes \((i,j)\), it takes next period’s variables on regime \(j\)’s steady state or path, and the current and lagged variables on regime \(i\)’s. When the regimes differ, regime \(i\)’s equations do not hold at that point, so the expansion is not taken around a solution of the model.
On a balanced growth path, the solution loses the exact unit root of the path. Moving the state one period along the path of regime \(r\) must move every variable by its growth in that regime: \(T_{x,r}\,g_r=g_r\). Take a New Keynesian model in levels whose technology growth switches between 0.5 and 0.1 percent a period, with switching probabilities 0.1 and 0.2.
Under
{'m','isolated'}, the largest entry of \(T_{x,r}\,g_r-g_r\) is \(3.6\times10^{-6}\) in regime 1 and \(1.4\times10^{-6}\) in regime 2. The coefficient of consumption on the level of technology is 0.99929 in regime 1 and 1.00142 in regime 2, instead of 1. Its gap from 1 is of the order of the switching probability times the difference between the growth rates.The error accumulates along a simulation. With no shocks and regime 1 throughout, the ratio C/A should settle at a constant. Under
{'m','isolated'}it falls by \(3.5\times10^{-6}\) a period, or 0.35 percent after 1000 periods.Two paths that start with technology and consumption 1 percent apart, with the same shocks and regimes, should have the same C/A. Under
{'m','isolated'}they differ by up to \(1.4\times10^{-5}\).Under
'mw'and'm', the coefficient is 1, C/A settles, and the two paths of C/A agree.'mw'keeps the unit root to round-off (about \(10^{-17}\)).'m'keeps it within the tolerance of its outer iteration: \(2\times10^{-13}\) with the defaultTolFunof \(10^{-8}\), about \(10^{-17}\) with aTolFunof \(10^{-14}\).
Models whose steady state and growth rates are the same in every regime
are unaffected: switching volatilities, switching policy-rule
coefficients, switching persistences, and models with a single regime,
stationary or growing. For them, the default 'm' uses the standard
perturbation at the common steady state and remains the recommended type. The unit test in
models/dsge/solving/solve_perturbation_strategies/switching_growth
locks the exact path under 'mw' and 'm'.
1.7.3. The Maih–Waggoner perturbation ('mw')
Maih and Waggoner (2018) perturb the transition matrix along with the shocks: \(P(\sigma)=(1-\sigma)I+\sigma P\), so that at the origin the regimes are isolated and each has its own deterministic steady state, a valid perturbation in the classical sense. The first-order slopes are then those of the isolated regimes (decoupled across regimes), and the switching enters the first order through a constant that comes from the derivative of the policy with respect to the tilt of \(P\), which RISE computes from the \(\sigma\)-equation of the first-order system. Syntax:
m = solve(m,'solve_perturbation_type','mw'); % tilt every chain
m = solve(m,'solve_perturbation_type',{'mw',{'dan'}}); % tilt the chain 'dan' only
m = solve(m,'solve_perturbation_type',{'mw',{'*none'}}); % no tilt: identical to {'m','isolated'}
The partitioned form is {'mw', partition}, also accepted as
{'maih_waggoner', partition}. The partition is a cell array of Markov
chain names, not switching-parameter names. It selects the chains whose
off-diagonal probabilities are tilted: each selected chain has transition
matrix \(I\) at \(\sigma=0\); unselected chains keep their original
transition probabilities and continue switching there. With a partial
partition the expansion therefore retains switching through the unselected
chains, rather than isolating every regime. When the regimes of an
unselected chain have different steady states, the first-order constant
carries the residual of the expected system at the regime steady states
and the lead shift after a switch, as for {'m','isolated'}.
The accepted selectors are:
{'chain1', 'chain2', ...}: the named chains only;{}or{'*all'}: every chain;{'*none'}: no chain;{'*all_but', 'chain1', ...}: every chain except the named ones.
Names must be declared Markov chains other than 'const'. A special
selector must come first; '*all' and '*none' must appear alone.
Plain 'mw' tilts every
chain. 'mw' and 'maih_waggoner' are the same value. The 'dan'
example above is used in test_switching_frwz_nk.
What to expect. The scheme is the natural one when the regimes are
distinct economies that last long, since each regime’s steady state is
genuinely a point the economy rests at for a long time, and it is the
scheme whose reference economy is deterministic. Two things follow from
the decoupling. The first-order slopes of a regime do not depend on the
transition probabilities, so a regime whose first-order system, taken
alone as a constant-parameter model, has more stable roots than
predetermined variables (a passive monetary policy) has several bounded
first-order solutions under 'mw', whatever the transition
probabilities. With the default solver setting RISE detects the decoupled
system, uses the eigenvalue solver regime by regime and reports that the
regime has more stable roots than predetermined variables (return code
21, as on the FRWZ NK model whose second regime is passive); naming
'mfi' explicitly returns one of the bounded
solutions, the one the iteration selects. And
along the path \(P(\sigma)\) the rest points of the switching
economy move like \(p/(p+\kappa)\) in the switching probability
\(p\), a saturating function whose Taylor series in \(\sigma\)
converges only when \(p\) is small relative to the speed
\(\kappa\) at which the state adjusts: the higher orders of 'mw'
reconnect with the exact rest points when the regimes last hundreds of
periods and diverge when they last tens. The Euler-error test shows this
as a non-monotone verdict that does not respond to the shock scale.
1.7.4. The Foerster–Rubio-Ramírez–Waggoner–Zha perturbation ('frwz')
Foerster, Rubio-Ramírez, Waggoner and Zha (2016) perturb the switching parameters along with the shocks: \(\theta_i(\chi)=\bar\theta+ \chi(\theta_i-\bar\theta)\), where \(\bar\theta\) is the ergodic mean of the parameters, so that at the origin the regimes are identical and the economy has one steady state \(\bar x(\bar\theta)\). The expansion is a joint Taylor series in \((\sigma,\chi)\) around that point, evaluated at \((1,1)\). Syntax:
m = solve(m,'solve_perturbation_type',{'frwz',{'mu'}}); % perturb mu only
m = solve(m,'solve_perturbation_type','frwz'); % perturb every switching parameter
The cell form is the version the paper recommends: the partition names
the switching parameters that move the steady state, which are perturbed;
the other switching parameters keep their regime dependence, as under
{'m','isolated'}. Plain 'frwz' perturbs every switching parameter, which the
paper calls the naive perturbation. The distinction matters: a
persistence or a policy coefficient that switches by a large amount is a
poor perturbation variable, and on a model whose persistence switches
from 0.9 to 0.5 with a common steady state the naive form is
non-monotone in the order while the partitioned form is {'m','isolated'} and
converges. The partition may be {'*all'}, {'*none'} or
{'*all_but', 'v1', ...}.
What to expect. FRWZ is a valid perturbation whose series converges on every model tested where the gap between steady states is moderate, and at higher orders it is the most accurate scheme on the growth model of the test suite. Its properties come with four consequences to know about.
The first order is regime-blind in the slopes. The parameters in the partition enter the first-order solution only through the regime-specific constants (the terms of order \(\chi\)); the slopes are those of the common-parameter economy and are the same in every regime. Regime-specific dynamics from a switching level, target or tax appear at order 2, through the cross terms in \(\chi x\). Estimation at first order, the common practice, therefore uses a solution in which the regimes differ by their intercepts only. On the growth model with a 5 percent productivity gap the two regimes’ slopes are identical under FRWZ to the last digit, while they differ by 0.13 (
{'m','isolated'}), 0.17 ('mw') and 0.26 ('m') in their largest entry.The expansion point is a point no regime visits. The steady state of the ergodic-mean economy is between the regimes’ rest points, and the polynomial has to reach each regime’s rest point through the series in \(\chi\). The rest points are reproduced with an error of order \(g^{k+1}\) in the gap \(g\) at order \(k\), so they are only as good as the order.
The gap is a perturbation variable. A larger parameter or steady-state gap can change how the measured residuals behave across orders. A non-monotone Euler-error pattern alone does not determine a convergence radius or establish that the gap caused it.
The partition is a modeling choice. The user has to say which parameters are perturbed, and there is a version of the scheme for each choice; the steady-state-moving parameters are the recommended one.
FRWZ does not require the isolated steady states to exist. On the FRWZ RBC model with a
negative growth rate in one regime (\(\mu=-0.0337\)), that regime
has no steady state in isolation: the net return the Euler equation
requires, \(\beta^{-1}e^{(1-\upsilon)\mu}-1+\delta\), is
\(-0.038\), the capital stock that would deliver it is complex, and
{'m','isolated'}, 'mw' and 'bm' stop at
the steady-state stage with return code 1. {'frwz',{'mu'}} solves from
the steady state of the ergodic-mean economy (\(\bar\mu=0.0070\)),
which exists. The switching economy itself does have a rest point in
that regime, since agents expect the return of positive growth, and
'm' reaches it through its Start option, a homotopy in the
parameter gap from the ergodic-mean steady state: at first order it
converges to rest points of 9.24 and 47.88 for the capital stock. But
with probabilities of staying of 0.75 and 0.5 the regimes last one to
four periods, the economy never gets near a rest point 40 units from
where it lives, and the M’s Euler error, \(10^{-2.5}\), is behind
FRWZ’s \(10^{-3.2}\); its higher orders do not converge there. Fast
switching is FRWZ’s domain, persistent regimes with a switching steady
state the M’s.
M with self-consistent expansion points ('m')
Perturbation M scales only the future shocks and keeps the transition
matrix active in the first-order slopes. Its reference economy is the
shock-free switching economy: parameters switch, shocks are off. When
the steady state differs across regimes, that economy does not rest at
the isolated steady states: after a switch the state moves toward the
new steady state at the rate given by the policy slopes, and agents
anticipate further switches. Expanding around the isolated steady
states, with the lead of the pair \((i,j)\) evaluated at regime
\(j\)’s steady state, is then an expansion around points the
reference economy never visits. The first-order solution of {'m','isolated'}
corrects for that with its constant (the residual of the expected system
at the isolated steady states and the lead shift after a switch); its
forward-looking residual then falls with the order, but the
self-consistent expansion below, taken at the rest points themselves, is
more accurate at every order.
Self-consistent expansion points are the default configuration of M,
requested as 'm'. It keeps the same perturbation principle and
moves the expansion configuration: the anchors are the rest points \(\hat x_i\) of the
shock-free switching economy, and the derivatives of the pair
\((i,j)\) are evaluated at the transition point, the value of regime
\(j\)’s policy at regime \(i\)’s rest point. Rest points and
slopes are determined jointly by a fixed point (Anderson-accelerated
functional iteration); the inner problem at each iteration is the usual
coupled quadratic, so every regime-switching solver applies. The
\(\sigma\)-constant is zero by construction (certainty equivalence
at first order). With a common steady state the option returns exactly
plain {'m','isolated'}, at every order and at the cost of {'m','isolated'}: the rest configuration
is the steady state and every transition point is that same point, so the
solve hands over to the standard perturbation without an outer iteration
(report: outer 0, method 'common steady state'). With
P = I it returns 'mw' at first order. On a constant-parameter
model there is nothing to re-anchor: the request is accepted and
solve returns the {'m','isolated'} solution. Optimal-policy models are
re-anchored like any other (see Optimal-policy models below).
Steady states solved separately can differ across regimes through solver
noise, in which case M takes its outer loop. Supply the exact steady state
with sstate_imposed=true and check the original model equations in every
regime. The common-steady-state check retains its absolute 1e-10 test.
At solve_order 2 and above the default higher orders
(the curvature variant, described below) are one pass of the
standard higher-order engine from the first-order configuration: the rest
points stay at their first-order values, and an order-K solve costs the
first-order stage plus one standard order-K solve, the cost of {'m','isolated'}’s
higher orders. The refinement 'joint' re-expands regime \(j\)’s
polynomial at regime \(i\)’s rest point (the Taylor shift) and solves
rest points, slopes and all higher-order coefficients as one fixed point,
through the toolbox’s recursive engine; under it the first-order block of
an order-2 solution is not the order-1 solution, because the rest
points and slopes are outputs of the closure and improve with the order.
The higher-order stages run only if the first-order block is mean-square
stable (return code 25 otherwise), and the returned solution passes the
same test at every order.
The variant comes second in solve_perturbation_type; settings follow
it as name-value pairs:
m = solve(m,'solve_perturbation_type','m');
m = solve(m,'solve_perturbation_type',{'m','MaxIter',500,'Display','iter'});
m = solve(m,'solve_perturbation_type',{'m','joint','Continuation',false});
m = solve(m,'solve_perturbation_type',{'m','isolated'});
{'m','MaxIter',500} is the curvature variant with that setting. The
isolated variant takes no setting: supplying one is an error, even if its
value equals its default. Continuation applies to the joint variant
only. Unknown or duplicate names, missing values, and invalid values are
rejected. Names and enumerated values are case-sensitive. These settings
are not accepted for the other perturbation types.
The keys ExpansionPoint and HigherOrders are retired. A new call
that uses them stops with a migration error that gives the positional
form: {'m','ExpansionPoint','regime_steady_state'} becomes
{'m','isolated'}, and {'m','HigherOrders','joint'} becomes
{'m','joint'}. Former separate-method spellings, cell payloads, and
options constructors also raise migration errors. There is no public
options object or second method name.
Saved models translate on loading. A saved bare 'm' or 'maih' is
today’s default; its stored policy is kept and solved again at the next
solve. Saved settings with the former keys become the matching variant,
and former separate-method models become the matching self-consistent variant with their
settings. Stored policies and calibration are unchanged. The inactive
continuation field in older curvature configurations is omitted.
The settings follow MATLAB’s optimization options where a name exists:
MaxIter (300) and TolFun (1e-8) for the outer fixed point,
Algorithm ('anderson', the default, or 'picard'),
InitDamping (1, the initial step of the Picard iteration), Display
('off' by default, 'final', 'iter'), Continuation (true for joint
higher orders), Start and
the variant (see below). The
previous solve’s rest configuration and policy jets are reused as
the starting point within the same expansion configuration when their
dimensions match, which is what estimation
needs; there is no option for it. The solver report is in
model_data.state_space{1}.m_expansion: outer iterations, method, residual of
the rest-point equations, displacement of the anchors, whether the warm
start was used, and the rest configuration xhat.
A request for the steady state alone (sstate) or derivatives without
the solve (solve_derivatives_only) first computes the isolated anchors.
It succeeds under default M when those anchors are common. When they differ,
the rest configuration requires a full solve and the request raises
rise:m:steady_state_only. Call solve, or select
{'m','isolated'} for isolated steady states.
After a solve, get(m,'sstate') returns the rest points.
Backward-only linear models use the direct first-order solution at the current parameters. A warm policy is an initial guess and cannot replace that solution. Simulation plans request isolated anchors for unspecified initial and terminal values; a previously solved model retains the anchors supplied by its solution.
The linear-quadratic loose-commitment and stochastic-replanning solvers
require their de-weighted promise block to depend on the current regime
alone. At self-consistent transition points this restriction can fail when
anchors differ. Default M then returns 37 (M_LQ_PROMISE_UNSUPPORTED),
with the original identifier and message in
model_data.state_space{1}.m_failure. Common-anchor models satisfying
the policy solver’s restrictions remain supported. Code 29 means that the
outer fixed point did not converge although every evaluation of its map
succeeded. When an evaluation failed, M returns the code of the last failure
instead. That is the code of the derivatives (2 when they cannot be evaluated
at a trial point), of the first-order solve (21 when it found no solution
within its iteration limit), 22 when that solve returned no solution or a
non-finite one, or the code of a higher-order solve.
Limits known at the time of writing: with very large gaps between rest
points (a quarter of the capital stock in the test model), or with
transition probabilities whose curvature is on the scale of the gap, the
outer fixed point may fail to converge from a cold start at order 3 and
above with the joint variant. The Continuation option (default
true for joint higher orders) then walks the
displacement carried by the higher-order feedback from 0 to 1 with
adaptive steps; if the fixed point disappears before the full shift the
solve returns retcode 29 (M_OUTER_NOT_CONVERGED), or the code of the
last failed evaluation as above, and the report records the displacement
fraction reached (mu_reached). Order 2
converges without continuation in all cases tested. Anticipated shocks
are supported at every order. Explicit Continuation settings with
curvature higher orders are rejected as inactive.
Where the rest-point iteration starts is the Start option: 'auto'
(the default) starts from the isolated steady states and, when a regime
has none and the steady-state stage fails, from the unique steady state
of the ergodic-mean economy, the point FRWZ expand around; 'isolated'
and 'ergodic' force one or the other. From the ergodic-mean point the
rest points can be far away, so the solve walks the switching parameters
from their ergodic mean, where the M is the standard perturbation, to
their regime values, warm-starting the outer fixed point at each step (a
homotopy in the parameter gap, with the same adaptive steps as the
displacement continuation). The report records the start (start),
whether the homotopy ran (gap_continuation) and the fraction of the
gap reached (mu_gap_reached). If model definitions fail along the gap,
the solve returns their numerical error code with the original calibration
restored. Start also accepts a numeric matrix
(endogenous variables by regimes, in the order of the endogenous
variables): an explicit starting rest configuration, which takes
precedence over the warm start and is reported as 'given'. It is the
device for exploring the branches of the rest-point equation, which can
have several solutions on a model with a peg regime (two, both
mean-square stable at first order, on the ZLB model of the M note with
two-quarter spells); a start of the wrong size is refused. On the growth model the two starts
reach the same fixed point to \(10^{-9}\); on FRWZ’s RBC model, where
the contraction regime has no isolated steady state, the first order
converges to rest points of 9.24 and 47.88 for the capital stock, 40
units from the start, while the higher orders do not converge.
What the solve does once and what it repeats: the isolated steady states are solved once, in the steady-state stage every perturbation type runs, and never again; they start the outer iteration, and the rest points move inside it by one Newton step per iteration at a negligible cost. What every outer iteration recomputes is the derivatives of the model at the transition configurations, the first-order block and, at order 2 and above, the higher-order engine. Profiled on the growth and NK models, the derivatives are 16 to 24 percent of a first-order solve (the inner first-order solves 23 to 38 percent), a third at order 2, and 15 to 20 percent at orders 3 and 4, where the engine’s right-hand sides and Sylvester solves are 50 to 75 percent. The cost is the number of outer iterations, 7 to 80, times the coefficient solves inside each.
How the higher orders are computed is the variant: 'curvature'
is the default and 'joint' the refinement. 'joint' is the
Taylor-shift construction above: the rest points,
the first order and every higher order are one fixed point, each order
re-expanded at the transition points with the feedback of the orders
above it, which is what makes the residual fall with the order (growth
model with a 5 percent gap: \(-4.8\), \(-6.1\), \(-7.1\),
\(-8.1\) at orders 1 to 4, in \(\log_{10}\) of the Euler
error). Its cost is the number of outer iterations, 20 to 70 on the
models tested, each one a full order-K solve; the outer tolerance is a
modest lever (1e-6 instead of 1e-8 saves 10 to 30 percent of the
iterations at no cost in accuracy; at 1e-4 the growth model needs 48
instead of 72 iterations at order 4 and loses 0.7 of a decade).
The separate solve_perturbation_engine='recursive' engine remains
available, including its use by curvature and the joint map.
The report records the retained choice in higher_orders.
'curvature' (the default) keeps that feedback and still costs one order-K solve: it
computes the higher orders as a perturbation in the curvature of the
model around the first-order M configuration. The rest points and the
first order are solved as at order 1 (first derivatives only), the
derivatives up to the solve order are evaluated once at the converged
transition points, and one pass of the standard higher-order engine
computes the orders 2 to K with the displacement between the rest points
carried by the \(\sigma\) column of the pair’s state transition for
the orders above 1, the first-order lead slope being composed without it
since its shift is part of the transition point (hops by default,
the recursive engine above order 5 or on request through
solve_perturbation_engine; the two agree to \(10^{-8}\)). The feedback of each order on the
constant and the slopes then comes out in the \(\sigma\) slots of
that order, as a variance correction does in the standard perturbation,
and the anchors stay at the first-order rest points: the held fixed point
of the polynomial moves where the joint fixed point moves its rest
points. The construction is a perturbation in the strict sense (the
model linearized at the M configuration is solved exactly by the
first-order M, and the corrections are linear at every order), it has
the same consistency order as the joint fixed point, it nests the
standard perturbation with a common steady state, and it has no fixed
point to fold; what can fail is the series, and the report gives the
largest coefficient by order (coefficient_norm), which falls with the
order when the series converges. On the growth model with a 5 percent gap
it gives \(-4.8\), \(-6.2\), \(-7.1\), \(-8.0\) at orders
1 to 4 against \(-4.8\), \(-6.1\), \(-7.1\), \(-8.1\)
joint, in about one second at every order instead of 74 outer
iterations at order 4; with a 20 percent gap it is monotone through order
4 (\(-5.2\)) where the joint fixed point folds; on FRWZ’s NK model it
trails the joint scheme by 0.3 to 0.9 of a decade at orders 2 to 4
(\(-5.5\) against \(-6.4\) at order 4) and stays three decades
ahead of FRWZ’s own partitioned expansion; on FRWZ’s RBC model, whose
regimes last two to four periods, its series diverges at order 4, where
the joint scheme does not solve above order 1 and FRWZ’s is the scheme to
use. The report records higher_orders 'curvature', stages
1 and the outer iterations of the first-order stage; the accuracy
report labels the default m and the joint variant m{joint}.
The isolated variant’s label is m{isolated}.
Note
Under perturbation M, RISE auto-declares
several auxiliary parameters (iota_frwz_*, ss_frwz_*,
perturbator, …) that are not used in the model. Their
absence from your calibration triggers a benign
"1(incomplete!)" warning at parse time. This warning is not
an error; do not chase it. Chase the retcode.
The Barthélemy–Marx perturbation ('bm')
Barthélemy and Marx (2016, Solving endogenous regime switching models)
perturb the shock scale only, as {'m','isolated'} does, and define a
regime-dependent steady state by the P-weighted condition of their
Assumption 2: for every regime \(i\),
the lead of the pair \((i,j)\) at regime \(j\)’s own steady
state, the current variables at regime \(i\)’s, and the lag at the
steady state of any regime \(k\). Their expansion is then the
ordinary perturbation at that configuration: pairwise derivatives at
\((\bar z_j,\bar z_i,\bar z_i)\), the coupled first-order solve
without a constant, the standard higher orders. In RISE, 'bm' is
exactly that: a steady-state stage that solves the condition by Newton
from the isolated steady states (with the lag at the current regime’s
anchor), writes the anchors into the steady-state slot, and hands over to
the {'m','isolated'} machinery. The M expansion with self-consistent points is not involved,
there is no Taylor shift, and 'bm' takes no partition.
Two facts locate the scheme. With a common steady state it is {'m','isolated'} to
the last digit (and so on a constant-parameter model, like 'm').
When no lagged variable has a switching steady state, or when the
lagged variables enter only through combinations invariant to the lag
regime (their own model divides the lagged rate by the lagged regime’s
target), the transition point of a pair is the next regime’s steady
state, the depth-zero and depth-one closures coincide, and 'bm'
equals 'm' (checked at orders 1 and 2 on a three-equation NK model
with a switching target). Outside that class the clause “for any regime
\(k\)” of Assumption 2 cannot hold, which the authors state; the
report model_data.state_space{1}.bm carries the residual of that
clause as an \(h\times h\) matrix (assumption2_residual, entry
\((i,k)\) the largest residual of regime \(i\)’s equations with
the lag at regime \(k\)’s anchor), so the distance from their class
is visible. The condition with the lag at the current regime’s anchor may
also have no solution: on the growth model with a switching productivity
level it disappears at a gap of 2 to 3 percent, and the solve then returns
retcode 30 (BM_ANCHOR_NOT_FOUND). solve_derivatives_only is
refused under 'bm', since the derivatives belong at the P-weighted
anchors, which the solve computes; sstate returns the isolated steady
states, the starting point, and get(m,'sstate') after a solve returns
the anchors.
Optimal-policy models
A perturbation type does not depend on where the equations come from. The
first-order conditions that RISE derives from an @optimization_problem
are equations in the variables and the multipliers like any others, and
'm' and 'bm' re-anchor them as they re-anchor any model:
under commitment, under discretion and wherever the commitment parameter
switches, at every order. When a switching
parameter moves the steady state (an inflation target, a loss weight, a
parameter of the constraints), the rest points of the multipliers move
with those of the other variables, and with a common steady state both
types return plain {'m','isolated'}.
Discretion, and every regime in which the commitment parameter is below
one, adds one object: the first-order conditions carry the policy of next
period’s regime as a function of today’s state variables, and its
derivatives (the policy functions written f1942 in the generated
equations). Under {'m','isolated'} and 'bm' the lead of the pair \((i,j)\)
sits at regime \(j\)’s own anchor, and so do these policy functions.
Under 'm' the lead of the pair is regime \(j\)’s policy at
regime \(i\)’s rest point, and the policy functions are taken at that
same point: regime \(j\)’s polynomial is re-expanded there, as every
other function of the variables is evaluated at the pair’s point. At
first order the slopes of a linear policy are the same everywhere and only
its level moves; from order 2 its derivatives move too, by the curvature
of the policy times the gap between the rest points. The replanning loop
of discretion runs around the M expansion with self-consistent points unchanged:
each pass solves the rest configuration and the coefficients given the
previous pass’s policy functions, and the loop stops when they reproduce
themselves.
The first-order solves inside the fixed point use the solver the model is
configured with (rise.engine.dsge_tools.solve.configured_solver), the
one solve uses, whichever it is. A solver with requirements on the
derivatives it is given applies them there as anywhere else, and says so
in its own terms when they are not met: see the limits of each solver in
Optimal policy.
Testing a perturbation: the Euler error against the order
A perturbation is only as good as its convergence: along a simulated
path, the residual of the model’s own equations must fall as the order
of approximation rises. rise.engine.dsge_tools.accuracy.perturbation_report
solves a model at several orders and perturbation types, simulates one
common path of regimes and shocks, measures the Euler residuals with the
paradigm-free accuracy engine, and reports the forward-looking equations
separately from the static ones (static identities gain curvature at
every order under every scheme and would hide a floor):
m = dsge_model('mymodel', 'solve_order', 3);
rep = rise.engine.dsge_tools.accuracy.perturbation_report(m, ...
'types', {{'m','isolated'},'mw','m'}, 'orders', 1:3, 'shock_scales', [1 0.5 0.25]);
Per type and shock scale the forward-looking column is labeled
monotone when the measured error falls with order, flat when it
changes little, and non-monotone when it rises at some order or a
path becomes nonfinite. Shock scaling evaluates the same policies on
common shocks at several scales. These labels describe the measurements;
they do not identify a convergence radius or establish the cause of an
error. exact means residuals are at the rounding level at every
evaluated order, and no forward equation means no equation has a lead.
rep.table holds the numbers, latex_file writes them as a tabular.
The model must be constructed with a derivative order at least equal to
the largest order requested.
1.7.5. Which type to use
Both {'mw', partition} and {'frwz', partition} allow a selection:
the 'mw' partition names Markov chains whose transition probabilities
are perturbed, while the 'frwz' partition names switching parameters
that are perturbed.
The steady state does not switch (volatilities, policy-rule coefficients, persistences): use the default
'm'. Explicit regime-steady-state M,'bm'and'frwz'with an empty partition return the same solution, at the same or a higher cost;'mw'and the naive'frwz'return a different and less accurate one. On a balanced growth path, the growth rates must not switch either.The growth rate switches on a balanced growth path (
solve_bgptrue):'mw'or'm', never{'m','isolated'}, whose solution loses the exact unit root of the path (see When the steady state or the growth rate switches, change the type).The steady state switches and the model is solved at first order for estimation:
'm'. It is the only scheme whose first order has regime-specific slopes, no level error and no constant, and whose rest points are those of the switching economy; on the models of the test suite it is the most accurate first-order scheme whenever the gap matters. Its cost is a dozen first-order solves, four to six times{'m','isolated'}per draw along an estimation random walk (0.10 to 0.19 s warm against 0.02 to 0.04 s on the test models), the warm start being kept automatically across parameter changes; with a common steady state it costs nothing, since it hands over to{'m','isolated'}.The steady state switches and the higher orders matter:
'm', whose default higher orders cost what{'m','isolated'}’s cost (order 2 up to about 200 variables, order 3 up to about 50, order 4 up to about 16 on a 64 GB machine, the limits of the standard engine), or{'frwz', partition}. FRWZ converges faster with the order on the growth model and wins when regimes switch every few periods; the M is ahead on the New Keynesian models and when the real gap is large (a switching capital tax with a 40 percent gap in the capital stock). Run both through the Euler-error test on the model at hand.A regime has no isolated steady state:
{'frwz', partition}, or'm'with its defaultStart'auto', which starts from the ergodic-mean steady state and walks the parameter gap (first order only, so far).Regimes that switch every few periods:
{'frwz', partition}. The rest points of the switching economy are then far from where the economy lives, and the ergodic-mean anchoring is the better one, as on FRWZ’s RBC model.Regimes that last decades and are meant as distinct economies:
'mw', whose first order is the isolated regimes’ and whose higher orders reconnect in that limit only.'bm'reproduces the Barthélemy–Marx scheme for comparison; inside their class (no predetermined variable with a switching steady state) it equals'm', outside it its anchors may not exist.
Plain 'm' is the default: self-consistent expansion points with
curvature higher orders. The joint variant remains an explicit
choice. This interface change does not alter either numerical algorithm.
The measurements below are historical and do not qualify a new model or
establish a universal speed or accuracy ordering.
1.7.6. Historical evidence
The following numerical records for the retained types are historical results, not fresh qualification of the current code.
The verdicts of the Euler-error test on the models of the M project and on FRWZ’s own examples, forward-looking equations, full-size shocks, orders 1 to 3 (1 to 4 on the growth model). The numbers are \(\log_{10}\) of the mean absolute residual; the growth model has a switching productivity level (A: common level, switching persistence; B: 5 percent gap; C: 20 percent gap), the NK model with capital a switching inflation target (B) or capital tax (F), the FRWZ NK model a switching growth rate and Taylor coefficient with a passive regime, the FRWZ RBC model a switching growth rate, persistence and volatility with no isolated steady state in one regime, the BM NK model (Barthélemy and Marx, Section 3) a switching Taylor response and target with the targeted rate set by the P-weighted Fisher relation, with constant and with their endogenous, inflation-dependent probabilities.
The table was recorded before 'curvature' became the default
higher orders of the M: its 'm' column is the 'joint'
variant. Its {'m','isolated'} column was recorded before the
correction of 8 November 2026, which gave the isolated constant the
residual of the expected system and the lead shift: where the regime
steady states differ, its flat entries describe the former constant
(on growth B the corrected variant is monotone, \(-3.9\) and
\(-5.4\) at orders 1 and 2). Order 1 is the same under both. The results recorded for the
default 'curvature' are those of its description above: on growth B
\(-4.8\) to \(-8.0\) over orders 1 to 4; on growth C monotone
through order 4 (\(-5.2\)), where the joint fixed point folds; on
FRWZ’s NK model 0.3 to 0.9 of a decade behind the joint variant at
orders 2 to 4; on FRWZ’s RBC model a series that diverges at order 4.
Model |
|
|
|
|
|
|---|---|---|---|---|---|
growth A |
monotone, −5.5 to −9.7 |
non-monotone |
= |
= |
monotone, −5.5 to −10.1 |
growth B |
flat, −3.0 |
blows up |
monotone, −5.1 to −9.2 |
no anchor |
monotone, −4.9 to −8.1 |
growth C |
flat, −2.6 |
blows up |
monotone, −4.3 to −7.1 |
no anchor |
monotone to order 3, fold at 4 |
NK B |
flat, −2.2 |
non-monotone |
monotone, −3.4 to −5.1 |
flat, −2.9 |
monotone, −3.4 to −5.2 |
NK F |
non-monotone |
blows up |
monotone, −2.7 to −3.6 |
flat, −1.8 |
monotone, −3.0 to −4.7 |
FRWZ NK |
flat, −1.2 |
fails (code 21) |
monotone, −1.2 to −2.0 (naive form non-monotone, −2.2 to −1.7) |
flat, −1.2 |
monotone, −2.5 to −4.6 |
FRWZ RBC |
no steady state |
no steady state |
monotone, −3.2 to −4.5 |
no steady state |
order 1 only, −2.5 ( |
BM NK, constant P |
flat, −2.4 |
non-monotone |
monotone, −4.7 to −6.3 |
flat, −4.5 to −4.7 |
monotone, −4.8 to −6.5 |
BM NK, endogenous P |
flat, −2.3 |
explodes |
fails (code 3) |
monotone, −4.6 to −5.1 |
monotone, −4.8 to −6.1 |
Two readings. Where the steady state switches, 'm' is the most
accurate first-order scheme on every model (NK F, FRWZ NK by more than a
decade; growth B and NK B within a few hundredths of FRWZ), and at
higher orders its 'joint' variant converges wherever it solves, ahead
of FRWZ on the NK models and behind it on the growth model. And on FRWZ’s
own NK model the rest points of the interest rate under the 'joint'
variant converges
with the order to the pair (1.0402, 1.0298), the rest configuration
of the switching economy, while FRWZ’s partitioned form sits at (1.0225,
1.0114), which is why its Euler error stays two and a half decades behind
at order 3. On FRWZ’s RBC model, whose regimes last one to four periods,
the order is reversed: the M reaches the rest points of the switching
economy only through the parameter-gap homotopy, sits 0.6 of a decade
behind FRWZ at first order, and its higher orders fail (the 'joint'
variant does not solve above order 1, the 'curvature' series
diverges at order 4); fast switching is FRWZ’s domain. All first-order solutions that solve are mean-square
stable.
1.7.7. First-order solvers and the types
The recorded solver comparisons in this section are historical evidence.
With the default solver selection, shock-only switching already uses
rise_1 when the common first-order coefficient blocks satisfy the
existing eigenvalue-solver admission check and the problem is eligible
(discretionary policy uses its existing route). An explicit mfi is
respected. A solver failure establishes that the algorithm did not find a
solution in its budget. It does not establish that no solution exists.
The first-order solve of a switching model is a coupled quadratic system,
and the solver option chooses the algorithm: 'mfi' (functional
iteration, the default), 'mafia' (the same map with Anderson
acceleration), 'mnk' and 'mn' (Newton, with or without the
Kronecker form), 'mfi_full', 'mnk_full' and 'mn_full' (the
same on the full state vector) and 'fwz' (the Newton system of
Farmer, Waggoner and Zha). Every perturbation type runs on every solver,
because the types change the matrices of the coupled system and not the
system itself; 'm' uses the chosen solver for its initial and final
first-order solves and its own Newton for the coupled solves inside the
outer iteration. What differs across solvers is which solution they land
on when the system has several, and the test suite’s matrix of types by
solvers (models/dsge/solving and the M project’s battery) shows
three patterns.
On the growth model with a 5 percent productivity gap, only the functional iterations (
'mfi','mfi_full') return the mean-square-stable solution for{'m','isolated'}and'm'; the Newton solvers and'mafia'converge to a solution that fails the stability test (return code 25). Functional iteration has the contraction that selects the stable solution; Newton converges to the root nearest its start.On the NK model with capital, every solver except
'fwz'returns the same solution for every type (to \(10^{-7}\), the Newton solvers’ tolerance, and \(10^{-10}\) under'm', which tightens the inner tolerance).On the FRWZ NK model whose second regime is passive, the coupled system has more than one mean-square-stable solution under the transition-point types:
'fwz'returns a solution different from the other solvers’ for'm'(and the same one for{'m','isolated'}), and the plain Newton solvers'mn'and'mn_full'do not converge for'm'(return code 29, or the code of the failed evaluation of the outer map, as described above). Both solutions pass the stability test. Which one is the relevant equilibrium is a question the solver cannot settle; theContinuationoption of joint higher-order M and a warm start from a known solution are the tools for keeping a solver on one branch.
The practical rule: keep 'mfi' unless it is slow, check the
return code, and when a model may have several stable solutions,
compare two solvers before trusting one.
Construction and solve memory
Let \(h\) be the number of regimes, \(n\) the system dimension after
the solver’s reductions, and \(n_{pb}\) the number of predetermined
columns. In the dense Kronecker Newton route, newton_iteration_h
allocates a matrix of side \(h n n_{pb}\). Its double-precision entries
alone occupy \(8(h n n_{pb})^2\) bytes. During construction, each
Kronecker block has side \(n n_{pb}\) and requires
\(8(n n_{pb})^2\) bytes for its entries, in addition to the assembled
matrix, coefficient blocks, derivatives and current policy arrays.
Solving the assembled system also requires factorization storage and workspace. The construction bounds therefore describe specified arrays and give no measured peak for a complete solve. Model compilation and derivative construction have their own storage requirements before this linear solve begins. These dimensions describe the coupled system.