1.11. Exact score of switching VARs
A reduced-form VAR whose variables are all observed, with complete data, is
estimated on the direct route (see Direct likelihood of fully observed models): its
likelihood is the density of the residuals the data imply, with the
Hamilton recursion over the regimes. On that route the posterior kernel of
RISE (Maih [2015]) also returns its exact gradient, the score: the
derivatives of the log posterior with respect to the estimated parameters.
fmincon and fminunc use it in the mode search, instead of finite
differences of the objective, when the whole posterior qualifies.
There is no option to set. The score is used by default where it exists, and the optimizers’ own gradient flags turn it off.
The derivatives are those of the computed log posterior, not finite differences of nearby values; floating-point arithmetic and the tolerances of the search still apply. The score does not supply a Hessian, a posterior covariance or a marginal data density: those keep their usual curvature requirements (see Resuming the finite-difference Hessian).
1.11.1. What is differentiated
The score covers the parameters of the reduced form and of its regimes:
the lag coefficients, the constants and the loadings of deterministic variables, with the steady state of each regime that depends on them;
the variances and covariances of the residuals;
the transition parameters: constant transition probabilities of a latent chain, and the parameters of transition probabilities that depend on the data (indicators of a threshold, logistic transitions), through the model’s own transition routines.
The likelihood is not computed again. The score differentiates the
residuals, the Cholesky factors of the covariances, the transition
matrices and the regime probabilities that the likelihood computes, with
RISE’s automatic differentiation (rise.engine.sym.adolm). It follows
the same initial distribution of the regimes (ergodic by default,
kf_ergodic, kf_user_init) and the same presample
(kf_presample). The prior is differentiated through the evaluators of
its encoded densities, in the free coordinates under affine restrictions.
Under estim_mle the score is that of the likelihood.
Where regimes coincide, the likelihood does not depend on the transition probabilities, and neither does the score: its entries for them are zero. At the cutoff of a threshold indicator, or at a kink of a prior density, the log posterior has no two-sided derivative: with a threshold transition, the score is the derivative within the region where no observation crosses the cutoff.
1.11.2. When the score is used
The search receives the score when all of the following hold:
the model is a reduced-form VAR (
rfvar_model), constant or with Markov chains, any number of them;its likelihood takes the direct route: every variable observed, no missing observations,
estim_force_filterfalse;its posterior is the native one, with
estim_eval_liktrue: priors on individual parameters (estim_priors), linear restrictions allowed;the optimizer is
fmincon(the default) orfminunc, withoutestim_blocks, and its gradient flag is not turned off.
The posterior keeps finite differences, with a reason, in these cases:
Case |
Reason given |
|---|---|
structural and proxy VARs, the filter route |
|
derived parameter bindings |
|
a VAR prior template ( |
|
a prior density the score cannot differentiate at the start |
warning |
rise.engine.dsge_tools.estim.direct_score_available(md) returns the
verdict and the reason for the model data md of pull_objective.
1.11.3. Turning it off, asking for it
estim_optimizer = {'fmincon', 'SpecifyObjectiveGradient', false}(or'GradObj', 'off', and the same forfminunc) gives the optimizer finite differences. Neither the likelihood nor the prior changes.SpecifyObjectiveGradient = true(or'GradObj', 'on') where the score exists is the default search. Where it does not, it is refused:rise:estimation:objectiveDerivativesUnavailable.fminuncsearches the bounded parameters in unbounded coordinates (see Posterior maximization); it receives the score through the chain rule of that map, and itsCheckGradientsoption accepts it.Under linear restrictions the search receives the score of the free coordinates. A switching search that starts from the mode of the constant-parameter version receives, in that first stage, the score of the tied coordinates.
At a point the model rejects, the objective is the graded value of Posterior maximization, which has no exact derivative. The search receives central differences of it there.
1.11.4. Reading the score
The eighth output of the posterior kernel is the score:
[objective, lb, ub, ~, ~, ~, md] = pull_objective(m);
[log_post, log_lik, log_prior, ~, retcode, ~, ~, score] = ...
rise.engine.dsge_tools.estim.log_posterior_kernel(md, x);
xholds the estimated parameters in their natural units, in the order ofmd.estim_priors_data.indiv_wise(the order of the estimation).score(k)is the derivative of the log posterior with respect tox(k), in nats (natural log units) per unit of that parameter: per squared percent for the variance of a series in percent, per unit of probability for a transition probability. It is the gradient of-objective.Where the posterior has no score, the call stops with
rise:score:unsupportedand the reason. The other outputs, and calls with fewer outputs, are unchanged.
1.11.5. Cost
A scored evaluation also computes the derivatives, while the search needs
fewer evaluations. The entries of the transition matrix are evaluated once
on the data of all periods, so the derivative of an endogenous chain costs
about as much as that of a latent one. On the bivariate VARs of 32 periods
of the unit tests (RISE-unit-tests/models/var/reduced_form/direct_score_fixture.m,
fmincon, one MATLAB thread, medians of three runs, 23 November 2026):
Chain |
Scored evaluation / one without the score |
Search without the score |
Search with the score |
|---|---|---|---|
latent |
4.0 |
1345 evaluations, 2.0 s |
127 evaluations, 0.6 s |
threshold indicator |
3.4 |
490 evaluations, 1.0 s |
112 evaluations, 0.6 s |
logistic transition |
2.7 |
522 evaluations, 2.2 s |
104 evaluations, 1.0 s |
Both searches end at the same mode. SpecifyObjectiveGradient = false
gives the search without the score.
1.11.6. Example
The tutorial Estimation/var_direct_score/howto.m runs the score on US
inflation and the federal funds rate (Smets and Wouters (2007) data in
RISE’s examples/VariousModels/SmetsWouters, both in percent per
quarter), 1966Q1-2004Q4, with a VAR(1) whose residual covariance switches
between two regimes of a latent chain (14 parameters). In the run behind
this page:
at the start of the search, the score and RISE’s central differences of the objective (
rise.engine.numerics.numdiff.jacobian) agree to a relative difference of \(5.8\times10^{-8}\);the search with the score takes 303 evaluations, the search without it 941. Both end at a log posterior of -4.48782077, with modes that differ by at most \(4.0\times10^{-8}\); the largest entry of the score at the mode is \(6.2\times10^{-6}\);
with everything switching and a logistic transition in lagged inflation whose slope and location are estimated (20 parameters), the score and the central differences agree to \(7.1\times10^{-8}\).
The tutorial also prints the time of one evaluation with and without the score for both models, and the reason given where the score is not available.