*! version 1.0.1 21aug2026

Title

gvar solve -- stack the country models and solve the GVAR

Syntax

gvar solve [, options]

options

tolerance(#) tolerance for calling an eigenvalue a unit root. Default 1e-6.

graph plot the eigenvalue moduli.

name(name) graph name.

neigen(#) how many eigenvalues to list. Default 20.

nosummary suppress the report.

Description

gvar solve builds G0 and H_l from the country models through
the link matrices, inverts G0 to obtain the reduced form
x_t = d0 + d1 t + sum_l F_l x(t-l) + eta_t, and reports the eigenvalues
of the companion matrix.

Nothing in the dynamic-analysis group works until this has run.

Options

tolerance(#) is how close to one an eigenvalue modulus must be before it
counts as a unit root. Default 1e-6.

It matters more than it looks. The unit-root count is compared against
K - sum(r_i) as a specification check, so a tolerance that is too tight
splits a root that is genuinely at one into "just below" and reports a spurious
mismatch; too loose and it absorbs a root that is really at 0.999 and hides a
real one. If the reported count sits one or two away from the expected number,
vary this before concluding anything about the ranks.

graph plots the eigenvalue moduli in descending order with a reference
line at one, which is the quickest way to see whether the model is marginally or
badly unstable -- a single modulus at 1.02 is a different problem from a dozen.

name(name) names the graph, so a loop over specifications does not
overwrite its own output.

neigen(#) how many of the largest moduli to list. Default 20. The
companion matrix has K x pmax eigenvalues -- 408 on the shipped demo,
whose dominant unit raises pmax to 3 -- so
listing them all is rarely useful; the largest are where the information is.

nosummary suppresses the report but still solves the model and still fills
r(). Use it inside loops. Note it also suppresses the instability warning,
so check r(stable) yourself when running quietly.

Examples

The ordinary case, after gvar estimate:

. gvar solve

With the eigenvalue plot, and a looser unit-root tolerance because the count
came back one short:

. gvar solve, graph tolerance(1e-4)

Quietly, inside a loop over cointegrating ranks, checking stability
programmatically:

. gvar solve, nosummary

. if (r(stable) == 0) display as error "rank set `r' is explosive"

Remarks

The stability check is a specification test, not a formality. A GVAR
with K variables and sum r_i cointegrating relations must have
exactly K - sum r_i eigenvalues on the unit circle. The command counts
them and compares. A mismatch means the ranks and the dynamics disagree, and
the usual cause is an overstated rank somewhere.

Any eigenvalue modulus above one is explosive and makes every impulse
response meaningless. The command says so rather than proceeding quietly.

Stored results

gvar solve stores the following in r():

r(eigen) the eigenvalue moduli

r(maxmod) the largest modulus

r(nunit) eigenvalues at one

r(nexpl) eigenvalues above one

r(expected) K minus the total rank

r(K) endogenous variables

r(pmax) the GVAR lag order

r(stable) 1 if no explosive root

Source

Toolbox solve_GVAR.m.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane