33. Time-varying transition probabilities
By default, a Markov chain’s transition probabilities are constant
parameters – declared as chain_tp_<i>_<j> and bound to a
numeric value. RISE also supports endogenous transition
probabilities, where each off-diagonal probability is a function
of endogenous variables, parameters, or an observed exogenous
variable (a deterministic regressor carried in the data).
The mechanism is the @transition_functions block in the model
file. This chapter is the entry-point reference; the block grammar
itself is documented in Model file language under
Markov chains.
33.1. When to use TVTP
Constant transition probabilities are the right model when regime switches are driven by forces outside the model’s variables – a policymaker’s preference shift, a structural break, an exogenous volatility regime.
Time-varying transition probabilities are the right model when the regime switches should depend on the state of the economy. The classical examples:
Endogenous ZLB switching – the probability of moving into the bound regime depends on the natural rate.
State-contingent reform probability – the probability of a policy regime change depends on debt-to-GDP.
Volatility regimes triggered by recession – the probability of entering the high-volatility regime depends on the output gap.
The cost is that the regime probabilities are now part of the
solution and must be evaluated at each iteration of the solver.
The TVTP-aware solvers (mn, mfi, mafia) handle this
transparently.
33.2. The @transition_functions block
Each off-diagonal probability you want to make endogenous gets one equation in the block. The right-hand side is whatever expression you write – a parameter, a linear function of a state, a logistic, a quantile of a continuous-state distribution, etc. RISE evaluates the expression as-is. The shape of the function – including whether it is bounded – is entirely your choice:
@parameters theta_zlb "sensitivity to B"
@transition_functions
"Probability normal -> bound"
zlb_tp_1_2 = 1 / (1 + exp(-theta_zlb * (B - B_star)));
"Probability bound -> normal"
zlb_tp_2_1 = 1 / (1 + exp( theta_zlb * (B - B_star)));
The right-hand side may reference any endogenous variable,
parameter, or steady-state value (var{stst}). The example
above uses a logistic for [0, 1] containment, but any
expression is accepted; the user decides what the function does at
the edges of the state space.
A variable declared in logs (@endogenous(log)) means its level
here, as it does in @model:
if B is a log variable, B^theta_zlb is the level of B
raised to theta_zlb, and the probability the solution uses is
the one the simulation reports in the series zlb_tp_1_2. (Before
2026-10-09 the modern toolbox read a log variable in this block as
its log; a model written for that, with exp(theta_zlb*B) standing
for B^theta_zlb, now needs the level form.)
The name pattern is the same as for constant transition
parameters: <chain>_tp_<i>_<j>. The parser distinguishes them
from constant transition parameters by the presence of a defining
equation in @transition_functions. The diagonal probabilities
are still inferred – you only write the off-diagonals.
33.3. Driving the transition with an observed exogenous variable
A transition function may depend on an observed exogenous variable – a deterministic regressor that you supply in the data rather than a variable the model solves for. This is common in reduced-form work: the probability of switching regimes is driven by an external indicator (a financial-conditions index, a foreign interest rate, a commodity price) that enters the model only through the transition.
In a model file, declare the driver on both the @exogenous and
@observables lines – so RISE knows it is supplied as data –
and reference it in @transition_functions:
@exogenous EPS Z
@observables Y Z
@transition_functions
"Probability calm -> turbulent"
vol_tp_1_2 = 1 / (1 + exp(-(g * Z - c)));
"Probability turbulent -> calm"
vol_tp_2_1 = 1 / (1 + exp( (g * Z - c)));
For the VAR families the same idea is expressed through the
factory: list the driver under deterministic_vars and write the
probabilities in markov_chains.endogenous_probabilities:
markov_chains = struct( ...
'name', 'mstvt', 'number_of_states', 2, ...
'controlled_parameters', {{'c'}}, ...
'endogenous_probabilities', ...
{{'mstvt_tp_1_2 = logistic(IDX_LAG, g12, c12)', ...
'mstvt_tp_2_1 = logistic(IDX_LAG, g21, c21)'}}, ...
'probability_parameters', {{'g12','c12','g21','c21'}});
m = rfvar_model('Y', 'lag_length', 4, 'constant_term', true, ...
'deterministic_vars', {'IDX_LAG'}, ...
'markov_chains', markov_chains);
33.3.1. How it is evaluated
The observed exogenous is exactly that – data. At each date RISE evaluates the transition matrix on the full vector of variables, endogenous and exogenous together, taking the exogenous at its observed value. No auxiliary variable is created, and the exogenous driver never enters the covariance of the structural shocks: it is a conditioning regressor, not an innovation.
Two paths follow automatically from how much of the model is observed:
Fully observed (the usual reduced-form case): no continuous-state filtering is required, so RISE uses the closed-form likelihood. The regimes are still latent, so the Hamilton filter and smoother run and return the
smoothed_regime_probabilitiespath shaped by the observed driver.Latent states present (for example a DSGE with unobserved states): the regime-switching Kalman filter runs, and the observed driver is fed into the transition matrix at each date alongside the filtered state.
Occasionally-binding constraints (a
max/minin the model): the constrained filter forecasts each regime’s path with the constraints enforced, and those forecasts evaluate the transition matrix with the same observed driver. A driver of regime switches and a lower bound on the policy rate can sit in one model and be filtered together;simulateandirfevaluate the probabilities with the driver’s values at each step too.
The driver has one date everywhere. Its value at date t drives the
move out of t, into t+1: in the solution, which evaluates the
transition functions on the variables of date t, in both likelihood
routes and in simulate and irf. An observed exogenous variable
that also enters an equation enters the equation of its own date.
Data simulated with a driver and filtered back therefore meet the
driver on the same dates; the unit test testExogenousDriverDating
checks it.
Until 2026-10-13 two places used another date. simulate and
irf used the driver’s value in the period entered (since
2026-10-12). The default filter, imm, gave the prediction of t+1
the value at t of an observed exogenous in an equation. The other
filters and the closed-form likelihood used the value at t+1.
The driver must be observed. A transition that depends on an unobserved structural shock cannot be evaluated this way – there is no data value to supply – and RISE stops with a clear error rather than silently substituting a zero. If you need a latent driver, model it as an endogenous state and reference that state in the transition function instead.
33.3.2. Where the regime probabilities start
The regime probabilities follow one rule on both likelihood routes: the filter, and the closed-form likelihood of a fully observed model.
The start uses no data. It is the ergodic distribution of the transition matrix at the steady state, where the observed exogenous variables are zero (
kf_ergodic = true, the default). Withkf_ergodic = falseit is equal probabilities. A distribution given as the third entry ofkf_user_initis used as given.The start sits at the date before the first observation. The move at the steady state takes it into the first period. The ergodic distribution of that matrix does not move; equal probabilities and a given distribution do.
The move from date t to date t+1 uses the information of date t. The driver’s value at t drives the move out of t. The endogenous variables enter at their updated values in the filter, and at their observed values in the closed-form likelihood.
The first move into the sample uses nothing from the period it explains. The filter starts at the steady state, before the first period, and evaluates its first move there. The closed-form likelihood needs the first observations to read the state (one period when the state is the first lag of the observed variables, more with longer lags). Its start, moved once at the steady state, is the distribution of the regime at the last of them, and its first move into the likelihood is evaluated at that observation.
The filter’s start is the steady state. When the data begin far from
it, the first periods of the likelihood carry that distance. The
remedy is kf_presample: the filter runs through the presample, so
its states and regime probabilities reflect those data, and the
likelihood counts only the periods after it:
[f, LL] = filter(m, kf_presample = 4);
The same option works in estimate.
A missing value of an observed driver leaves a move undefined. Both
routes stop with the error rise:filter:missingTransitionDriver.
Supply the value or shorten the sample (estim_start_date,
estim_end_date).
Checking the two routes against each other. estim_force_filter =
true runs the filter on a fully observed model. The two routes give
the same numbers when the filter conditions on the same information as
the closed-form likelihood. Take a model whose state is the first lag
of the observed variables and whose steady state is the same in every
regime. With the default initialization and kf_presample = 1, the
log-likelihood and the contribution of every period agree to rounding,
whatever the start: the ergodic one, equal probabilities, or one given
in kf_user_init. This holds with constant probabilities, with an
observed driver and with an endogenous driver. The unit test
Test_likelihood_routes_in_sync checks these cases.
Before 2026-10-13 the filter’s first move used the driver’s first
observation, which belongs to the first period. The closed-form
likelihood started from the ergodic distribution of the matrix
evaluated on the data of its first likelihood period, and ignored
kf_ergodic. The closed-form log-likelihood of a model with a driver
changes, and so does the filter’s when an observed driver’s first value
is not zero. Equal probabilities used to sit one move later in the
closed-form likelihood than in the filter, and the two routes
differed by about 0.06 in the log-likelihood of the test models.
Later on 2026-10-13 the closed-form likelihood placed them where the
filter does, and began to read a starting distribution given in
kf_user_init.
33.4. Mixing constant and endogenous chains
A model may freely mix:
Constant-TP chains – declared via
chain_tp_i_jordinary parameters, with no entries in@transition_functions.TVTP chains – with one equation per off-diagonal probability in
@transition_functions.
The joint composite transition matrix is built from the per-chain matrices at every state, so constant-TP chains contribute their constant factor while TVTP chains contribute their state-evaluated factor.
33.5. Estimation under TVTP
When the parameters appearing inside the transition functions are estimated, the prior is declared as usual:
priors.theta_zlb = {2.00, 0.50, 5.00, 'gamma(0.9)', 1e-6, 20};
priors.B_star = {0.0, -1.0, 1.0, 'normal(0.9)'};
and passed through estim_priors. The estimator runs the
regime-conditional Kalman filter and uses the state-dependent
transition matrix at each date. See
Estimation.
33.6. Transition probabilities in the output
The entries of @transition_functions are evaluated on the paths
the model produces, as the entries of an @epilogue are (see
Model file language, under Epilogue).
The outputs of simulate and forecast, of
perfect_foresight, counterfactual and
brute_force_simulate, and the variables filter returns have a
series under each entry’s name: zlb_tp_1_2 at date t is the
function evaluated on the path at t.
The output of simulate holds a second series for each transition
of each chain, zlb_1_2 (and regime_<i>_<j> for the regimes):
at date t, the probability the simulation used for the move into t.
It is the transition function evaluated on the path at t-1:
zlb_1_2 at t equals zlb_tp_1_2 at t-1.
An @epilogue entry may use a transition probability by name, for
plotting and diagnostics:
@epilogue
"Expected stay at the bound, at the current probability of leaving it"
bound_stay = 1/zlb_tp_2_1;
The epilogue does not affect the solution, so it is the right place for derived quantities you want to look at later but not pin down.
33.7. Where to look next
Model file language – the
@transition_functionsblock grammar and the@epilogueblock grammar.Solving – the solvers that handle TVTPs cleanly (
mnandmnkNewton solvers, the defaultmfi, andmafia, which adds safeguarded Anderson acceleration to themfimap). Check the return code with every solver.Optimal policy – when the
commitmentchain’s transitions are themselves endogenous (stochastic replanning).Storytelling – the
smoothed_regime_probabilitiesoutput offiltershows the TVTP-implied probability path the data actually realized.The tutorial
Estimation/tvtp_driver_zlb– an observed indicator drives a volatility regime in a model with a zero lower bound: filtering for several strengths of the driver.