2.11. Stochastic simulations
Once a model is solved, RISE exposes a small set of stochastic-analysis
routines on the model object. All of them share the same convention:
the return type is a struct of ts (RISE time-series) objects keyed
by endogenous-variable name, with multiple pages when there are
multiple parameterizations or solution branches.
2.11.1. Artificial data
simulate returns simulated time series from the solved model:
sim = simulate(m, 'simul_periods', 200);
plot(sim.PAI, sim.Y)
The most relevant options:
Option |
Effect |
|---|---|
|
Number of periods to simulate (default |
|
Burn-in periods discarded from the head of the returned series
(default |
|
Seed forwarded to MATLAB’s RNG before drawing. |
|
When |
|
Initial conditions and / or a conditioning path. Accepts a
struct of |
The output struct is suitable for fan charts, regime-conditioning
diagnostics, and as data for an estimation step. Pages of the returned
ts correspond to the model’s parameterizations.
2.11.2. Pruned simulations
RISE implements 5-th order approximation of the perturbation solution
of regime-switching DSGE models. At order \(\geq 2\) the
straight-perturbation simulation is not guaranteed to be bounded: an
unlucky shock realisation can send the state off to inf. The
pruning algorithm of [Andreasen et al., 2013], generalised to
regime-switching models, removes the unbounded higher-order terms at
simulation time without changing the policy function. Pruning is on by
default at order \(\geq 2\) and can be controlled via the standard
solve / simulate options.
2.11.3. Theoretical and Simulated moments
For a linear solved model the unconditional first and second moments
are available in closed form via the Lyapunov equation. RISE exposes
them through theoretical_autocovariances (and the
theoretical_autocorrelations convenience wrapper):
[Acov, info, retcode] = theoretical_autocovariances(m, 10);
Acorr = theoretical_autocorrelations(m, 'autocorr_ar', 10);
For higher-order or regime-switching models, where closed-form moments
are not available, the standard practice is to simulate a long path
with simulate and compute sample moments from the returned
ts (cov, corrcoef, var overloaded on ts). The two
should agree at order 1 up to Monte Carlo error.
2.11.4. Variance decomposition
variance_decomposition returns the share of forecast-error variance
attributable to each structural shock, at each horizon, for each
endogenous variable:
vd = variance_decomposition(m);
The output is a struct of ts (one entry per endogenous variable)
where each ts carries one column per shock and one row per horizon
(conditional) or a single row for the unconditional decomposition
(unconditional). It is available for the linear (order-1) solution
of constant-parameter and regime-switching models.
2.11.5. Impulse responses
irf returns impulse responses on the solved model:
myirfs = irf(m);
The output is a struct of ts keyed by shock name; each entry is
itself a struct of ts keyed by endogenous variable. quick_irfs
(see Plotting tools) lays the result out in a publication
grid.
Simple Impulse Responses
“Simple” IRFs trace the model’s response to a one-time, one-shock deviation from a fixed initial state (typically the unconditional mean or the deterministic steady state). For a linear model the simple IRF is the same regardless of initial state and shock sign, so it is the natural default. The main controls are:
irf_periods(default40): horizon.irf_shock_signandirf_shock_scale: sign and size of the impulse. Use-1for a contractionary shock and2to feed a two-standard-deviation impulse instead of the default one.solve_shock_horizon: anticipation horizon. With a strictly positive value the IRF traces the response to a shock that is announced the corresponding number of periods ahead (the “anticipation” pattern); with0the shock is unanticipated.Delayed reaction of the response is obtained by appending zero realisations to the shock path through a simulation plan. The same plan, with
simplan.anticipate(true)vsanticipate(false), produces the anticipated and unanticipated variants.
Generalized Impulse Responses
For nonlinear or regime-switching models, the simple IRF depends on
the initial state and on whether the shock is positive or negative,
small or large. The generalized impulse response (GIRF), defined as
the difference between the conditional expectation of the path with a
given shock and without, averaged over the model’s stationary
distribution of states, is the right object to look at. Switch irf
into GIRF mode via:
girf = irf(m, 'irf_type', 'girf', 'irf_draws', 1000);
irf_draws controls the number of state-and-shock realisations
averaged. The cost scales linearly with irf_draws; values in the
low thousands are usually enough for smooth output.