<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SVAR | Nikolaos Koutounidis</title><link>http://www.nikolaoskoutounidis.com/tags/svar/</link><atom:link href="http://www.nikolaoskoutounidis.com/tags/svar/index.xml" rel="self" type="application/rss+xml"/><description>SVAR</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Mon, 10 Aug 2026 00:00:00 +0000</lastBuildDate><image><url>http://www.nikolaoskoutounidis.com/media/sharing.jpg</url><title>SVAR</title><link>http://www.nikolaoskoutounidis.com/tags/svar/</link></image><item><title>bh2019-oil-svar-python: Baumeister &amp; Hamilton (2019) Oil SVAR in Python</title><link>http://www.nikolaoskoutounidis.com/code/bh2019-oil-svar-python/</link><pubDate>Mon, 10 Aug 2026 00:00:00 +0000</pubDate><guid>http://www.nikolaoskoutounidis.com/code/bh2019-oil-svar-python/</guid><description>&lt;h2 id="overview">Overview&lt;/h2>
&lt;p>&lt;code>bh2019-oil-svar-python&lt;/code> is an independent, open-source &lt;strong>Python translation&lt;/strong> of the MATLAB replication code for:&lt;/p>
&lt;blockquote>
&lt;p>Baumeister, Christiane, and James D. Hamilton. 2019. &lt;strong>&amp;ldquo;Structural Interpretation of Vector Autoregressions with Incomplete Identification: Revisiting the Role of Oil Supply and Demand Shocks.&amp;rdquo;&lt;/strong> &lt;em>American Economic Review&lt;/em> 109(5): 1873-1910.&lt;/p>
&lt;/blockquote>
&lt;p>The official MATLAB package is on the AEA Data and Code Repository (&lt;a href="https://www.openicpsr.org/openicpsr/project/113108/version/V1/view" target="_blank" rel="noopener">openICPSR project 113108&lt;/a>). This repository re-implements it in NumPy and SciPy, with a Numba-accelerated historical decomposition, keeps a 1:1 mapping to the original &lt;code>.m&lt;/code> files, and validates the output against the published results.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>GitHub:&lt;/strong> &lt;a href="https://github.com/nkoutoun/bh2019-oil-svar-python#readme" target="_blank" rel="noopener">github.com/nkoutoun/bh2019-oil-svar-python&lt;/a>&lt;/li>
&lt;li>&lt;strong>License:&lt;/strong> MIT for the translation code. The redistributed input data remain subject to their original terms.&lt;/li>
&lt;/ul>
&lt;h2 id="installation">Installation&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">conda env create -f environment.yml
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">conda activate bh19
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Or, with pip:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pip install -e .&lt;span class="o">[&lt;/span>dev&lt;span class="o">]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="what-is-replicated">What Is Replicated&lt;/h2>
&lt;p>One command-line script per paper object, each mapped to the original MATLAB source:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Script&lt;/th>
&lt;th>Paper object&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>01_baseline_mcmc.py&lt;/code>&lt;/td>
&lt;td>Posterior sampler, baseline 4-variable oil-market SVAR&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>02_figure7_prior_posterior.py&lt;/code>&lt;/td>
&lt;td>Figure 7; Table 3, panels A and B&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>03_figure8_irf_table3.py&lt;/code>&lt;/td>
&lt;td>Figure 8; Table 3, panels C to E; Table 2 posterior column&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>04_figure9_10_hd_table4.py&lt;/code>&lt;/td>
&lt;td>Figures 9 and 10; Table 4, baseline row&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>05_table2_prior_probs.py&lt;/code>&lt;/td>
&lt;td>Table 2, prior column&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>06_figure6_cross_country.py&lt;/code>&lt;/td>
&lt;td>Figure 6, cross-country gasoline demand&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>07_kaer_figures1_2.py&lt;/code>&lt;/td>
&lt;td>Figures 1 and 2, Kilian (2009) revisited&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>08_km12_figures3_4.py&lt;/code>&lt;/td>
&lt;td>Figures 3 and 4, Kilian and Murphy (2012) revisited&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Every MCMC script takes &lt;code>--draws&lt;/code>, &lt;code>--burn&lt;/code>, &lt;code>--seed&lt;/code>, &lt;code>--outdir&lt;/code>, and &lt;code>--quick&lt;/code>, so the whole pipeline can be smoke-tested in about a minute before committing to a paper-scale run of 2,000,000 draws.&lt;/p>
&lt;h2 id="validation">Validation&lt;/h2>
&lt;p>At paper scale the Python posterior reproduces Table 3, column 1, of the original paper on all five checks:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Magnitude (Table 3, col. 1)&lt;/th>
&lt;th>Published&lt;/th>
&lt;th>Obtained&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Panel A, oil supply elasticity&lt;/td>
&lt;td>0.15 (0.09, 0.22)&lt;/td>
&lt;td>0.155 (0.115, 0.211)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Panel B, oil demand elasticity&lt;/td>
&lt;td>-0.35 (-0.51, -0.24)&lt;/td>
&lt;td>-0.335 (-0.429, -0.255)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Panel C, supply shock to activity, 12m&lt;/td>
&lt;td>-0.50 (-0.91, -0.17)&lt;/td>
&lt;td>-0.479 (-0.827, -0.164)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Panel D, consumption-demand shock to activity, 12m&lt;/td>
&lt;td>0.13 (-0.14, 0.44)&lt;/td>
&lt;td>0.151 (-0.118, 0.458)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Panel E, inventory-demand shock to activity, 12m&lt;/td>
&lt;td>-0.36 (-0.81, 0.07)&lt;/td>
&lt;td>-0.328 (-0.750, 0.080)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Table 2 sign probabilities and Table 4 episode contributions match as well. The Python chain samples the identical posterior with a different random-number generator than MATLAB, so agreement holds up to Monte Carlo error and publication rounding, not draw-by-draw identity. Full details and tolerances are in &lt;code>VALIDATION.md&lt;/code>.&lt;/p>
&lt;h2 id="relation-to-my-research">Relation to My Research&lt;/h2>
&lt;p>Identification in oil markets is close to my own work on how global oil supply shocks transmit across U.S. state economies, in &lt;a href="http://www.nikolaoskoutounidis.com/publication/wip-oil/">Shale Production and the Transmission of Oil Supply Shocks&lt;/a>. Porting the Baumeister and Hamilton framework to Python puts a Bayesian SVAR with informative priors on elasticities in the hands of researchers and students who do not work in MATLAB, and the docstrings name the exact MATLAB routine each function translates so the two codebases can be read side by side.&lt;/p>
&lt;h2 id="attribution">Attribution&lt;/h2>
&lt;p>This is an independent translation. It was not written, reviewed, or endorsed by Christiane Baumeister or James D. Hamilton, and any translation errors are mine alone. Please cite the original paper and consult the &lt;a href="https://www.openicpsr.org/openicpsr/project/113108/version/V1/view" target="_blank" rel="noopener">official replication package&lt;/a> for the authoritative implementation.&lt;/p></description></item></channel></rss>