*! version 1.0.1 21aug2026

Title

gvar bdic -- deviance information criterion for the sampled model

Syntax

gvar bdic [, nosummary]

gvar bayes and gvar solve must have run
first.

Description

gvar bdic evaluates the global likelihood at every retained draw and
reports

Dbar = -2 mean_s logL(theta_s) posterior mean deviance

pD = Dbar - D(theta_bar) effective parameters

DIC = Dbar + pD

The likelihood is the reduced form itself,
Y_t = d0 + d1 t + sum_l F_l Y_ + eta_t, with
Sigma = G0^-1 S G0^-1' and S block diagonal in the country
covariances.

Options

nosummary suppresses the report. Everything still appears in r(),
which is the usual way to compare two models:

. gvar bdic, nosummary
. scalar dic_a = r(dic)

There are no other options. DIC has no tuning parameters -- it is a function of
the chain that is already in memory.

Remarks

Only differences mean anything. The level carries the arbitrary constant of
the Gaussian density, so a DIC of -86013 is not "good" or "bad" on its own.
Compare models fitted to the same data, the same lag orders and the same
variables. A DIC computed on a different sample is not comparable, and nothing
in the number will tell you that -- gvar bdic cannot check it either.

Do not read pD as a measure of prior tightness, in either direction. It is
concentration times curvature: tightening the prior concentrates the posterior,
which lowers pD, and simultaneously pushes it into a steeper region of the
likelihood, which raises pD. The two oppose, so nothing guarantees which wins.
Measured on the 26-unit demo with prmean(0), 150 draws, seed 20260811,
under the earlier gendog(poil=usa) specification: K = 136 with a lag
order of 2 and 37128 parameters. The shipped example now uses
dominant(poil pmat pmetal), which raises the lag order to 3 and the
parameter count to 55624, so the levels below no longer match what the
command prints -- at lambda1 = 0.1 it now reports Dbar near -84567 rather
than -86444. Only the shape of the relationship carries over.

lambda1 Dbar pD pD/count

0.5 -89403.7 1305.2 0.035

0.2 -88301.6 698.5 0.019

0.1 -86443.5 428.8 0.012 (the default)

0.05 -80996.2 -73.9 -0.002

0.01 -42151.1 -926.0 -0.025

On this demo pD falls steadily as the prior tightens and goes negative
below about lambda1 = 0.1, while Dbar rises. That is one dataset and
five points, not a theorem -- the useful conclusion is the negative one: a
smaller pD does not mean a tighter prior, or a looser one.

When to distrust it. A negative pD is the clearest signal, and on the table
above it appears at lambda1(0.05) and tighter -- so this is a warning that
fires on the shipped demo, not a theoretical caveat. pD is the effective
number of parameters; a negative one is impossible as a count and means the
normal approximation behind DIC has broken down. At lambda1 = 0.01 the
coefficients are pinned near zero while the data sit around 4.8, so the model is
badly misspecified rather than parsimonious. gvar bdic flags a negative pD,
and separately flags pD above half the actual count, which is the same failure
from the other side.

These figures were re-measured. An earlier version of this table was
computed before Sigma was corrected from inv(L) D inv(L)' to
L D L'. Sigma enters the deviance twice, through log|Sigma| and
through the quadratic form, so the old table was out by up to 147% on
Dbar -- and it was U-shaped, which is why this section used to assert a
minimum near lambda1 = 0.2. The mechanism argument survived the correction;
the shape did not. See gvar methods.

On this data DIC prefers the loosest prior, falling monotonically from
+122130 at lambda1 = 0.01 to -73998 at 0.5. That is
substantive: the data want flexibility, and the heavily shrunk models are
misspecified. It is also a reminder that DIC ranks fit adjusted for
complexity, not economic plausibility.

theta_bar follows the source, oddly. BGVAR.R:1053-1055 averages
A, S and G0^-1 separately across draws and then combines them
as G0^-1_mean S_mean G0^-1_mean'. That is not the mean of Sigma --
E[G0^-1 S G0^-1'] is not E[G0^-1] E[S] E[G0^-1]' -- and it is not the
model gvar solve holds either, since stacking is nonlinear in
the country coefficients. It is reproduced because DIC gets compared across
papers and a different theta_bar gives a different pD.

A draw whose covariance is singular is skipped, not zeroed. A likelihood
computed from a singular covariance is not a likelihood. Skipped draws are
counted and reported; if the count is large, check
gvar bconv and the eigenvalue trim before reading the DIC.

Not the same as what gvar estimate reports. That gives a log likelihood,
AIC and SBC per country model from reduced-rank ML. This is one number for
the whole stacked system, and the two cannot be compared.

On reading the source. utils.R:1446 has a .globalLik call
commented out inside .gvar.stacking.wrapper, which looks like the dead
joint sampler at BVAR_linear.cpp:413. It is not the same situation:
BGVAR.R:974 and 1051 call a live exported globalLik() and
BGVAR.R:1012 documents dic(). The commented line is only a storage
shortcut. Commented code near a live call path needs the call path checked
before the comment is trusted.

Examples

Fit, check the chains, solve, then score:

. gvar bayes, prior(mn) prmean(0) noeigentrim draws(2000) burnin(2000) seed(20260811)

. gvar bconv

. gvar solve

. gvar bdic

Comparing two priors on the same data, which is the only comparison DIC
supports:

. gvar bayes, prior(mn) prmean(0) noeigentrim draws(2000) burnin(2000) seed(1)

. gvar solve, nosummary

. gvar bdic, nosummary

. scalar dic_mn = r(dic)

. gvar bayes, prior(ssvs) prmean(0) noeigentrim draws(2000) burnin(2000) seed(1)

. gvar solve, nosummary

. gvar bdic, nosummary

. display "Minnesota " dic_mn " SSVS " r(dic)

Stored results

gvar bdic stores the following in r():

r(dbar) posterior mean deviance

r(pd) effective number of parameters

r(dic) Dbar + pD

r(nparam) actual parameter count

r(nfailed) draws skipped for a singular covariance

r(draws) draws in the chain

Source

BGVAR R/BGVAR.R dic() and the exported globalLik();
src/helper.cpp dmvnrm_arma_fast. Spiegelhalter, D. J., Best, N. G.,
Carlin, B. P. and van der Linde, A. (2002), Bayesian measures of model
complexity and fit, JRSS B 64, 583-639.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane