*! version 1.0.1 21aug2026

Title

gvar irf -- impulse responses of the solved GVAR

Syntax

gvar irf , shock(unitvar) [options]

options

shock(unitvar) the element of x(t) that is shocked. Required.

response(spec) which responses to report. Accepts unit:var, unit:*, *:var or a bare variable name. Default is the shocked variable in every unit.

step(#) horizon. Default 24.

type(string) girf, oirf or sgirf. Default girf.

cumulative accumulate the responses.

negative a minus one standard-error shock.

first(units) which units lead the ordering. For type(sgirf) this is the identifying assumption, and the block size is derived from it.

vorder(spec) the variable order inside each leading unit, one block per unit separated by ;.

vcov(string) sample keeps the estimated covariance; blockdiag zeroes every cross-unit covariance; blockdiag unit does the same but leaves one unit's cross-covariances free.

shrink shrink the correlation matrix towards the identity, intensity chosen internally.

lambda(#) set the shrinkage intensity by hand, between 0 and 1.

reps(#) bootstrap replications for the bands.

level(#) band level. Default 95.

shuffle resample whole date columns rather than orthogonalised scalars.

shrinkdraw shrink the covariance used to generate the draws.

lamdraw(#) set that intensity by hand.

horizons(numlist) which horizons to print.

graph small-multiples plot.

name(name) by(string) graph name and by() options.

nosummary suppress the table.

saving(name) save the responses.

Description

gvar irf computes generalized, orthogonalised or structural impulse
responses, optionally cumulated, optionally with bootstrap confidence bands.

The generalized responses of Pesaran and Shin (1998) are the default because
they need no ordering of the variables: with 136 variables no Cholesky
ordering is defensible. They are not responses to orthogonal shocks, so they
do not decompose into contributions that sum to one.

Options

shock(unitvariable) names the element of the global vector that is
shocked. Required. It must select exactly one element -- a shock to "all of the
United States" is not defined.

response(spec) restricts which responses are reported, as
unit:variable with * wildcards. Omitted, every element responds, which
on the shipped demo is 136 series -- readable as a graph, not as a table.

step(#) the horizon. Default 24.

type(girf|oirf|sgirf) the identification.
girf is the generalized response of Pesaran and Shin, which needs no
ordering and is what Dees, di Mauro, Pesaran and Smith report;
oirf is orthogonalised and needs a full ordering of all K variables;
sgirf is structural-generalized -- orthogonalised within a leading block
and generalized across the rest, which is the usual compromise for a GVAR where
a full ordering of 136 variables is indefensible.

girf is the default and the only one that needs no ordering argument. The
other two need a Cholesky factor and so will refuse on a singular
Sigma_zeta -- see shrink.

first(units) and vorder(spec) set the leading block for
type(sgirf): which units come first, and optionally the variable order
within them. The block size n0 is the total number of endogenous variables
in those units, exactly as reorder_GVAR.m defines it.

cumulative reports cumulated responses, which is what you want when the
variable is a growth rate and the question is about the level.

vcov(spec) transforms the covariance before it is used:
the sample matrix, block diagonal (every cross-unit covariance set to zero), or
block diagonal with one unit's cross-covariances left free. The middle option is
the assumption a good many GVAR papers make when they want the generalized
responses to be readable as country-specific.

shrink and lambda(#) shrink the correlation matrix towards the
identity. On the shipped demo Sigma_zeta is 136 x 136 with rank 133 -- 134
quarters cannot support more -- so it has no Cholesky factor and anything
orthogonalised needs one of these. shrink picks the intensity internally;
lambda() sets it by hand.

reps(#) bootstrap replications for the confidence bands, and
level(#) their coverage. With reps(0), the default, no bands are
drawn: the responses are point estimates from the estimated system treated as
known.

shuffle, shrinkdraw and lamdraw(#) govern how each bootstrap
replication handles the same singularity. shuffle resamples the residual
matrix by columns, which keeps the cross-section dependence intact;
shrinkdraw shrinks within each replication rather than once at the start,
which is the honest choice if the shrinkage intensity is itself uncertain.

negative flips the sign of the shock, so a "one standard error decrease"
reads the natural way round.

restrictions(spec), signs(spec), draws(#) and
maxtries(#) identify the shock by sign and zero restrictions instead of by
ordering. draws() is how many accepted rotations to keep and
maxtries() how many candidates to try per accepted draw; if the second is
reached the restriction set is probably infeasible rather than merely tight.

cfhold(spec), cfvia(spec) and cfbase produce a counterfactual
response: hold one set of variables fixed, transmit the shock only through
another, and optionally report the unrestricted baseline alongside for
comparison.

horizons(numlist) selects which horizons appear in the printed table;
table forces the table when a graph was also asked for.
graph, name() and by() control the plot -- by() panels it
by unit or by variable.

saving(name) writes the responses to a dataset, one row per (response,
horizon).

nosummary suppresses the report.

Remarks

Choosing a type. girf is invariant to ordering and is what the GVAR
literature reports. oirf orthogonalises the whole system by Cholesky and
depends on the order of x(t); see gvar describe, order.
sgirf orthogonalises only a leading block, which is the case where you
have a defensible ordering for a few units and none for the rest.

The impact matrix is not triangular. In a GVAR the reduced form carries
G0^-1, so the Cholesky impact matrix is G0^-1 P, not P. Testing
for triangularity will report a correct implementation as broken. The identity
that does hold is B0 B0' = G0^-1 Sigma G0^-1'.

Orthogonalised responses need a factorable covariance. With more
variables than periods Sigma_zeta is singular and no Cholesky factor
exists. The command refuses rather than returning missing values, and names
the two remedies. See gvar methods.

On the bands. reps() runs the full model-level bootstrap: the
global vector is regenerated, every country model re-estimated and the GVAR
re-solved on each replication. The count discarded as unstable is reported and
matters. For a model with K > T, shuffle is the better scheme.

Examples

. gvar irf, shock(usa:r) response(y) step(24)
. gvar irf, shock(usa:poil) response(usa:y euro:y) cumulative
. gvar irf, shock(usa:r) response(y) reps(200) shuffle
. gvar irf, shock(usa:r) type(sgirf) first(usa) ///
vorder(poil pmat pmetal y Dp eq r lr)
. gvar irf, shock(usa:r) type(oirf) shrink

Stored results

gvar irf stores the following in r():

r(irf) the responses, horizons by responses

r(lower) lower band

r(upper) upper band

r(band) all three quantiles stacked

r(shock) the shock

r(responses) the responses reported

r(type) girf, oirf or sgirf

r(step) the horizon

r(reps) replications that converged

r(discarded) draws discarded

Source

Toolbox irf.m, phi.m; reordering from reorder_GVAR.m; bands
from bootstrap_GVAR.m.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane