Skip to content

Check whether a result survives other specifications

Find out whether a conclusion rests on the data or on one choice of specification: here, that output falls after a monetary tightening, in a three-variable VAR. The VAR is fitted again for every combination of lag lengths, samples and Cholesky orderings, the response of output to the policy shock two quarters on is read from each, and the specification curve shows which choices move it.

The specification curve: the response at horizon 2 in every specification, sorted, with intervals, and below it which choices each specification made.
The specification curve: the response in every combination of lags, samples and orderings.

Before you start

  • A VAR to start from: the base specification. This page makes the data, so the true response is known: quarterly series on the dates of the example sample_macro (2000Q1 to 2024Q4) driven by three shocks drawn with seeds, a policy shock er, a demand shock ey and a price shock ep. The output gap gap falls 0.6 and 0.8 times the policy shock one and two quarters after it, inflation infl follows the gap a quarter later, and the policy rate rate follows a Taylor rule plus the policy shock. With your own data, load the series instead.
  • The ordering that identifies the policy shock. With the rate last, the rate may respond within the quarter to the gap and inflation, but they respond to it only a quarter later: the timing of this data. Putting the rate first is the alternative to compare.
  • The choices worth trying: lag lengths from one to four and the one BIC chooses, the full sample, one starting in 2005 and one ending before the pandemic, and the two orderings. Every combination is fitted: 30 VARs.

In the app, or in code

The Specification sensitivity dialog: base specification var, the response of gap to a rate shock at horizon 2, lags 1 to 4 and bic, three samples and two Cholesky orderings.
Estimate → Model selection → Specification sensitivity…, as in step 4.

Follow this step by step in the app

View → Guide → How do I → Check whether a result survives other specifications. The Guide panel takes you through these steps one at a time: Open… opens each step's dialog filled in, Show me runs it, and each step is ticked when its result is there. In the app's help, the page's Walk me through this opens it. The Guide is in the pymetrix-guide plugin, which is experimental (pip install --pre "pymetrix[guide]"; the walkthroughs come with its release after 0.1.0a1).

  1. File → Load example data…, with Example dataset: sample_macro and Save as: data. Data → Generate series…, with Data: data, New series name: er and Formula: 0.5*normrnd(seed=1). Again with New series name: ey and Formula: 0.5*normrnd(seed=2), and with New series name: ep and Formula: 0.3*normrnd(seed=3).
  2. Data → Generate series… three more times: New series name: gap and Formula: ey + 0.7*ey[-1] + 0.4*ey[-2] - 0.6*er[-1] - 0.8*er[-2] - 0.5*er[-3] - 0.2*er[-4]; New series name: infl and Formula: 2 + ep + 0.5*ep[-1] + 0.2*gap[-1]; New series name: rate and Formula: 2 + 1.5*(infl - 2) + 0.5*gap + er.
  3. Estimate → VARs and local projections → VAR…, with Series: gap, infl, rate (in that order: the Cholesky ordering), Lags: bic and Save as: var. BIC chooses two lags.
  4. Estimate → Model selection → Specification sensitivity…, with Base specification: var, Quantity compared: Response at a horizon, Variable or coefficient: gap, Shock: rate, Horizon: 2, Lags to compare: 1, 2, 3, 4, bic, Samples: :; 2005Q1:; :2019Q4, Cholesky orderings: gap, infl, rate; rate, gap, infl and Save as: grid. Under Advanced settings, Bootstrap draws: 200, for each response's interval. The Summary tab gives the shares with the base's sign and significant; the Graph is the specification curve; Specifications lists every VAR; By choice gives the response by each choice and each dimension's share of the variance.
  5. Again, with Quantity compared: Response path, Horizon: 12 and Save as: paths (Bootstrap draws back to 0). The Paths tab draws every specification's response, the base's highlighted.
from pymetrix import VAR, Dataset, specification_grid
from pymetrix.sensitivity import irf

data = (Dataset.example("sample_macro")
        .with_series(er="0.5*normrnd(seed=1)", ey="0.5*normrnd(seed=2)", ep="0.3*normrnd(seed=3)")
        .with_series(gap="ey + 0.7*ey[-1] + 0.4*ey[-2] - 0.6*er[-1] - 0.8*er[-2] - 0.5*er[-3] - 0.2*er[-4]")
        .with_series(infl="2 + ep + 0.5*ep[-1] + 0.2*gap[-1]")
        .with_series(rate="2 + 1.5*(infl - 2) + 0.5*gap + er"))
var = VAR(["gap", "infl", "rate"], lags="bic").fit(data)   # BIC: 2 lags; 93 observations, 2001Q4 to 2024Q4
var.irf(12, draws=0)["gap", "rate"]                         # -0.24 after one quarter, -0.30 after two
choices = {"lags": [1, 2, 3, 4, "bic"],
           "sample": [(None, None), ("2005Q1", None), (None, "2019Q4")],
           "identification": [["gap", "infl", "rate"], ["rate", "gap", "infl"]]}
grid = specification_grid(var, data, vary=choices, quantity=irf("rate", "gap", horizon=2, draws=200))
grid.summary()        # 30 specifications: all negative, 83% significant; median -0.24, from -0.34 to -0.07
grid.by_dimension()   # lags: 71% of the variance (one lag: -0.09 on average); ordering 10%; sample 1%
grid.curve()
paths = specification_grid(var, data, vary=choices, quantity=irf("rate", "gap", periods=12))
paths.fan()

Check the result

  • The sign survives. Every one of the 30 VARs has output falling two quarters after a tightening, and 25 of them (83%) with a 95% interval clear of zero. The median response is -0.24, the base's -0.30, and they range from -0.34 to -0.07: the sign is robust, the size is not.
  • The lag length moves it most. Its choices account for 71% of the variance of the responses: with one lag the response averages -0.09 and is significant in half the VARs; with two to four lags it is -0.27 to -0.29 and always significant. One lag cannot carry a response that peaks in the second quarter, and the Specifications tab shows why to distrust it: the one-lag VARs fail the autocorrelation check on the full sample and from 2005.
  • BIC is a choice too. On the full sample it chooses two lags, but on the two shorter samples one, and its responses there (-0.12) sit with the one-lag VARs. The lowest-BIC specification is marked on the curve, as one specification among the others.
  • The ordering matters less, as it should here. With the rate first, the response averages -0.19 against -0.25 and is significant in two thirds of the VARs: putting the rate first lets it absorb some of the demand shock. The sample hardly matters (1% of the variance).
  • The truth is known. The policy shock has a standard deviation of 0.5, so the gap's true response to a one-standard-deviation shock is -0.30 after one quarter and -0.40 after two. The VARs with two lags or more are close to it; the one-lag VARs are far off.

Pitfalls

  • A robust sign is not a robust size. Report the range across specifications with the base's estimate, and the choice that moves it, not the base alone.
  • The lowest criterion is not the answer. Criteria compare models of the same variables on the same sample; here BIC prefers one lag on the shorter samples although the response needs two. Read the diagnostics beside it.
  • Specifications are not equally credible. A VAR that fails its residual checks, or an ordering the timing of the data rules out, should count for less: the curve shows them all, so say which you discount and why.
  • The grid grows fast. Each dimension multiplies the number of fits, and bootstrap draws multiply the time of each. Use Parallel processes (under Advanced settings) for large grids, and draws only for the quantity you report.
  • Identification is a choice the data cannot make. Cholesky orderings are restrictions; when the orderings disagree, compare with sign restrictions (an identification object in the list of choices, in code).

See also