1.7. VAR threshold profiles
A threshold VAR with a calibrated cutoff has known regimes, so its posterior
mode and its marginal data density given the cutoff come in closed form (see
Switching VARs with known regimes). threshold_profile scores many
candidate values of the cutoff in one call:
out = threshold_profile(m, 'thr', grid, 'data', db, 'estim_var_prior', prior, ...);
For each candidate it returns the mode, the log posterior at the mode and the log marginal data density given the cutoff, \(\log p(Y \mid \mathit{thr})\), without estimating the model once per candidate. The grid and the choice among the candidates are the user’s.
1.7.1. The call
threshold_profile(obj, parameter_name, grid, varargin) takes
obj: anrfvar_modelor aprfvar_modelwith more than one regime;parameter_name: a parameter of the transition probabilities that is not estimated, such as the cutoffthrofhard_threshold(pinfobs,thr,0);grid: its candidate values, finite, in any order;varargin: the arguments ofestimate('data','estim_var_prior', the estimation window,solve_check_stability, …).
The problem is built once, as estimate would build it. A candidate
costs one evaluation of the model, which gives its regime path, and nothing
else is rebuilt. Candidates with the same path are one partition of the
sample: its mode and its marginal data density are computed once and
reported for each of its candidates. Reordering the grid reorders the rows
of the results (and renumbers the partitions).
1.7.2. The output
With \(J\) candidates, \(h\) regimes, \(n\) variables and
\(K\) regressors, out has the fields
Field |
Content |
|---|---|
|
as given ( |
|
\(J \times 1\) cell: |
|
\(J \times 1\): the partition of each candidate, numbered in the order of first appearance (0 without a known path) |
|
the number of distinct partitions, their regime paths over the likelihood periods (one column each), and the first period that is scored |
|
\(J \times h\): the number of scored periods in each regime |
|
\(J \times 1\): the log posterior kernel at the mode, the
|
|
\(J \times 1\) and \(J \times 1\) cell: the closed-form log
marginal data density given the path, in nats, and |
|
\(n \times K \times h \times J\) and \(n \times n \times h \times J\): the mode. Rows are the equations, columns the constant, the deterministic variables and the lags, the variables in alphabetical order |
|
\(J \times 1\) cell: the mode as a struct of parameter values,
as |
|
the passes of the alternation and the scaled score at the mode |
1.7.3. Statuses and errors
A candidate without a result has NaN in its numerical fields and its
reason in status; the other candidates are unaffected. For example:
the conditional of covariance (regimes 2) is not an exact normal or inverse-Wishart: regime 2 is empty and the prior has no proper density on the covariance (minnesota);the kernel rejects a conditional mode (return code 25): undersolve_check_stability = true, a pass of the alternation reaches a VAR that is not stable. With the model of the example below and RISE’s defaults, the cutoffs 0.2 and 0.25, which leave 2 quarters in regime 1, get this status; without the stability check they have their values.
A candidate can have a mode and no marginal data density: its
log_marginal_data_density is NaN with the reason, as listed in
Switching VARs with known regimes.
These are errors:
Identifier |
When |
|---|---|
|
the parameter is estimated: the regimes of a candidate are known only when its value is given |
|
the model has no such parameter |
|
the model has one regime |
|
the regimes are not known from the data at a candidate tried before
the problem is built: a latent chain, or an uncertain path, for
example with |
|
no candidate has a known path with closed-form conditionals |
|
the model is not a reduced-form VAR, or is an array of models |
An empty grid, or one with a NaN or an infinite value, fails the argument validation.
1.7.4. Reading the profile
Every candidate scores the same periods: only the partition changes. The values of different candidates are therefore comparable.
Each value conditions on its cutoff. With prior probabilities \(\pi_{j}\) on the grid, the posterior probability of candidate \(j\) is proportional to \(\pi_{j}\, p(Y \mid \mathit{thr}_{j})\), and \(\log \sum_{j} \pi_{j}\, p(Y \mid \mathit{thr}_{j})\) is the log marginal data density of the threshold VAR whose cutoff has that prior. Candidates of one partition have equal values, so a uniform prior on the grid weighs a partition by its number of candidates.
A period whose threshold variable, as the chain reads it (here the inflation of the quarter before), equals the cutoff is in regime 1. A grid made of the distinct values of that variable over the scored periods therefore visits once each partition whose regime 1 is not empty.
Nothing is trimmed: an empty regime under a proper prior keeps the mode of its prior and adds 0 to the marginal data density, so a cutoff beyond the data gives the constant-parameter VAR’s value. Keeping a share of the periods in each regime is the user’s choice, through the grid.
Under the stability check or finite parameter bounds each value carries the label of Closed-form marginal data density of VARs. The values, the mode and
log_postdo not change, except at a candidate whose alternation reaches a VAR that is not stable: it gets a status (above).To take the candidate with the largest exact value, leave out the statuses, the NaNs and the labels;
maxkeeps the first of tied candidates:valid = find(cellfun(@isempty, out.status) ... & cellfun(@isempty, out.log_marginal_data_density_reason) ... & isfinite(out.log_marginal_data_density)); [~, k] = max(out.log_marginal_data_density(valid)); best = valid(k); mb = set(m, 'parameters', struct('thr', out.grid(best)));
1.7.5. An example
The threshold VAR(1) of Switching VARs with known regimes (quarterly
inflation and the federal funds rate in percent per quarter, 1966Q1-2004Q4,
niw, regime 2 when the inflation of the previous quarter is above
thr), profiled over 13 cutoffs with solve_check_stability = false
and estim_prior_trunc = 0:
out = threshold_profile(m, 'thr', (0.4:0.1:1.6).', 'data', db, ...
'estim_start_date', date2serial('1966Q1'), ...
'estim_end_date', date2serial('2004Q4'), ...
'estim_var_prior', prior, ...
'solve_check_stability', false, 'estim_prior_trunc', 0);
|
regime 1 |
regime 2 |
log MDD |
|
|---|---|---|---|---|
0.4 |
18 |
137 |
-60.8299 |
-1.9717 |
0.5 |
33 |
122 |
-54.6746 |
2.2380 |
0.6 |
48 |
107 |
-42.1703 |
14.2961 |
0.7 |
61 |
94 |
-39.2101 |
15.8903 |
0.8 |
76 |
79 |
-47.9022 |
4.8804 |
0.9 |
84 |
71 |
-48.1664 |
3.8128 |
1.0 |
90 |
65 |
-46.0661 |
5.4148 |
1.1 |
99 |
56 |
-44.7006 |
5.7527 |
1.2 |
107 |
48 |
-43.1164 |
6.3940 |
1.3 |
113 |
42 |
-54.4369 |
-5.8291 |
1.4 |
118 |
37 |
-54.7302 |
-6.7736 |
1.5 |
125 |
30 |
-50.6026 |
-3.7926 |
1.6 |
128 |
27 |
-58.2736 |
-12.0560 |
The 155 scored quarters (1966Q2-2004Q4) give 13 partitions. At the best
cutoff of the grid, 0.7, estimate returns the same log marginal data
density (-39.210139), the same log_post (15.890298) and the same mode.
With a uniform prior on the grid, 0.7 has posterior probability 0.928, 0.6
0.048 and 1.2 0.019; the threshold VAR with that prior has a log marginal
data density of -41.7005, against -71.3346 for the constant-parameter VAR
on the same quarters. These probabilities belong to this grid: the cutoff
0.7061, between two of its points, scores higher still (below). In the run
behind this page the 13 candidates took 7.0 seconds (0.54 seconds each, the
build included), and one estimate at one cutoff, without its Hessian,
0.78 seconds; every candidate of this grid has a partition of its own, and
so a solve of its own.
At the default settings, four more candidates give
|
regime 1 |
regime 2 |
partition |
log MDD |
|---|---|---|---|---|
0.7 |
61 |
94 |
1 |
-39.2101 |
0.7061 (a value of lagged inflation) |
62 |
93 |
2 |
-37.8898 |
0.7065 (between that value and the next) |
62 |
93 |
2 |
-37.8898 |
4.6608 (above the data) |
155 |
0 |
3 |
-71.3346 |
each with the reason integral of the untruncated kernel; the estimated
kernel is truncated by the stability check and finite parameter bounds.
The quarter whose lagged inflation is 0.7061 moves to regime 1 when the
cutoff reaches it, the next two candidates share one partition, and the
empty regime gives back the constant VAR. Under minnesota the cutoff
above the data has the status the conditional of covariance (regimes 2) is
not an exact normal or inverse-Wishart, and thr = 1 has its mode
(log_post -4.0740) and no marginal data density.
The tutorial Estimation/var_threshold_profile/howto.m runs this example.
1.7.6. The routine
threshold_profile builds the model data with pull_objective and
calls rise.engine.var.vartools.bvar_known_regime_profile(model_data,
parameter_name, grid), which takes the model data directly.