forked from adamwang15/mcxs-report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1527 lines (1490 loc) · 83.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.3.287">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Adam Wang">
<title>Macroeconometrics Research Report - Sign and Zero Restrictions: Optimism Shock on the Australian Business Cycle</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}</style>
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
<script src="site_libs/quarto-nav/headroom.min.js"></script>
<script src="site_libs/clipboard/clipboard.min.js"></script>
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="site_libs/quarto-search/fuse.min.js"></script>
<script src="site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="./">
<script src="site_libs/quarto-html/quarto.js"></script>
<script src="site_libs/quarto-html/popper.min.js"></script>
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="site_libs/quarto-html/anchor.min.js"></script>
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script id="quarto-search-options" type="application/json">{
"location": "navbar",
"copy-button": false,
"collapse-after": 3,
"panel-placement": "end",
"type": "overlay",
"limit": 20,
"language": {
"search-no-results-text": "No results",
"search-matching-documents-text": "matching documents",
"search-copy-link-title": "Copy link to search",
"search-hide-matches-text": "Hide additional matches",
"search-more-match-text": "more match in this document",
"search-more-matches-text": "more matches in this document",
"search-clear-button-title": "Clear",
"search-detached-cancel-button-title": "Cancel",
"search-submit-button-title": "Submit"
}
}</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
<link rel="stylesheet" href="styles.css">
</head>
<body class="nav-fixed">
<div id="quarto-search-results"></div>
<header id="quarto-header" class="headroom fixed-top">
<nav class="navbar navbar-expand-lg navbar-dark ">
<div class="navbar-container container-fluid">
<div class="navbar-brand-container">
<a class="navbar-brand" href="./index.html">
<span class="navbar-title">Macroeconometrics Research Report</span>
</a>
</div>
<div class="quarto-navbar-tools ms-auto">
</div>
<div id="quarto-search" class="" title="Search"></div>
</div> <!-- /container-fluid -->
</nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
<!-- sidebar -->
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">On this page</h2>
<ul>
<li><a href="#introduction" id="toc-introduction" class="nav-link active" data-scroll-target="#introduction">Introduction</a></li>
<li><a href="#data" id="toc-data" class="nav-link" data-scroll-target="#data">Data</a>
<ul class="collapse">
<li><a href="#acf-and-pacf-plot" id="toc-acf-and-pacf-plot" class="nav-link" data-scroll-target="#acf-and-pacf-plot">ACF and PACF plot</a></li>
<li><a href="#augmented-dickey-fuller-test" id="toc-augmented-dickey-fuller-test" class="nav-link" data-scroll-target="#augmented-dickey-fuller-test">Augmented Dickey-Fuller test</a>
<ul class="collapse">
<li><a href="#level" id="toc-level" class="nav-link" data-scroll-target="#level">Level</a></li>
<li><a href="#first-difference" id="toc-first-difference" class="nav-link" data-scroll-target="#first-difference">First difference</a></li>
</ul></li>
</ul></li>
<li><a href="#model" id="toc-model" class="nav-link" data-scroll-target="#model">Model</a>
<ul class="collapse">
<li><a href="#specification" id="toc-specification" class="nav-link" data-scroll-target="#specification">Specification</a>
<ul class="collapse">
<li><a href="#structural-form" id="toc-structural-form" class="nav-link" data-scroll-target="#structural-form">Structural form</a></li>
<li><a href="#reduced-form" id="toc-reduced-form" class="nav-link" data-scroll-target="#reduced-form">Reduced form</a></li>
<li><a href="#orthogonal-reduced-form-parameterization" id="toc-orthogonal-reduced-form-parameterization" class="nav-link" data-scroll-target="#orthogonal-reduced-form-parameterization">Orthogonal reduced-form parameterization</a></li>
</ul></li>
<li><a href="#algorithm" id="toc-algorithm" class="nav-link" data-scroll-target="#algorithm">Algorithm</a>
<ul class="collapse">
<li><a href="#reduced-form-1" id="toc-reduced-form-1" class="nav-link" data-scroll-target="#reduced-form-1">Reduced form</a></li>
<li><a href="#structural-form-1" id="toc-structural-form-1" class="nav-link" data-scroll-target="#structural-form-1">Structural form</a></li>
<li><a href="#implementations" id="toc-implementations" class="nav-link" data-scroll-target="#implementations">Implementations</a></li>
<li><a href="#extension" id="toc-extension" class="nav-link" data-scroll-target="#extension">Extension</a></li>
</ul></li>
<li><a href="#simulation" id="toc-simulation" class="nav-link" data-scroll-target="#simulation">Simulation</a>
<ul class="collapse">
<li><a href="#reduced-form-2" id="toc-reduced-form-2" class="nav-link" data-scroll-target="#reduced-form-2">Reduced form</a></li>
<li><a href="#structural-form-2" id="toc-structural-form-2" class="nav-link" data-scroll-target="#structural-form-2">Structural form</a></li>
</ul></li>
<li><a href="#identification" id="toc-identification" class="nav-link" data-scroll-target="#identification">Identification</a></li>
<li><a href="#interpretation" id="toc-interpretation" class="nav-link" data-scroll-target="#interpretation">Interpretation</a>
<ul class="collapse">
<li><a href="#irf" id="toc-irf" class="nav-link" data-scroll-target="#irf">IRF</a></li>
<li><a href="#fevd" id="toc-fevd" class="nav-link" data-scroll-target="#fevd">FEVD</a></li>
</ul></li>
</ul></li>
<li><a href="#results" id="toc-results" class="nav-link" data-scroll-target="#results">Results</a>
<ul class="collapse">
<li><a href="#us-data" id="toc-us-data" class="nav-link" data-scroll-target="#us-data">US data</a>
<ul class="collapse">
<li><a href="#irf-1" id="toc-irf-1" class="nav-link" data-scroll-target="#irf-1">IRF</a></li>
<li><a href="#fevd-1" id="toc-fevd-1" class="nav-link" data-scroll-target="#fevd-1">FEVD</a></li>
</ul></li>
<li><a href="#australian-data" id="toc-australian-data" class="nav-link" data-scroll-target="#australian-data">Australian data</a>
<ul class="collapse">
<li><a href="#history" id="toc-history" class="nav-link" data-scroll-target="#history">History</a></li>
<li><a href="#irf-2" id="toc-irf-2" class="nav-link" data-scroll-target="#irf-2">IRF</a></li>
<li><a href="#fevd-2" id="toc-fevd-2" class="nav-link" data-scroll-target="#fevd-2">FEVD</a></li>
</ul></li>
<li><a href="#extension-1" id="toc-extension-1" class="nav-link" data-scroll-target="#extension-1">Extension</a>
<ul class="collapse">
<li><a href="#history-1" id="toc-history-1" class="nav-link" data-scroll-target="#history-1">History</a></li>
<li><a href="#irf-3" id="toc-irf-3" class="nav-link" data-scroll-target="#irf-3">IRF</a></li>
<li><a href="#fevd-3" id="toc-fevd-3" class="nav-link" data-scroll-target="#fevd-3">FEVD</a></li>
</ul></li>
</ul></li>
</ul>
</nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Sign and Zero Restrictions: Optimism Shock on the Australian Business Cycle</h1>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Author</div>
<div class="quarto-title-meta-contents">
<p>Adam Wang </p>
</div>
</div>
</div>
</header>
<!-- latex shortcuts -->
<!-- do not show warnings and run code when testing -->
<blockquote class="blockquote">
<p><strong>Abstract.</strong> This article investigates the effects of optimism shocks on the Australian economy using a Bayesian Structural Vector Autoregression (BSVAR) model. We implement the sign and zero restrictions algorithm proposed by <span class="citation" data-cites="arias2018inference">Arias, Rubio-Ramı́rez, and Waggoner (<a href="#ref-arias2018inference" role="doc-biblioref">2018</a>)</span> to identify the optimism shock. Impulse response functions (IRF) and forecast error variance decomposition (FEVD) are used to analyse the effects of the optimism shock on five key macroeconomic variables: productivity, stock prices, consumption, real interest rate and hours worked.</p>
<p><strong>Keywords.</strong> Bayesian Structural VAR, sign restrictions, zero restrictions, optimism shock</p>
</blockquote>
<!-- [Replication Package](https://www.econometricsociety.org/publications/econometrica/2018/03/01/inference-based-structural-vector-autoregressions-identified) -->
<section id="introduction" class="level1">
<h1>Introduction</h1>
<p><strong>Objective</strong>: The goal of this research project is to implement the sign and zero restrictions algorithm proposed by <span class="citation" data-cites="arias2018inference">Arias, Rubio-Ramı́rez, and Waggoner (<a href="#ref-arias2018inference" role="doc-biblioref">2018</a>)</span> in the <a href="https://github.com/bsvars/bsvarSIGNs">bsvarSIGNs</a> package, and apply it to analyse the optimism shock to Australian economy.</p>
<p><strong>Question</strong>: Does optimism shocks drive the business cycles in Australian economy?</p>
<p><strong>Motivation</strong>: In macroeconomics, there has been a longstanding belief that fluctuations in business cycles can be largely attributed to episodes of optimism and pessimism. An optimism shock is defined as a positive shock to stock prices that does not affect productivity. Using a penalty function approach (PFA)<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a>, <span class="citation" data-cites="beaudry2011mood">Beaudry, Nam, and Wang (<a href="#ref-beaudry2011mood" role="doc-biblioref">2011</a>)</span> finds significant evidence that optimism shocks are a key driver of business cycles in the United States as it creates a simultaneous boom in consumption and hours worked. But, <span class="citation" data-cites="arias2018inference">Arias, Rubio-Ramı́rez, and Waggoner (<a href="#ref-arias2018inference" role="doc-biblioref">2018</a>)</span> argue that PFA imposes additional restrictions, and they find less significant results using an importance sampler algorithm. This research project aims to extend the analysis to the Australian economy by implementing the importance sampler algorithm, and compare the results with United-States data.</p>
</section>
<section id="data" class="level1">
<h1>Data</h1>
<!-- load data -->
<!-- concat datasets -->
<p>All data are collected from the Reserve Bank of Australia (RBA), the Australian Bureau of Statistics (ABS) and Yahoo Finance. The sample period covers 1994 Q3 to 2023 Q4. Following <span class="citation" data-cites="beaudry2011mood">Beaudry, Nam, and Wang (<a href="#ref-beaudry2011mood" role="doc-biblioref">2011</a>)</span>, we select the following five variables for our analysis</p>
<ul>
<li><strong>Productivity</strong>: non-farm labour productivity per hour (source: RBA, series ID GNFPROSQI).</li>
</ul>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-3-1.png" class="quarto-discovered-preview-image img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Productivity</figcaption><p></p>
</figure>
</div>
</div>
</div>
<ul>
<li><strong>Stock prices</strong>: end-of-period ASX 200 index (source: Yahoo Finance, ticker symbol ^AXJO), divided by the consumer price index.</li>
</ul>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Stock prices</figcaption><p></p>
</figure>
</div>
</div>
</div>
<ul>
<li><strong>Consumption</strong>: retail turnover (source: ABS, series ID A3348585R), divided by the consumer price index.</li>
</ul>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Consumption</figcaption><p></p>
</figure>
</div>
</div>
</div>
<ul>
<li><strong>Real interest rate</strong>: over-night cash rate nets inflation (source: RBA, series ID FIRMMCRI and GCPIAGSAQP).</li>
</ul>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-6-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Real interest rate</figcaption><p></p>
</figure>
</div>
</div>
</div>
<ul>
<li><strong>Hours worked</strong>: total hours worked (source: ABS, series ID A85389611R).</li>
</ul>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Hours worked</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>The first two variables (productivity and stock prices) are chosen to identify the optimism shock, the last three variables (consumption, real interest rate and hours worked) are chosen to capture the business cycle dynamics as in standard macroeconomic theory.</p>
<p>To capture multiplicative relationships in macroeconomic time series and percentage change interpretation, all variables are log transformed (except for real interest rate). A preview of first 6 rows of the concatenated dataset is shown below.</p>
<div class="cell">
<div class="cell-output-display">
<table class="table table-sm table-striped small">
<colgroup>
<col style="width: 11%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 15%">
<col style="width: 23%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: center;">date</th>
<th style="text-align: center;">productivity</th>
<th style="text-align: center;">stock_prices</th>
<th style="text-align: center;">consumption</th>
<th style="text-align: center;">real_interest_rate</th>
<th style="text-align: center;">hours_worked</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">Sep 1994</td>
<td style="text-align: center;">4.2297</td>
<td style="text-align: center;">3.4527</td>
<td style="text-align: center;">4.9278</td>
<td style="text-align: center;">4.842</td>
<td style="text-align: center;">6.0222</td>
</tr>
<tr class="even">
<td style="text-align: center;">Dec 1994</td>
<td style="text-align: center;">4.2384</td>
<td style="text-align: center;">3.3870</td>
<td style="text-align: center;">4.9191</td>
<td style="text-align: center;">5.961</td>
<td style="text-align: center;">6.0143</td>
</tr>
<tr class="odd">
<td style="text-align: center;">Mar 1995</td>
<td style="text-align: center;">4.2283</td>
<td style="text-align: center;">3.3764</td>
<td style="text-align: center;">4.9315</td>
<td style="text-align: center;">5.892</td>
<td style="text-align: center;">6.0171</td>
</tr>
<tr class="even">
<td style="text-align: center;">Jun 1995</td>
<td style="text-align: center;">4.2136</td>
<td style="text-align: center;">3.4216</td>
<td style="text-align: center;">4.9487</td>
<td style="text-align: center;">6.209</td>
<td style="text-align: center;">6.0220</td>
</tr>
<tr class="odd">
<td style="text-align: center;">Sep 1995</td>
<td style="text-align: center;">4.2327</td>
<td style="text-align: center;">3.4635</td>
<td style="text-align: center;">4.9500</td>
<td style="text-align: center;">6.293</td>
<td style="text-align: center;">6.0199</td>
</tr>
<tr class="even">
<td style="text-align: center;">Dec 1995</td>
<td style="text-align: center;">4.2297</td>
<td style="text-align: center;">3.4968</td>
<td style="text-align: center;">4.9610</td>
<td style="text-align: center;">6.708</td>
<td style="text-align: center;">6.0164</td>
</tr>
</tbody>
</table>
</div>
</div>
<section id="acf-and-pacf-plot" class="level2">
<h2 class="anchored" data-anchor-id="acf-and-pacf-plot">ACF and PACF plot</h2>
<div class="cell">
<div class="cell-output-display">
<div id="fig-acf-plot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="index_files/figure-html/fig-acf-plot-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Figure 1: ACF Plots</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>The autocorrelation function (ACF) plot shows all variables have a consistent pattern of autocorrelation, this suggests that the time series are non-stationary. Stationarity is formally tested using the Augmented Dickey-Fuller test in the next section.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-pacf-plot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="index_files/figure-html/fig-pacf-plot-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Figure 2: PACF Plots</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>The partial autocorrelation function (PACF) plot shows that the partial autocorrelation of all variables is significant at lag 1, real interest rate is also significant at lag 2. Therefore, choosing a lag length for the VAR model greater than or equal to 2 is reasonable, following convention for quarterly data, we will adopt a lag length of 4 for the VAR model.</p>
</section>
<section id="augmented-dickey-fuller-test" class="level2">
<h2 class="anchored" data-anchor-id="augmented-dickey-fuller-test">Augmented Dickey-Fuller test</h2>
<section id="level" class="level3">
<h3 class="anchored" data-anchor-id="level">Level</h3>
<p>All five variables are non-stationary at 5% significance level base on the Augmented Dickey-Fuller test.</p>
<div class="cell">
<div class="cell-output-display">
<table class="table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">variable</th>
<th style="text-align: right;">p_value</th>
<th style="text-align: right;">non_stationary</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">productivity</td>
<td style="text-align: right;">0.8372</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td style="text-align: left;">stock_prices</td>
<td style="text-align: right;">0.1728</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">consumption</td>
<td style="text-align: right;">0.6167</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td style="text-align: left;">real_interest_rate</td>
<td style="text-align: right;">0.3705</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">hours_worked</td>
<td style="text-align: right;">0.0657</td>
<td style="text-align: right;">1</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="first-difference" class="level3">
<h3 class="anchored" data-anchor-id="first-difference">First difference</h3>
<p>Applying Augmented Dickey-Fuller test to the first difference of the variables, we find that all variables are stationary at 5% significance level. Therefore, all variables are integrated of order one <span class="math inline">\(I(1)\)</span> and it is reasonable to put them in a VAR system without further transformation.</p>
<div class="cell">
<div class="cell-output-display">
<table class="table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">variable</th>
<th style="text-align: right;">p_value</th>
<th style="text-align: right;">non_stationary</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">productivity</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;">stock_prices</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">consumption</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;">real_interest_rate</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">hours_worked</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">0</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</section>
</section>
<section id="model" class="level1">
<h1>Model</h1>
<section id="specification" class="level2">
<h2 class="anchored" data-anchor-id="specification">Specification</h2>
<p>Adopting notations from <span class="citation" data-cites="rubio2010structural">Rubio-Ramirez, Waggoner, and Zha (<a href="#ref-rubio2010structural" role="doc-biblioref">2010</a>)</span>, the SVAR model is specified as follows.</p>
<p>The endogenous variables are</p>
<p><span class="math display">\[
\mathbf{y}_t = [\text{productivity}_t,\ \text{stock prices}_t,\ \text{consumption}_t,\ \text{real interest rate}_t,\ \text{hours worked}_t]'
\]</span></p>
<section id="structural-form" class="level3">
<h3 class="anchored" data-anchor-id="structural-form">Structural form</h3>
<p><span class="math display">\[
\begin{align*}
\mathbf{y}_t' \mathbf{A}_0 &= \sum_{l=1}^{p} \mathbf{y}_{t-l}'\mathbf{A}_l + \mathbf{c} + \boldsymbol{\varepsilon}_t' \\
\boldsymbol{\varepsilon}_t | \mathbf{Y}_{t-1} &\overset{\text{iid}}{\sim} \mathcal{N}_N(\mathbf{0}, \mathbf{I})
\end{align*}
\]</span></p>
<p>where <span class="math inline">\(\mathbf{y}_t\)</span> is an <span class="math inline">\(N\times1\)</span> vector of endogenous variables, <span class="math inline">\(\boldsymbol{\varepsilon}_t\)</span> is an <span class="math inline">\(N\times1\)</span> vector of exogenous structural shocks, <span class="math inline">\(\mathbf{A}_l\)</span> is an <span class="math inline">\(N\times N\)</span> matrix of parameters with <span class="math inline">\(\mathbf{A}_0\)</span> invertible, <span class="math inline">\(\mathbf{c}\)</span> is an <span class="math inline">\(1\times N\)</span> vector of parameters, and <span class="math inline">\(p\)</span> is the lag length, and <span class="math inline">\(T\)</span> is the sample size. This can be compactly written as</p>
<p><span class="math display">\[
\begin{align*}
\mathbf{y}_t' \mathbf{A}_0 &= \mathbf{x}_t' \mathbf{A}_+ + \boldsymbol{\varepsilon}_t'
\end{align*}
\]</span></p>
<p>where <span class="math inline">\(\mathbf{A}_+ = [\mathbf{A}_1'\ \cdots\ \mathbf{A}_p'\ \mathbf{c}']\)</span> and <span class="math inline">\(\mathbf{x}_t = [\mathbf{y}_{t-1}'\ \cdots\ \mathbf{y}_{t-p}'\ 1]\)</span>. The dimension of <span class="math inline">\(\mathbf{A}_+\)</span> is <span class="math inline">\(K\times N\)</span> where <span class="math inline">\(K=Np+1\)</span>.</p>
<p>In matrix form,</p>
<p><span class="math display">\[
\begin{align*}
\mathbf{Y} \mathbf{A}_0 &= \mathbf{X} \mathbf{A}_+ + \boldsymbol{\varepsilon}\\
\boldsymbol{\varepsilon}| \mathbf{X} &\sim \mathcal{MN}_{T\times N}(\mathbf{0}, \mathbf{I}_N, \mathbf{I}_T)
\end{align*}
\]</span></p>
<p>where <span class="math inline">\(\mathbf{Y} = [\mathbf{y}_1\ \cdots\ \mathbf{y}_T]'\)</span>, <span class="math inline">\(\mathbf{X} = [\mathbf{x}_1\ \cdots\ \mathbf{x}_T]'\)</span>, and <span class="math inline">\(\boldsymbol{\varepsilon}= [\boldsymbol{\varepsilon}_1\ \cdots\ \boldsymbol{\varepsilon}_T]'\)</span>.</p>
<p>The matrices <span class="math inline">\(\mathbf{A}_0\)</span> and <span class="math inline">\(\mathbf{A}_+\)</span> are structural parameters.</p>
</section>
<section id="reduced-form" class="level3">
<h3 class="anchored" data-anchor-id="reduced-form">Reduced form</h3>
<p><span class="math display">\[
\begin{align*}
\mathbf{y}_t' &= \mathbf{x}_t' \mathbf{B} + \mathbf{u}_t' \\
\mathbf{u}_t | \mathbf{Y}_{t-1} &\overset{\text{iid}}{\sim} \mathcal{N}_N(\mathbf{0}, \mathbf{\Sigma})
\end{align*}
\]</span></p>
<p>where <span class="math inline">\(\mathbf{B} = \mathbf{A}_ + \mathbf{A}_0^{-1},\ \mathbf{u}_t' = \boldsymbol{\varepsilon}_t' \mathbf{A}_0^{-1}\)</span>, and</p>
<p><span class="math display">\[
\mathbf{\Sigma }= \mathbb{E}[\mathbf{u}_t\mathbf{u}_t'] = (\mathbf{A}_0^{-1})' (\mathbf{A}_0^{-1}) = (\mathbf{A}_0 \mathbf{A}_0')^{-1}
\]</span></p>
<p>In matrix form,</p>
<p><span class="math display">\[
\begin{align*}
\mathbf{Y} &= \mathbf{X} \mathbf{B} + \mathbf{u} \\
\mathbf{u} | \mathbf{X} &\sim \mathcal{MN}_{T\times n}(\mathbf{0}, \mathbf{\Sigma}, \mathbf{I}_T)
\end{align*}
\]</span></p>
<p>where <span class="math inline">\(\mathbf{u} = [\mathbf{u}_1\ \cdots\ \mathbf{u}_T]'\)</span>.</p>
<p>The matrices <span class="math inline">\(\mathbf{B}\)</span> and <span class="math inline">\(\mathbf{\Sigma}\)</span> are reduced-form parameters.</p>
</section>
<section id="orthogonal-reduced-form-parameterization" class="level3">
<h3 class="anchored" data-anchor-id="orthogonal-reduced-form-parameterization">Orthogonal reduced-form parameterization</h3>
<p>Since SVAR model are identified up to a rotation matrix <span class="math inline">\(\mathbf{Q}\)</span>, we can explicitly specified the reduced-form model as</p>
<p><span class="math display">\[
\mathbf{y}_t' = \mathbf{x}_t' \mathbf{B} + \boldsymbol{\varepsilon}_t' \mathbf{Q}' h(\mathbf{\Sigma})
\]</span></p>
<p>Where <span class="math inline">\(\mathbf{Q}'h(\mathbf{\Sigma}) = \mathbf{A}_0^{-1}\)</span> or <span class="math inline">\(\mathbf{Q}=h(\mathbf{\Sigma}) \mathbf{A}_0\)</span>, and <span class="math inline">\(h\)</span> is some differentiable decomposition, one specific choice is the upper triangular Cholesky decomposition.</p>
<p>Then, we can define a mapping <span class="math inline">\(f_h\)</span> between the reduced-form parameters <span class="math inline">\((\mathbf{B}, \mathbf{\Sigma}, \mathbf{Q})\)</span> and structural-form parameters <span class="math inline">\((\mathbf{A}_0, \mathbf{A}_+)\)</span> as</p>
<p><span class="math display">\[
\begin{align*}
f_h(\mathbf{A}_0, \mathbf{A}_+) &= (
\underbrace{\mathbf{A}_+ \mathbf{A}_0^{-1}}_\mathbf{B},
\underbrace{(\mathbf{A}_0 \mathbf{A}_0')^{-1}}_{\mathbf{\Sigma}},
\underbrace{h((\mathbf{A}_0 \mathbf{A}_0')^{-1}) \mathbf{A}_0}_\mathbf{Q}
) \\
f_h^{-1}(\mathbf{B}, \mathbf{\Sigma}, \mathbf{Q}) &= (
\underbrace{h(\mathbf{\Sigma})^{-1} \mathbf{Q}}_{\mathbf{A}_0},
\underbrace{\mathbf{B} h(\mathbf{\Sigma})^{-1} \mathbf{Q}}_{\mathbf{A}_+}
)
)
\end{align*}
\]</span></p>
</section>
</section>
<section id="algorithm" class="level2">
<h2 class="anchored" data-anchor-id="algorithm">Algorithm</h2>
<section id="reduced-form-1" class="level3">
<h3 class="anchored" data-anchor-id="reduced-form-1">Reduced form</h3>
<p>The first step is to sample the reduced-form parameters (<span class="math inline">\(\mathbf{B}\)</span>, <span class="math inline">\(\mathbf{\Sigma}\)</span>). Adopting the conjugate Normal-Inverse-Wishart prior,</p>
<p><span class="math display">\[
\begin{align*}
\mathbf{B}|\mathbf{\Sigma }&\sim \mathcal{MN}_{K\times N}(\underline{\mathbf{B}}, \underline{\mathbf{V}},\mathbf{\Sigma}) \\
\mathbf{\Sigma }&\sim \mathcal{IW}_N(\underline{\mathbf{S}}, \underline{\nu})
\end{align*}
\]</span></p>
<p>and let</p>
<p><span class="math display">\[
\begin{align*}
\hat{\mathbf{B}} &= (\mathbf{X}'\mathbf{X})^{-1}\mathbf{X}'\mathbf{Y} \\
\mathbf{R} &= (\mathbf{Y}-\mathbf{X}\hat{\mathbf{B}})'(\mathbf{Y}-\mathbf{X}\hat{\mathbf{B}})
\end{align*}
\]</span></p>
<p>the conjugate posterior distribution can be derived from</p>
<p><span class="math display">\[\begin{align*}
p(\mathbf{B},\mathbf{\Sigma}|\mathbf{Y})
&\propto |\mathbf{\Sigma}|^{-T/2}\exp\left\{ -\frac{1}{2}\text{tr}\left[ \mathbf{\Sigma}^{-1}(\mathbf{Y}-\mathbf{X}\mathbf{B})'(\mathbf{Y}-\mathbf{X}\mathbf{B}) \right] \right\} \\
&\quad\times |\mathbf{\Sigma}|^{-T/2}\exp\left\{ -\frac{1}{2}\text{tr}[\mathbf{\Sigma}^{-1}(\mathbf{B}-\underline{\mathbf{B}})'\underline{\mathbf{V}}^{-1}(\mathbf{B}-\underline{\mathbf{B}})] \right\} \\
&\quad\times |\mathbf{\Sigma}|^{-(\underline\nu+N+1)/2}\exp\left\{ -\frac{1}{2} \text{tr}(\underline{\mathbf{S}}\mathbf{\Sigma}^{-1}) \right\} \\
&\propto |\mathbf{\Sigma}|^{-T/2}\exp\left\{ -\frac{1}{2}\text{tr}\left[ \left( \mathbf{R}+(\mathbf{B}-\hat{\mathbf{B}})'\mathbf{X}'\mathbf{X}(\mathbf{B}-\hat{\mathbf{B}}) \right) \mathbf{\Sigma}^{-1} \right] \right\} \\
&\quad\times |\mathbf{\Sigma}|^{-T/2}\exp\left\{ -\frac{1}{2}\text{tr}[(\mathbf{B}-\underline{\mathbf{B}})'\underline{\mathbf{V}}^{-1}(\mathbf{B}-\underline{\mathbf{B}})\mathbf{\Sigma}^{-1}] \right\} \\
&\quad\times |\mathbf{\Sigma}|^{-(\underline\nu+N+1)/2}\exp\left\{ -\frac{1}{2} \text{tr}(\underline{\mathbf{S}}\mathbf{\Sigma}^{-1}) \right\} \\
&\propto |\mathbf{\Sigma}|^{-T/2}\exp\left\{ -\frac{1}{2} \text{tr}\left[ \left( (\mathbf{B}-\hat{\mathbf{B}})'\mathbf{X}'\mathbf{X}(\mathbf{B}-\hat{\mathbf{B}})+(\mathbf{B}-\underline{\mathbf{B}})'\underline{\mathbf{V}}^{-1}(\mathbf{B}-\underline{\mathbf{B}}) \right) \mathbf{\Sigma}^{-1} \right] \right\} \\
&\quad\times |\mathbf{\Sigma}|^{-(\underline\nu+T+N+1)/2}\exp\left\{ -\frac{1}{2}\text{tr}\left[ (\mathbf{R}+\underline{\mathbf{S}})\mathbf{\Sigma}^{-1} \right] \right\} \\
&=|\mathbf{\Sigma}|^{-T/2}\exp\left\{ -\frac{1}{2} \text{tr}\left[ (\mathbf{B}-\overline{\mathbf{B}})'\overline{\mathbf{V}}^{-1}(\mathbf{B}-\overline{\mathbf{B}}) \mathbf{\Sigma}^{-1} \right] \right\} \\
&\quad\times |\mathbf{\Sigma}|^{-(\underline\nu+T+N+1)/2}\exp\left\{ -\frac{1}{2}\text{tr}\left[ (\mathbf{R}+\underline{\mathbf{S}}+\hat{\mathbf{B}}'\mathbf{X}'\mathbf{X}\hat{\mathbf{B}}+\underline{\mathbf{B}}'\underline{\mathbf{V}}^{-1}\underline{\mathbf{B}}-\overline{\mathbf{B}}'\overline{\mathbf{V}}^{-1}\overline{\mathbf{B}})\mathbf{\Sigma}^{-1} \right] \right\} \\
&=|\mathbf{\Sigma}|^{-T/2}\exp\left\{ -\frac{1}{2} \text{tr}\left[ (\mathbf{B}-\overline{\mathbf{B}})'\overline{\mathbf{V}}^{-1}(\mathbf{B}-\overline{\mathbf{B}}) \mathbf{\Sigma}^{-1} \right] \right\} \\
&\quad\times |\mathbf{\Sigma}|^{-(\underline\nu+T+N+1)/2}\exp\left\{ -\frac{1}{2}\text{tr}\left[ (\mathbf{Y}'\mathbf{Y}+\underline{\mathbf{S}}+\underline{\mathbf{B}}'\underline{\mathbf{V}}^{-1}\underline{\mathbf{B}}-\overline{\mathbf{B}}'\overline{\mathbf{V}}\overline{\mathbf{B}})\mathbf{\Sigma}^{-1} \right] \right\} \\
&=p(\mathbf{B}|\mathbf{\Sigma},\mathbf{Y})\times p(\mathbf{\Sigma}|\mathbf{Y})
\end{align*}\]</span></p>
<p>Therefore, the posterior distribution of the reduced-form parameters is given by</p>
<p><span class="math display">\[
\begin{align*}
\mathbf{B}|\mathbf{\Sigma},\mathbf{Y} &\sim \mathcal{MN}_{K\times N}(\overline{\mathbf{B}}, \overline{\mathbf{V}},\mathbf{\Sigma}) \\
\mathbf{\Sigma}|\mathbf{Y} &\sim \mathcal{IW}_N(\overline{\mathbf{S}}, \overline{\nu})
\end{align*}
\]</span></p>
<p>where</p>
<p><span class="math display">\[
\begin{align*}
\overline{\mathbf{B}} &= \overline{\mathbf{V}}(\mathbf{X}'\mathbf{Y}+\underline{\mathbf{V}}^{-1}\underline{\mathbf{B}}) \\
\overline{\mathbf{V}} &= (\mathbf{X}'\mathbf{X}+\underline{\mathbf{V}}^{-1})^{-1} \\
\overline{\mathbf{S}} &= \underline{\mathbf{S}}+\mathbf{Y}'\mathbf{Y}+\underline{\mathbf{B}}'\underline{\mathbf{V}}^{-1}\underline{\mathbf{B}}-\overline{\mathbf{B}}'\overline{\mathbf{V}}^{-1}\overline{\mathbf{B}} \\
\overline{\nu} &= \underline{\nu}+T
\end{align*}
\]</span></p>
</section>
<section id="structural-form-1" class="level3">
<h3 class="anchored" data-anchor-id="structural-form-1">Structural form</h3>
<p>To perform zero and sign restrictions, we need an algorithm to sample from the posterior distribution of the structural parameters (<span class="math inline">\(\mathbf{A}_0\)</span>, <span class="math inline">\(\mathbf{A}_+\)</span>) conditional on the zero and sign restrictions.</p>
<p>However, the set of structural parameters satisfying the zero restrictions is of Lebesgue measure zero in the set of all structural parameters (akin to <span class="math inline">\(\mathbb{P}(X=x)=0\)</span> for continuous <span class="math inline">\(X\)</span>). Luckily, we can sample the set of structural parameters satisfying the sign restrictions conditional on satisfying the zero restrictions.</p>
<p>Here is a high level outline of the algorithm proposed by <span class="citation" data-cites="arias2018inference">Arias, Rubio-Ramı́rez, and Waggoner (<a href="#ref-arias2018inference" role="doc-biblioref">2018</a>)</span>:</p>
<ol type="1">
<li>Sample reduced-form parameters (<span class="math inline">\(\mathbf{B}\)</span>, <span class="math inline">\(\mathbf{\Sigma}\)</span>, <span class="math inline">\(\mathbf{Q}\)</span>) conditional on the zero restrictions.</li>
<li>Set <span class="math inline">\((\mathbf{A}_0, \mathbf{A}_+) = f_h^{-1}(\mathbf{B}, \mathbf{\Sigma}, \mathbf{Q})\)</span>.</li>
<li>If the sign restrictions are satisfied, keep <span class="math inline">\((\mathbf{A}_0, \mathbf{A}_+)\)</span> and compute an importance weight, otherwise discard.</li>
<li>Repeat steps 1-3 until the desired number of samples is obtained.</li>
<li>Resample with replacement using the importance weights.</li>
</ol>
<p>Where step 5 (importance sampling) is needed to manipulate the density induced by step 1 to the desired Nomral-Generalized-Normal posterior density <span class="math inline">\(\mathcal{NGN}\)</span>.</p>
<p>To be explicit, starting with a Uniform-Normal-Inverse-Wishart <span class="math inline">\(\mathcal{UNIW}\)</span> prior distribution, the importance weight in step 3 is given by (posterior condition on <span class="math inline">\(\mathbf{Y}\)</span> is dropped for brevity):</p>
<p><span class="math display">\[
\begin{align*}
\frac{\mathcal{NGN}(\mathbf{A}_0,\mathbf{A}_+|\mathcal Z, \mathcal S)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}
&=\frac{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal Z, \mathcal S)v_{f_h}(\mathbf{A}_0,\mathbf{A}_+)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}\\
&\propto\frac{|\text{det}(\mathbf{A}_0)|^{-(2N+K+1)}}{v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}
\end{align*}
\]</span></p>
<p>where <span class="math inline">\(\mathcal Z\)</span> denotes zero restrictions and <span class="math inline">\(\mathcal S\)</span> denotes sign restrictions. The numerator is the target density, and the denominator is the proposal density from steps 1-2.</p>
</section>
<section id="implementations" class="level3">
<h3 class="anchored" data-anchor-id="implementations">Implementations</h3>
<p>For computational efficiency, main functions in the <code>bsvarSIGNs</code> package are written in C++. The first function is compute posterior parameters as derived above.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode cpp code-with-copy"><code class="sourceCode cpp"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>Rcpp<span class="op">::</span>List niw_cpp<span class="op">(</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>mat<span class="op">&</span> Y<span class="op">,</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>mat<span class="op">&</span> X<span class="op">,</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> Rcpp<span class="op">::</span>List prior</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="op">)</span> <span class="op">{</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> <span class="dt">int</span> T <span class="op">=</span> Y<span class="op">.</span>n_rows<span class="op">;</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> mat prior_B <span class="op">=</span> as<span class="op"><</span>mat<span class="op">>(</span>prior<span class="op">[</span><span class="st">"B"</span><span class="op">]);</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> mat prior_V <span class="op">=</span> as<span class="op"><</span>mat<span class="op">>(</span>prior<span class="op">[</span><span class="st">"V"</span><span class="op">]);</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> mat prior_S <span class="op">=</span> as<span class="op"><</span>mat<span class="op">>(</span>prior<span class="op">[</span><span class="st">"S"</span><span class="op">]);</span></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> prior_nu <span class="op">=</span> as<span class="op"><</span><span class="dt">int</span><span class="op">>(</span>prior<span class="op">[</span><span class="st">"nu"</span><span class="op">]);</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a> <span class="co">// analytic solutions</span></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a> mat prior_V_inv <span class="op">=</span> inv_sympd<span class="op">(</span>prior_V<span class="op">);</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a> mat post_V_inv <span class="op">=</span> prior_V_inv <span class="op">+</span> X<span class="op">.</span>t<span class="op">()</span> <span class="op">*</span> X<span class="op">;</span></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a> mat post_V <span class="op">=</span> inv_sympd<span class="op">(</span>post_V_inv<span class="op">);</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a> mat post_B <span class="op">=</span> post_V <span class="op">*</span> <span class="op">(</span>X<span class="op">.</span>t<span class="op">()</span> <span class="op">*</span> Y <span class="op">+</span> prior_V_inv <span class="op">*</span> prior_B<span class="op">);</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a> <span class="co">// marginal posterior of Sigma</span></span>
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true" tabindex="-1"></a> mat post_S <span class="op">=</span> prior_S <span class="op">+</span> Y<span class="op">.</span>t<span class="op">()</span> <span class="op">*</span> Y <span class="op">+</span> prior_B<span class="op">.</span>t<span class="op">()</span> <span class="op">*</span> prior_V_inv <span class="op">*</span> prior_B <span class="op">-</span> post_B<span class="op">.</span>t<span class="op">()</span> <span class="op">*</span> post_V_inv <span class="op">*</span> post_B<span class="op">;</span></span>
<span id="cb1-22"><a href="#cb1-22" aria-hidden="true" tabindex="-1"></a> post_S <span class="op">=</span> symmatu<span class="op">(</span>post_S<span class="op">);</span></span>
<span id="cb1-23"><a href="#cb1-23" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> post_nu <span class="op">=</span> prior_nu <span class="op">+</span> T<span class="op">;</span></span>
<span id="cb1-24"><a href="#cb1-24" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb1-25"><a href="#cb1-25" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> List<span class="op">::</span>create<span class="op">(</span></span>
<span id="cb1-26"><a href="#cb1-26" aria-hidden="true" tabindex="-1"></a> Named<span class="op">(</span><span class="st">"B"</span><span class="op">)</span> <span class="op">=</span> post_B<span class="op">,</span></span>
<span id="cb1-27"><a href="#cb1-27" aria-hidden="true" tabindex="-1"></a> Named<span class="op">(</span><span class="st">"V"</span><span class="op">)</span> <span class="op">=</span> post_V<span class="op">,</span></span>
<span id="cb1-28"><a href="#cb1-28" aria-hidden="true" tabindex="-1"></a> Named<span class="op">(</span><span class="st">"S"</span><span class="op">)</span> <span class="op">=</span> post_S<span class="op">,</span></span>
<span id="cb1-29"><a href="#cb1-29" aria-hidden="true" tabindex="-1"></a> Named<span class="op">(</span><span class="st">"nu"</span><span class="op">)</span> <span class="op">=</span> post_nu</span>
<span id="cb1-30"><a href="#cb1-30" aria-hidden="true" tabindex="-1"></a> <span class="op">);</span></span>
<span id="cb1-31"><a href="#cb1-31" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>The second function is to draw from the matrix normal distribution.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode cpp code-with-copy"><code class="sourceCode cpp"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>arma<span class="op">::</span>mat rmatnorm_cpp<span class="op">(</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>mat<span class="op">&</span> M<span class="op">,</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>mat<span class="op">&</span> U<span class="op">,</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>mat<span class="op">&</span> V</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="op">)</span> <span class="op">{</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> mat X <span class="op">=</span> mat<span class="op">(</span>size<span class="op">(</span>M<span class="op">),</span> fill<span class="op">::</span>randn<span class="op">);</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> M <span class="op">+</span> chol<span class="op">(</span>U<span class="op">).</span>t<span class="op">()</span> <span class="op">*</span> X <span class="op">*</span> chol<span class="op">(</span>V<span class="op">);</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>To draw from the inverse Wishart distribution, we use the <code>iwishrnd</code> function from the <code>RcppArmadillo</code> package. Using these three functions together, we are able to estimate the reduced-form BVAR model.</p>
<p>The following code calculates the volume element <span class="math inline">\(v_{(g\circ f_h)|\mathcal Z}\)</span> in the resampling step for the structural parameters</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode cpp code-with-copy"><code class="sourceCode cpp"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="dt">double</span> log_volume_element<span class="op">(</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>field<span class="op"><</span>arma<span class="op">::</span>mat<span class="op">>&</span> Z<span class="op">,</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>mat<span class="op">&</span> A0<span class="op">,</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>mat<span class="op">&</span> Aplus</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> colvec vec_structural <span class="op">=</span> join_vert<span class="op">(</span>vectorise<span class="op">(</span>A0<span class="op">),</span> vectorise<span class="op">(</span>Aplus<span class="op">));</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> mat Dz <span class="op">=</span> Df<span class="op">([</span>Z<span class="op">](</span><span class="at">const</span> colvec<span class="op">&</span> x<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> zero_restrictions<span class="op">(</span>Z<span class="op">,</span> x<span class="op">);</span> <span class="op">},</span> vec_structural<span class="op">);</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> mat Dgf <span class="op">=</span> Df<span class="op">([</span>Z<span class="op">](</span><span class="at">const</span> colvec<span class="op">&</span> x<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> <span class="va">g_fh_vec</span><span class="op">(</span>Z<span class="op">,</span> x<span class="op">);</span> <span class="op">},</span> vec_structural<span class="op">);</span></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a> mat DN <span class="op">=</span> Dgf <span class="op">*</span> null<span class="op">(</span>Dz<span class="op">);</span></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="fl">0.5</span> <span class="op">*</span> log_det<span class="op">(</span>DN<span class="op">.</span>t<span class="op">()</span> <span class="op">*</span> DN<span class="op">).</span>real<span class="op">();</span></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section>
<section id="extension" class="level3">
<h3 class="anchored" data-anchor-id="extension">Extension</h3>
<p>Besides the zero and sign restrictions, another popular identification scheme proposed by <span class="citation" data-cites="antolin2018narrative">Antolı́n-Dı́az and Rubio-Ramı́rez (<a href="#ref-antolin2018narrative" role="doc-biblioref">2018</a>)</span> is to impose narrative restrictions on the structural shocks and historical decomposition. For example, restricting a structural shock to be negative during some period, and we will apply this to restrict the optimism shock during the Covid-19 pandemic.</p>
<p>But, the difficulty is that the narrative restrictions <span class="math inline">\(\mathcal{R}\)</span> requires another resample with some importance weight:</p>
<p><span class="math display">\[
\frac{1}{\omega(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})} \propto \frac{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal S, \mathcal R)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})}
\]</span></p>
<p>To combine these two identification schemes, we need to calculate the importance weight when <strong>all</strong> of the three restrictions, zero, sign, and narrative, are present. Here is a preliminary calculation, with no guarantee of correctness:</p>
<p><span class="math display">\[
\begin{align*}
\frac{\mathcal{NGN}(\mathbf{A}_0,\mathbf{A}_+|\mathcal Z, \mathcal S, \mathcal R)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}
=&\frac{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal Z, \mathcal S, \mathcal R)v_{f_h}(\mathbf{A}_0,\mathbf{A}_+)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}\\
=&\frac{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal S, \mathcal R)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})}
\frac{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal Z, \mathcal S, \mathcal R)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal S, \mathcal R)}\\
&\times
\frac{v_{f_h}(\mathbf{A}_0,\mathbf{A}_+)}{v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}\\
\propto&\frac{1}{\omega(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})}\frac{v_{f_h}(\mathbf{A}_0,\mathbf{A}_+)}{v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}\\
\propto&\frac{1}{\omega(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})}\frac{|\text{det}(\mathbf{A}_0)|^{-(2N+K+1)}}{v_{(g\circ f_h)|\mathcal Z}(\mathbf{A}_0,\mathbf{A}_+)}
\end{align*}
\]</span></p>
<p>Where <span class="math inline">\(\frac{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal Z, \mathcal S, \mathcal R)}{\mathcal{UNIW}(\mathbf{B},\mathbf{\Sigma},\mathbf{Q}|\mathcal S, \mathcal R)}\propto1\)</span>, since zero restrictions does not change the likelihood. Therefore, it is simply the product of the importance weight for the narrative restrictions and the importance weight for the zero and sign restrictions.</p>
<p>The following code calculates <span class="math inline">\(\omega(\mathbf{B},\mathbf{\Sigma},\mathbf{Q})\)</span> for the narrative restrictions</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode cpp code-with-copy"><code class="sourceCode cpp"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="dt">double</span> weight_narrative<span class="op">(</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> <span class="dt">int</span><span class="op">&</span> T<span class="op">,</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> arma<span class="op">::</span>mat sign_narrative<span class="op">,</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> arma<span class="op">::</span>cube<span class="op">&</span> irf</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="op">)</span> <span class="op">{</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="at">const</span> <span class="dt">int</span> M <span class="op">=</span> <span class="fl">1e+04</span><span class="op">;</span> <span class="co">// number of draws to approximate normal distribution</span></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a> <span class="dt">double</span> n_success <span class="op">=</span> <span class="fl">1.0e-15</span><span class="op">;</span></span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a> cube Z<span class="op">(</span>irf<span class="op">.</span>n_rows<span class="op">,</span> sign_narrative<span class="op">.</span>col<span class="op">(</span><span class="dv">5</span><span class="op">).</span>max<span class="op">()</span> <span class="op">+</span> <span class="dv">1</span><span class="op">,</span> M<span class="op">,</span> fill<span class="op">::</span>randn<span class="op">);</span></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a> <span class="co">// change all starting period to the first period</span></span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a> <span class="co">// since we use the same M draws for all narrative restrictions</span></span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a> sign_narrative<span class="op">.</span>col<span class="op">(</span><span class="dv">4</span><span class="op">)</span> <span class="op">=</span> ones<span class="op">(</span>sign_narrative<span class="op">.</span>n_rows<span class="op">,</span> <span class="dv">1</span><span class="op">);</span></span>
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> <span class="op">(</span><span class="dt">int</span> m<span class="op">=</span><span class="dv">0</span><span class="op">;</span> m<span class="op"><</span>M<span class="op">;</span> m<span class="op">++)</span> <span class="op">{</span></span>
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>match_sign_narrative<span class="op">(</span>Z<span class="op">.</span>slice<span class="op">(</span>m<span class="op">),</span> sign_narrative<span class="op">,</span> irf<span class="op">))</span> <span class="op">{</span></span>
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a> n_success<span class="op">++;</span></span>
<span id="cb4-20"><a href="#cb4-20" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
<span id="cb4-21"><a href="#cb4-21" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
<span id="cb4-22"><a href="#cb4-22" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> M <span class="op">/</span> n_success<span class="op">;</span></span>
<span id="cb4-23"><a href="#cb4-23" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section>
</section>
<section id="simulation" class="level2">
<h2 class="anchored" data-anchor-id="simulation">Simulation</h2>
<section id="reduced-form-2" class="level3">
<h3 class="anchored" data-anchor-id="reduced-form-2">Reduced form</h3>
<p>To test the validity of our code, we simulate 1,000 observations from a bi-variate Gaussian random walk process with the covariance matrix equal to the identity matrix of order 2.</p>
<p>Then, we compute 1,000 posterior draws from a SVAR model with a constant term and one lag, using the default identification scheme: positive sign restrictions on the diagonal of <span class="math inline">\(\mathbf{A}_0\)</span>.</p>
<p>The posterior mean of the <span class="math inline">\(\mathbf{B}\)</span> is</p>
<div class="cell">
<div class="cell-output-display">
<table class="table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;"></th>
<th style="text-align: right;">y1</th>
<th style="text-align: right;">y2</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">y1_lag</td>
<td style="text-align: right;">0.9885</td>
<td style="text-align: right;">0.0052</td>
</tr>
<tr class="even">
<td style="text-align: left;">y2_lag</td>
<td style="text-align: right;">0.0027</td>
<td style="text-align: right;">0.9954</td>
</tr>
<tr class="odd">
<td style="text-align: left;">constant</td>
<td style="text-align: right;">0.0589</td>
<td style="text-align: right;">0.0822</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>The posterior mean of <span class="math inline">\(\mathbf{\Sigma}\)</span> is</p>
<div class="cell">
<div class="cell-output-display">
<table class="table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;"></th>
<th style="text-align: right;">y1</th>
<th style="text-align: right;">y2</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">y1</td>
<td style="text-align: right;">0.9760</td>
<td style="text-align: right;">0.0881</td>
</tr>
<tr class="even">
<td style="text-align: left;">y2</td>
<td style="text-align: right;">0.0881</td>
<td style="text-align: right;">1.0146</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>They are close to the true values of the simulated data.</p>
</section>
<section id="structural-form-2" class="level3">
<h3 class="anchored" data-anchor-id="structural-form-2">Structural form</h3>
<p>Suppose the true structural model is</p>
<p><span class="math display">\[
\begin{bmatrix}
-1 & 1\\
1 & 0\\
\end{bmatrix}
\begin{bmatrix}
y_{1,t}\\
y_{2,t}\\
\end{bmatrix}
=
\begin{bmatrix}
-1 & 1\\
1 & 0\\
\end{bmatrix}
\begin{bmatrix}
y_{1,t-1}\\
y_{2,t-1}\\
\end{bmatrix}
+
\begin{bmatrix}
\varepsilon_{1,t}\\
\varepsilon_{2,t}\\
\end{bmatrix},
\begin{bmatrix}
\varepsilon_{1,t}\\
\varepsilon_{2,t}\\
\end{bmatrix}
\sim
\mathcal{N}(
\begin{bmatrix}
0 \\
0
\end{bmatrix}
,
\begin{bmatrix}
1 & 0 \\
0 & 1 \\
\end{bmatrix}
)
\]</span></p>
<p>equivalently, we can simulate 1,000 observations from the reduced-form</p>
<p><span class="math display">\[
\begin{bmatrix}
y_{1,t}\\
y_{2,t}\\
\end{bmatrix}
=
\begin{bmatrix}
1 & 0\\
0 & 1\\
\end{bmatrix}
\begin{bmatrix}
y_{1,t-1}\\
y_{2,t-1}\\
\end{bmatrix}
+
\begin{bmatrix}
u_{1,t}\\
u_{2,t}\\
\end{bmatrix},
\begin{bmatrix}
u_{1,t}\\
u_{2,t}\\
\end{bmatrix}
\sim
\mathcal{N}(
\begin{bmatrix}
0 \\
0
\end{bmatrix}
,
\begin{bmatrix}
1 & 1 \\
1 & 2 \\
\end{bmatrix}
)
\]</span></p>
<p>Putting zero and sign restrictions on the inverse of the structural matrix</p>
<p><span class="math display">\[
\begin{bmatrix}
-1 & 1\\
1 & 0\\
\end{bmatrix}^{-1}
=
\begin{bmatrix}
0 & 1\\
1 & 1\\
\end{bmatrix}
\Rightarrow
\begin{bmatrix}
0 & +\\
+ & +\\
\end{bmatrix}
\]</span></p>
<p>Posterior mean of 1,000 draws of the structural matrix is</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code> [,1] [,2]
[1,] -0.9613 1.0448
[2,] 0.9614 0.0000</code></pre>
</div>
</div>
</section>
</section>
<section id="identification" class="level2">
<h2 class="anchored" data-anchor-id="identification">Identification</h2>
<p>The following restrictions are imposed on the contemporaneous impulse response to identify the optimism shock.</p>
<table class="table">
<colgroup>
<col style="width: 18%">
<col style="width: 18%">
<col style="width: 17%">
<col style="width: 26%">
<col style="width: 18%">
</colgroup>
<thead>
<tr class="header">
<th>Productivity</th>
<th>Stock prices</th>
<th>Consumption</th>
<th>Real interest rate</th>
<th>Hours worked</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>0</td>
<td>Positive</td>
<td>Unrestricted</td>
<td>Unrestricted</td>
<td>Unrestricted</td>
</tr>
</tbody>
</table>
<p>The identification strategy is based on the assumption that the optimism shock positively affects stock prices, and has no contemporaneous effect on productivity.</p>
</section>
<section id="interpretation" class="level2">
<h2 class="anchored" data-anchor-id="interpretation">Interpretation</h2>
<p>Two popular methods to interpret the SVAR model are impulse response function (IRF) and forecast error variance decomposition (FEVD) <span class="citation" data-cites="kilian2017structural">(<a href="#ref-kilian2017structural" role="doc-biblioref">Kilian and Lütkepohl 2017</a>, Chap 4)</span>.</p>
<section id="irf" class="level3">
<h3 class="anchored" data-anchor-id="irf">IRF</h3>
<p>The impulse response function (IRF) of the SVAR model is used to interpret the effect of the optimism shock on the endogenous variables. Specifically, we are interested in whether a positive optimism shock leads to a simultaneous boom in consumption and hours worked (as in the United States).</p>
<p>Mathematically, the response of the <span class="math inline">\(i\)</span>-th variable to the <span class="math inline">\(j\)</span>-th shock at horizon <span class="math inline">\(k\)</span> is given by the element at row <span class="math inline">\(i\)</span> columns <span class="math inline">\(j\)</span> of <span class="math inline">\(\mathbf{\Theta}_k\)</span>, where <span class="math inline">\(\mathbf{\Theta}_k\)</span> is defined recursively as</p>
<span class="math display">\[\begin{aligned}&\mathbf{\Theta}_{0} = \left(\mathbf{A}_{0}^{-1}\right)^{\prime},\quad\mathbf{\Theta}_{h} = \sum_{l=1}^{h}\bigl(\mathbf{A}_{\ell}\mathbf{A}_{0}^{-1}\bigr)^{\prime}\mathbf{\Theta}_{h-\ell},\quad\mathrm{} 1 \leq h \leq p,\\&\mathbf{\Theta}_{h} = \sum_{\ell=1}^{p}\bigl(\mathbf{A}_{\ell}\mathbf{A}_{0}^{-1}\bigr)^{\prime}\mathbf{\Theta}_{h-\ell},\quad\mathrm{} p < h < \infty.\end{aligned}\]</span>
</section>
<section id="fevd" class="level3">
<h3 class="anchored" data-anchor-id="fevd">FEVD</h3>
<p>The forecast error variance decomposition (FEVD) is used to quantify the relative importance of the optimism shock in explaining the variability of a <span class="math inline">\(h\)</span>-step ahead forecast of a particular variable. For example, we will examine the proportion of the variability of consumption and hours worked explained by the optimism shock.</p>
<p>Mathematically, the <span class="math inline">\(i\)</span>-th variable’s forecast error variance decomposition of the <span class="math inline">\(j\)</span>-th shock at horizon <span class="math inline">\(h\)</span> is given by</p>
<p><span class="math display">\[
\text{FEVD}_j^i(h) = \frac{\text{MSFE}_{j}^{i}(h)}{\sum_{n=1}^{N}\text{MSFE}_{j}^{n}(h)}, \quad \text{MSFE}_{j}^{i}(h) = \sum_{l=0}^{h-1} \mathbf{\Theta}_{ij,l}^{2}
\]</span></p>
</section>
</section>