Debian Codegraph @

addons/SVAR/doc/SVAR.tex

raw
1 \documentclass[a4paper,10pt]{article}
2 \usepackage{geometry,gretlhds}
3 \usepackage{url,fancyvrb}
4 \usepackage{pifont}
5 \usepackage[utf8]{inputenc}
6 \usepackage{graphicx}
7 \usepackage[authoryear]{natbib}
8 \usepackage{color}
9 \usepackage{dcolumn,amsmath}
10 \usepackage{hyperref}
11
12 \newenvironment{funcdoc}[1]
13 {\noindent\hrulefill\newline\nopagebreak\texttt{#1}%
14 \nopagebreak\par\noindent\hrulefill%
15 \nopagebreak\par\nopagebreak\smallskip\nopagebreak\par}
16 {\bigskip}
17
18 % ---------- Ripped from gretl.sty ----------------------------------------
19
20 \newcommand{\scriptname}{Listing}
21
22 \newcommand{\app}[1]{\textsf{#1}}
23 \newcommand{\cmd}[1]{\texttt{#1}}
24 \newcommand{\dtk}[1]{\texttt{\detokenize{#1}}}
25 \newcommand{\varname}[1]{\texttt{#1}}
26 \newcommand{\option}[1]{\texttt{-{}-#1}}
27 \newcommand{\ttsl}[1]{\ttfamily{\textsl{#1}}\normalfont}
28
29 \newenvironment{textcode}{\par\small\ttfamily}
30 {\normalfont\normalsize\par}
31
32 \DefineVerbatimEnvironment%
33 {code}{Verbatim}
34 {fontsize=\small, xleftmargin=1em}
35
36 \DefineVerbatimEnvironment%
37 {scode}{Verbatim}
38 {frame=lines, framesep=2ex, fontsize=\footnotesize,
39 formatcom=\color{myteal}, rulecolor=\color{mygray}}
40
41 \DefineVerbatimEnvironment%
42 {scodebit}{Verbatim}
43 {fontsize=\small, formatcom=\color{myteal}}
44
45 \DefineVerbatimEnvironment%
46 {scodebot}{Verbatim}
47 {frame=bottomline, framesep=2ex, fontsize=\small,
48 formatcom=\color{myteal}, rulecolor=\color{mygray}}
49
50 \renewcommand{\arraystretch}{1.2}
51
52 \definecolor{mygray}{rgb}{0.85,0.85,0.85}
53 \definecolor{myteal}{rgb}{0.0,0.25,0.15}
54 \definecolor{steel}{rgb}{0.03,0.20,0.45}
55
56 \def\floatpagefraction{.8}
57
58 %% add script as float (Listing)
59 \newcounter{script}[section]
60 \renewcommand \thescript
61 {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@script}
62 \def\fps@script{tbp}
63 \def\ftype@script{1}
64 \def\ext@script{los}
65 \def\fnum@script{\scriptname\nobreakspace\thescript}
66 \newenvironment{script}
67 {\@float{script}}
68 {\end@float}
69 \newenvironment{script*}
70 {\@dblfloat{script}}
71 {\end@dblfloat}
72
73 \bibliographystyle{apalike}
74 % ---------- End rip ------------------------------------------------------
75
76 \newcommand{\PrE}[1]{\ensuremath u_{#1}} % was \varepsilon_{#1} pre v1.95
77 \newcommand{\StS}[1]{\ensuremath \varepsilon_{#1}} % was u_{#1} pre v1.95
78 \newcommand{\InfSet}[1]{\ensuremath \mathcal{F}_{#1}}
79 \newcommand{\VarSym}{\ensuremath \Phi}
80 \newcommand{\IRF}[1]{\ensuremath \mathcal{I}_{#1}}
81 \newcommand{\FEVD}[1]{\ensuremath \mathcal{VD}_{#1}}
82 \newcommand{\pder}[2]{\ensuremath\frac{\partial #1}{\partial #2}}
83 \DeclareMathOperator{\VEC}{\mathrm{vec}}
84 \newlength{\irfw}
85 \newlength{\irfh}
86 \setlength{\irfw}{6.5cm}
87 \setlength{\irfh}{35mm}
88 \newcommand{\rk}[1]{\mathrm{rank}\left(#1\right)}
89
90 \hypersetup{pdftitle={The SVAR addon for gretl},
91 pdfauthor={Jack Lucchetti and Sven Schreiber},
92 colorlinks=true,
93 linkcolor=blue,
94 urlcolor=red,
95 citecolor=steel,
96 bookmarks=true,
97 bookmarksnumbered=true,
98 plainpages=false
99 }
100
101 \title{The SVAR addon for \app{gretl}}
102 \author{Jack Lucchetti and Sven Schreiber}
103 \date{October 2024}
104
105 \begin{document}
106
107 \maketitle
108
109 \tableofcontents
110
111 \clearpage
112
113 \section{Introduction}
114 \label{sec:intro}
115
116 The \texttt{SVAR} package is a collection of \app{gretl} functions to
117 estimate Structural VARs, or SVARs for short.
118
119 In the remainder of this guide, the emphasis will be put on the
120 scripting interface, which is the recommended way of using the
121 package. However, most of its features are also accessible via the
122 ``Structural VAR'' menu entry (go to \emph{Model $>$ Time Series $>$
123 Multivariate}) and the corresponding menu-driven interface. The
124 impatient reader, who already has some understanding of what a SVAR is
125 and is looking for a step-by-step guide on how to get her work done
126 quickly via point-and click methods, can consult section \ref{sec:GUI}
127 in the Appendix.
128
129 In order to establish notation\footnote{Attention: Starting in v1.95 we have
130 changed the notation in an important
131 way, by swapping the symbols for the structural shocks and the reduced-form
132 residuals (forecast errors). The reason is that most of the recent literature
133 uses $u$ for the reduced-form errors, and now we do so, too, which hopefully
134 makes everything a bit easier for users.}
135 and define a few concepts, allow us to
136 inflict on you a 2-page crash course on SVARs. In this
137 context,\footnote{The adjective ``structural'' is possibly one of the
138 most widely used and abused in econometrics. In other contexts, it
139 takes a totally different, and unrelated, meaning.} we call
140 ``structural'' a model in which we assume that the one-step-ahead
141 prediction errors $\PrE{t}$ from a statistical model can be thought of
142 as linear functions of the \emph{structural shocks} $\StS{t}$. In its
143 most general form, a structural model is the pair of equations
144 \begin{eqnarray}
145 \label{eq:one-step-ahead}
146 \PrE{t} & = & y_t - E(y_t | \InfSet{t-1}) \\
147 \label{eq:PrE-StS-AB}
148 A \PrE{t} & = & B \StS{t}
149 \end{eqnarray}
150 where $\InfSet{t-1}$ is the information set at $t-1$.
151
152 In practically all cases, the statistical model is a a finite-order
153 VAR and equation \eqref{eq:one-step-ahead} specialises to
154 \begin{equation}
155 \label{eq:VAR}
156 y_t = \mu' x_t + \sum_{i=1}^p \VarSym_i y_{t-i} + \PrE{t}
157 \qquad\mathrm{or}\qquad
158 \VarSym(L) y_t = \mu' x_t + \PrE{t}
159 \end{equation}
160 where the VAR may include an exogenous component $x_t$, which
161 typically contains at least a constant term. The above model is
162 referred to as the AB-model in Amisano-Giannini (1997).
163
164 The object of estimation are the square matrices $A$ and $B$;
165 estimation is carried out by maximum likelihood. After defining $C$ as
166 $A^{-1}B$, the relationship between prediction errors and structural
167 shocks becomes
168 \begin{equation}
169 \label{eq:PrE-StS-C}
170 \PrE{t} = C \StS{t}
171 \end{equation}
172 and under the assumption of normality the average log-likelihood can
173 be written as
174 \[
175 \mathcal{L} = \mathrm{const} - \ln |C| - 0.5 \cdot
176 \mathrm{tr}(\hat{\Sigma} (CC')^{-1})
177 \]
178
179 As is well known, the above model is under-identified and in order for
180 the log-likelihood to have a (locally) unique maximum, it is necessary
181 to impose some restrictions on the matrices $A$ and $B$. This issue
182 will be more thoroughly discussed in section \ref{sec:SVARid}; for the
183 moment, let's just say that some the elements in $A$ and $B$ have to
184 be fixed to pre-specified values. The minimum number of restrictions
185 is $n^2 + \frac{n^2 - n}{2}$. This, however, is a necessary condition,
186 but not sufficient by itself.
187
188 The popular case in which $A=I$ is called a C-model. Further, a
189 special case of the C-model occurs when $B$ is assumed to be
190 lower-triangular. This was \citeauthor{sims80}'s (\citeyear{sims80})
191 original proposal, and is sometimes called a ``recursive''
192 identification scheme. It has a number of interesting properties,
193 among which the fact that the ML estimator of $C$ is just the Cholesky
194 decomposition of $\hat{\Sigma}$, the sample covariance matrix of VAR
195 residuals. This is why many practitioners, including ourselves, often
196 use the ``recursive model'' and ``Cholesky model'' phrases
197 interchangeably. This has been the most frequently used variant of a
198 SVAR model, partly for its ease of interpretation, partly for its ease
199 of estimation.\footnote{Some may say ``partly for the unimaginative
200 nature of applied economists, who prefer to play safe and maximise
201 the chances their paper isn't rejected rather than risk and be
202 daring and creative''. But who are we to judge?} In the remainder of
203 this document, a lower-triangular C model will be called a ``plain''
204 SVAR model.
205
206 If the model is just-identified, $\hat{\Sigma} (CC')^{-1}$ will be the
207 identity matrix and the log-likelihood simplifies to
208 \[
209 \mathcal{L} = \mathrm{const} - 0.5 \ln |\hat{\Sigma}| - 0.5 n
210 \]
211 Of course, it is possible to estimate constrained models by imposing
212 some extra restrictions; this makes it possible to test the
213 over-identifying restrictions easily by means of a LR test.
214
215 Except for trivial cases, like the Cholesky decomposition,
216 maximisation of the likelihood involves numerical
217 iterations. Fortunately, analytical expressions for the score, the
218 Hessian and the information matrix are available, which helps a
219 lot;\footnote{As advocated in \citeauthor{AG}, the scoring algorithm
220 is used by default, but several alternatives are available. See
221 subsection \ref{sec:algorithms} below.} once convergence has
222 occurred, the covariance matrix for the unrestricted elements of $A$
223 and $B$ is easily computed via the information matrix.
224
225 Once estimation is completed, $\hat{A}$ and $\hat{B}$ can be used to
226 compute the structural VMA representation of the VAR, which is the
227 base ingredient for most of the subsequent analysis, such as Impulse
228 Response Analysis and so forth. If the matrix polynomial $\VarSym(L)$ in
229 equation \eqref{eq:VAR} is invertible, then (assuming $x_t=0$ for ease of
230 notation), $y_t$ can be written as
231 \begin{equation}
232 \label{eq:vma}
233 y_t = \VarSym(L)^{-1}\PrE{t} = \Theta(L) \PrE{t} = \PrE{t} + \Theta_1
234 \PrE{t-1} + \cdots
235 \end{equation}
236 which is known as the VMA representation of the VAR. Note that in
237 general the matrix polynomial $\Theta(L)$ is of infinite order.
238
239 From the above expression, one can write the \emph{structural} VMA
240 representation as
241 \begin{equation}
242 \label{eq:svma}
243 y_t = C \StS{t} + \Theta_1 C \StS{t-1} + \cdots
244 = M_0 \StS{t} + M_1 \StS{t-1} + \cdots
245 \end{equation}
246 From equation \eqref{eq:svma} it is immediate to compute the impulse response
247 functions:
248 \begin{equation}
249 \label{eq:IRFdef}
250 \IRF{i,j,h} = \pder{y_{i,t}}{\StS{j, t-h}} = \pder{y_{i,t+h}}{\StS{j, t}}
251 \end{equation}
252 which in this case equal simply
253 \[
254 \IRF{i,j,h} = \left[ M_h \right]_{ij}
255 \]
256 The computation of confidence intervals for impulse responses could,
257 in principle, be performed analytically by the delta method (see
258 \cite{Lut90}). However, this has two disadvantages: for a start, it is
259 quite involved to code. Moreover, the limit distribution has been
260 shown to be a very poor approximation in finite samples (see for
261 example \cite{FaBra96} or \cite{Kilian98}), so the bootstrap is almost
262 universally adopted, although in some cases it may be quite CPU-heavy.
263
264 %\pagebreak[4]
265
266 \section{C models}
267 \label{sec:Cmodel}
268 \subsection{A simple example}
269
270 As a trivial example, we will estimate a plain Cholesky model. The
271 data are taken from Stock and Watson's sample data
272 \dtk{sw_ch14.gdt}, and our VAR will include inflation and
273 unemployment, with a constant and 3 lags. Then, we will compute the
274 IRFs and their 90\% bootstrap confidence interval.\footnote{Why not
275 95\%? Well, keeping the number of bootstrap replications low is one
276 reason. Anyway, it must be said that in the SVAR literature few
277 people use 95\%. 90\%, 84\% or even 66\% are common choices.}
278
279 %\subsubsection{Gretl native \texttt{var} command}
280 In order to accomplish the above, note that we \emph{don't} need to
281 use the \texttt{SVAR} package, as a Cholesky SVAR can be handled by
282 \texttt{gretl} natively. In fact, the script shown in Table
283 \ref{InternalChol-in} does just that: runs a VAR, collects
284 $\hat{\Sigma}$ and estimates $C$ as its Cholesky decomposition.
285 Part of its output is in Table \ref{InternalChol-out}. The impulse
286 responses as computed by \texttt{gretl}'s internal command can be see
287 in Figure \ref{fig:nativeIRF}. See the Gretl User's Guide for more
288 details.
289
290 \begin{table}[htbp]
291 \begin{scode}
292 # turn extra output off
293 set verbose off
294
295 # open the data and do some preliminary transformations
296 open sw_ch14.gdt
297 genr infl = 400*ldiff(PUNEW)
298 rename LHUR unemp
299 list X = unemp infl
300
301 var 3 unemp infl
302
303 Sigma = $sigma
304 C = cholesky(Sigma)
305 print Sigma C
306 \end{scode}
307 %$
308 \caption{Cholesky example via \texttt{gretl}'s internal
309 \texttt{var} command}
310 \label{InternalChol-in}
311 \end{table}
312
313 \begin{table}[htbp]
314 \centering
315 \begin{scode}
316 VAR system, lag order 3
317 OLS estimates, observations 1960:1-1999:4 (T = 160)
318 Log-likelihood = -267.76524
319 Determinant of covariance matrix = 0.097423416
320 AIC = 3.5221
321 BIC = 3.7911
322 HQC = 3.6313
323 Portmanteau test: LB(40) = 162.946, df = 148 [0.1896]
324
325 Equation 1: u
326
327 coefficient std. error t-ratio p-value
328 --------------------------------------------------------
329 const 0.137300 0.0846842 1.621 0.1070
330 u_1 1.56139 0.0792473 19.70 8.07e-44 ***
331 u_2 -0.672638 0.140545 -4.786 3.98e-06 ***
332
333 ...
334 Sigma (2 x 2)
335
336 0.055341 -0.028325
337 -0.028325 1.7749
338
339 C (2 x 2)
340
341 0.23525 0.0000
342 -0.12041 1.3268
343 \end{scode}
344 \caption{Cholesky example via \texttt{gretl}'s internal
345 \texttt{var} command --- Output}
346 \label{InternalChol-out}
347 \end{table}
348
349 \begin{figure}[htbp]
350 \centering
351 \includegraphics{simpleC_gretl}
352 \caption{Impulse response functions for the simple Cholesky model (native)}
353 \label{fig:nativeIRF}
354 \end{figure}
355
356 %\clearpage
357
358 \subsection{Base estimation via the \texttt{SVAR} package}
359 \label{sec:baseest}
360
361 We will now replicate the above example via the \texttt{SVAR} package;
362 in order to do so, we need to treat this model as a special case of
363 the C-model, where $\PrE{t} = C \StS{t}$ and identification is
364 attained by stipulating that $C$ is lower-triangular, that is
365
366 \begin{equation}
367 \label{eq:cholesky}
368 C = \left[ \begin{array}{ll}
369 c_{11} & 0 \\ c_{12} & c_{22}
370 \end{array} \right].
371 \end{equation}
372
373 \begin{table}[htbp]
374 \begin{scode}
375 # turn extra output off
376 set verbose off
377
378 # open the data and do some preliminary transformations
379 open sw_ch14.gdt
380 genr infl = 400*ldiff(PUNEW)
381 rename LHUR unemp
382 list X = unemp infl
383 list Z = const
384
385 # load the SVAR package
386 include SVAR.gfn
387
388 # set up the SVAR
389 Mod = SVAR_setup("C", X, Z, 3)
390
391 # Specify the constraints on C
392 SVAR_restrict(&Mod, "C", 1, 2, 0)
393
394 # Estimate
395 SVAR_estimate(&Mod)
396 \end{scode}
397 \caption{Simple C-model}
398 \label{tab:simpleC-base}
399 \end{table}
400
401 Table \ref{tab:simpleC-base} shows a sample script to estimate the
402 example Cholesky model: the basic idea is that the model is contained
403 in a \app{gretl} bundle.\footnote{Bundles are containers in which a certain
404 object (a scalar, a matrix and so on) is associated to a ``key'' (a
405 string). Technically speaking, a bundle is an associative array like ``hashes''
406 in Perl or ``dictionaries'' in Python. Fore more info, you'll want to take a
407 look at the Gretl User's Guide, section 11.7.} In this example,
408 the bundle is called \texttt{Mod}, but it can of course take any valid
409 \texttt{gretl} identifier.
410
411 After performing the same preliminary steps as in the example in Table
412 \ref{InternalChol-in}, we load the package and use the
413 \dtk{SVAR_setup} function, which initialises the model and sets up
414 a few things. This function takes 4 arguments:
415 \begin{itemize}
416 \item a string, with the model type (\texttt{"C"} in this example);
417 \item a list containing the endogenous variables $y_t$;
418 \item a list containing the exogenous variables $x_t$ (may be
419 \texttt{null});
420 \item the VAR order $p$.
421 \end{itemize}
422
423 Once the model is set up, you can specify which elements you want to
424 constrain to achieve identification: in fact, the key ingredient in a
425 SVAR is the set of constraints we put on the structural
426 matrices. \texttt{SVAR} handles these restrictions via their implicit
427 form representation $R \theta = d$. As an example, the constraints
428 for the simple case we're considering here can be written in implicit
429 form as
430 \[
431 R \VEC C = d
432 \]
433 where $R = \left[ 0, 0, 1, 0 \right]$ and $d=0$.
434
435 There are several ways to constrain a model: the easiest way is to use
436 the \dtk{SVAR_restrict} function, which should be enough in most
437 cases; for alternatives, jump to section \ref{sec:OtherConstraints}. A
438 complete description of the the \dtk{SVAR_restrict} function can
439 be found in appendix \ref{sec:syntax}; suffice it to say here that the
440 result of the function
441 \begin{code}
442 SVAR_restrict(&Mod, "C", 1, 2, 0)
443 \end{code}
444 is to ensure that $C_{1,2} = 0$ (see eq.~\ref{eq:cholesky}).
445
446 The next step is estimation, which is accomplished via the
447 \dtk{SVAR_estimate} function, which just takes one argument, the
448 model to estimate. The output of the \dtk{SVAR_estimate} function
449 is shown below:\footnote{For compatibility with other packages,
450 $\hat{\Sigma}$ is estimated by dividing the cross-products of the
451 VAR residuals by $T-k$ instead of $T$; this means that the actual
452 figures will be slightly different from what you would obtain by
453 running \texttt{var} and then \texttt{cholesky(\$sigma)}.} note
454 that, as an added benefit, we get asymptotic standard errors for the
455 estimated parameters (estimated via the information
456 matrix).\footnote{You may feel surprised by the fact that in our
457 example the $z$-statistics for two elements of the $C$ matrix are
458 exactly the same. This is no coincidence: in short, the reason why
459 this happens is that the parameter covariance matrix is computed
460 from the information matrix, which is a function of $C$ itself
461 \citep[see][for more details]{AG}. On the other hand, the test
462 shouldn't be taken literally, as under the null hypothesis
463 $C_{11} = 0$ or $C_{22} = 0$ the covariance matrix would become
464 singular, and all the relevant asymptotic theory would break
465 down. To be on the safe side, just take the $z$ values as
466 descriptive statistics in these cases.}
467
468 \begin{code}
469 Unconstrained Sigma:
470 0.05676 -0.02905
471 -0.02905 1.82044
472
473 coefficient std. error z-stat p-value
474 --------------------------------------------------------
475 C[ 1; 1] 0.238243 0.0131548 18.11 2.62e-73 ***
476 C[ 2; 1] -0.121939 0.105142 -1.160 0.2461
477 C[ 1; 2] 0.00000 0.00000 NA NA
478 C[ 2; 2] 1.34371 0.0741942 18.11 2.62e-73 ***
479 \end{code}
480
481 At this point, the model bundle contains all the quantities that will
482 need to be accessed later on, including the structural VMA
483 representation \eqref{eq:svma}, which is stored in a matrix called
484 \texttt{IRFs} which has $h$ rows and $n^2$ columns. Each row $i$ of
485 this matrix is $\VEC(M_i)'$, so if you wanted to retrieve the IRF for
486 variable $m$ with respect to the shock $k$, you'd have to pick its
487 $[(k-1)\cdot n + m]$-th column.
488
489 The number of rows $h$ is closely related to the ``horizon''. The function
490 \dtk{SVAR_setup} initialises automatically the horizon to 24 for
491 monthly data and to 20 for quarterly data. To change it, you just
492 assign the desired value to the \texttt{horizon} element of the
493 bundle, as in
494 \begin{code}
495 Mod.horizon = 40
496 \end{code}
497 (Since the contemporaneous impact effect is also part of the IRFs, the
498 matrix will have one more row than this horizon specification.)
499 Clearly, this adjustment has to be done \emph{before} the
500 \dtk{SVAR_estimate} function is called.
501
502 More details on the internal organisation of the bundle can be
503 found in section \ref{sec:bundle_struct} in the appendix. Its contents
504 can be accessed via the ordinary \app{gretl} syntactic constructs for
505 dealing with bundles. For example, the number of observations used in
506 estimating the model is stored as the bundle member \texttt{T}, so
507 if you ever need it you can just use the syntax \texttt{Mod.T}.
508
509 Once the model has been estimated, it becomes possible to retrieve
510 estimates of the structural shocks, via the function
511 \texttt{GetShocks}, as in:
512 \begin{code}
513 series foo = GetShock(&Mod, 1)
514 series bar = GetShock(&Mod, 2)
515 \end{code}
516 If we append the two lines above to example \ref{tab:simpleC-base},
517 two new series will be obtained. The formula used is nothing but
518 equation \eqref{eq:PrE-StS-C} in which the VAR residuals are used in
519 place of $\PrE{t}$.
520
521 \bigskip
522
523 \textbf {Warning:} If you are working on a subsample of your dataset,
524 keep in mind that the SVAR package follows a different convention than
525 \app{gretl} for handling the actual start of your sample. Ordinary
526 \app{gretl} commands, such as \cmd{var}, will use data prior to your
527 subsampling choice for lags, if present. The SVAR package, on the
528 contrary, will not. An example should make this clear: suppose your
529 dataset starts at 1970Q1, but you restrict your sample range only to
530 start at 1980Q1. The \app{gretl} commands
531 \begin{code}
532 smpl 1980:1 ;
533 list X = x y z
534 var 6 X
535 \end{code}
536 will estimate a VAR with 6 lags, in which the first datapoint for the
537 dependent variable will be 1980Q1 and data from 1978Q3 to 1979Q4 will
538 be used for initialising the VAR. However,
539 \begin{code}
540 smpl 1980:1 ;
541 list X = x y z
542 Mod = SVAR_setup("C", X, const, 6)
543 \end{code}
544 will estimate the same model on a different dataset: that is, the first
545 available datapoint for estimation will be 1981Q3 because data from
546 1980Q1 to 1981Q2 will be needed for lagged values of the $y_t$ variables.
547
548 \subsection{Algorithm choice}
549 \label{sec:algorithms}
550
551 Another thing you may want to toggle before calling
552 \dtk{SVAR_estimate} is the optimisation method: you do this by
553 setting the bundle element \texttt{optmeth} to some number between 0
554 and 4; its meaning is shown below:
555
556 \begin{center}
557 \begin{tabular}{rl}
558 \hline
559 \texttt{optmeth} & Algorithm \\
560 \hline
561 0 & BFGS (numerical score) \\
562 1 & BFGS (analytical score) \\
563 2 & Newton-Raphson (numerical score) \\
564 3 & Newton-Raphson (analytical score) \\
565 4 & Scoring algorithm (\textbf{default}) \\
566 \hline
567 \end{tabular}
568 \end{center}
569
570 So in practice the following code snippet
571 \begin{code}
572 Mod.optmeth = 3
573 SVAR_estimate(&Mod)
574 \end{code}
575 would estimate the model by using the Newton-Raphson method, computing
576 the Hessian by numerically differentiating the analytical score. In
577 most cases, the default choice will be the most efficient; however, it
578 may happen (especially with heavily over-identified models) that the
579 scoring algorithm fails to converge. In those cases, there's no
580 general rule. Experiment!
581
582
583 \subsection{Displaying the Impulse Responses}
584 \label{sec:IRF-FEVD}
585
586 The \texttt{SVAR} package provides a function called \texttt{IRFplot}
587 for plotting the impulse response function on your screen, with a
588 little help from our friend \texttt{gnuplot}; its syntax is relatively
589 simple. \texttt{IRFplot} requires three arguments:
590 \begin{enumerate}
591 \item The model bundle (as a pointer);
592 \item the number of the structural shock we want the IRF to;
593 \item the number of the variable we want the IRF for.
594 \end{enumerate}
595 For example,
596 \begin{code}
597 IRFplot(&Mod, 1, 1)
598 \end{code}
599
600 The function can be used in a more sophisticated way than this (see
601 later). Its output is presented in Figure
602 \ref{fig:simpleC-noboot.IRF}. As can be seen, it's very similar to the
603 one obtained by \texttt{gretl}'s native command (Figure
604 \ref{fig:nativeIRF}).
605
606 \begin{figure}[htbp]
607 \centering
608 \includegraphics[scale=0.7]{simpleC_11_noboot}
609 \caption{Impulse response functions for unemployment}
610 \label{fig:simpleC-noboot.IRF}
611 \end{figure}
612
613 By the way: you can attach labels to the structural shocks if you
614 want. Just store an array of strings with the appropriate number of
615 elements into the model bundle, under the \texttt{snames} key. For
616 example,
617 \begin{code}
618 Mod.snames = strsplit("foo bar baz")
619 \end{code}
620 If you omit this step, the structural shocks will be labelled with
621 names corresponding to the observable variables in your VAR. This
622 doesn't make particular sense in general, but it does in a triangular
623 model, in which there is a one-to-one correspondence, so we decided to
624 make this the default choice.
625
626 A word on the unit of measurement of IRFs: by their definition (see
627 equation \eqref{eq:IRFdef}), clearly their unit of measurement is
628 the same as the one for the corresponding observable variable
629 $y_{i,t}$.
630 % [old:]
631 % Given that the structural shocks are normalized to have unit
632 % variance, the conventionally used unit size innovation is at the same
633 % time a standard deviation shock.
634 % The direct impact effect in the same
635 % equation then depends on the respective diagonal element of $C$.
636 % [New:]
637 The conventional normalization of unit variances of the structural shocks
638 and of the association of shocks to equations implies that the impact of the
639 i-th structural unit size shock on the i-th variable will be just one standard
640 deviation of the i-th reduced-form error.
641 This is often referred to as a one-standard-deviation shock.
642 % [end new]
643 Sometimes, however, a different convention is adopted, and
644 people want to display IRFs graphically by normalizing the impact
645 effect $\IRF{i,i,0} = 1$.
646 This representation is often labeled as a unit shock, and the necessary division
647 by the respective standard deviation of the reduced-form errors
648 can be achieved by setting the bundle member \cmd{normalize}
649 to 1, as in
650 \begin{code}
651 Mod.normalize = 1
652 \end{code}
653 before calling \cmd{IRFplot}. Setting it back to its default value of
654 0 will restore standard behavior.
655
656 \subsection{Bootstrapping}
657 \label{sec:bootstrap}
658
659 \begin{table}[htbp]
660 \begin{scode}
661 bfail = SVAR_boot(&Mod, 1024, 0.90)
662
663 loop i = 1..2
664 loop j = 1..2
665 sprintf fnam "simpleC_%d%d.pdf", i, j
666 IRFsave(fnam, &Mod, i, j)
667 end loop
668 end loop
669 \end{scode}
670 \caption{Simple C-model (continued)}
671 \label{tab:simpleC-IRF}
672 %$
673 \end{table}
674
675 The next step is computing bootstrap-based confidence intervals for
676 the estimated coefficients and, more interestingly, for the impulse
677 responses: as can be seen in Table \ref{tab:simpleC-IRF}, this task is
678 given to the \dtk{SVAR_boot} function, which takes as arguments
679 \begin{enumerate}
680 \item The model bundle pointer;
681 \item the required number of bootstrap replications (1024
682 here), which can be omitted if the default value of 2000 is
683 satisfactory;\footnote{There's a hard limit at 16384 at the moment;
684 probably, it will be raised in the future. However, unless your
685 model is very simple, anything more than that is likely to take
686 forever and melt your CPU.}
687 \item the desired size of the confidence interval $\alpha$ (with a default
688 of 0.9 or 90\% coverage probability, so it could have been omitted in the
689 example above).
690 \end{enumerate}
691
692 For further optional arguments see below and the function reference in the
693 appendix.
694 The function outputs a scalar, which keeps track of how many bootstrap
695 replications failed to converge (none here). Note that this procedure
696 may be quite CPU-intensive.
697
698 The function can also return in output a table similar to the output
699 to \texttt{Cmodel}, which is used to display the bootstrap means and
700 standard errors of the parameters:
701 \begin{code}
702 Bootstrap results (1024 replications)
703 coefficient std. error z p-value
704 ---------------------------------------------------------
705 C[ 1; 1] 0.232146 0.0183337 12.66 9.57e-37 ***
706 C[ 2; 1] -0.114610 0.143686 -0.7976 0.4251
707 C[ 1; 2] 0.00000 0.00000 NA NA
708 C[ 2; 2] 1.30234 0.0853908 15.25 1.61e-52 ***
709
710 Failed = 0, Time (bootstrap) = 20.24
711 \end{code}
712 This can be achieved by supplying a zero fourth argument to the
713 \dtk{SVAR_boot} function, as in
714 \begin{code}
715 bfail = SVAR_boot(&Mod, 1024, 0.90, 0)
716 \end{code}
717
718 Once the bootstrap is done, its results are stored into the bundle for
719 later use: upon successful completion, the model bundle will
720 contain another bundle called
721 \texttt{bootdata}. This contains some information on the bootstrap
722 details, such as the confidence interval $\alpha$ and others; in
723 addition, it will contain three matrices in which each column is one
724 of the $n^2$ IRFs, and the rows contain
725 \begin{enumerate}
726 \item the lower limit of the confidence interval in the
727 \dtk{lo_cb} matrix;
728 \item the upper limit of the confidence interval in the
729 \dtk{hi_cb} matrix;
730 \item the medians in the \texttt{mdns} matrix.
731 \end{enumerate}
732 where $h$ is the IRF horizon.
733
734 In practice, the bootstrap results may be retrieved as follows (the
735 medians in this example):
736 \begin{code}
737 bfail = SVAR_boot(&Mod, 1024, 0.90)
738 scalar h = Mod.horizon
739 bundle m = Mod.bootdata
740 matrix medians = m.mdns
741 \end{code}
742
743 However, if you invoke \texttt{IRFplot()} after the bootstrap, the
744 above information will be automatically used for generating the
745 graph. In this case, you may supply \texttt{IRFplot()} with a fourth
746 argument, an integer from 0 to 2, to place the legend to the right of
747 the plot (value: 1), below it (value: 2) or omit it altogether (value:
748 0). The default, which applies if you omit the parameter, is 1.
749
750 Another \texttt{SVAR} function, \texttt{IRFsave()}, is used to
751 store plots the impulse responses into graphic files files for later
752 use;\footnote{The format is dictated by the extension you use for the
753 output file name: since this job is delegated to \texttt{gnuplot},
754 all graphical formats that \texttt{gnuplot} supports are available,
755 including pdf, PostScript (via the extension \texttt{ps}), PNG (via
756 the extension \texttt{png}) or Scalable Vector Graphics (via the
757 extension \texttt{svg}). } its arguments are the same as
758 \texttt{IRFplot()}, except that the first argument must contain a
759 valid filename to save the plot into. In the above example, this
760 function is used within a loop to save all impulse responses in one
761 go. The output is shown in Figure \ref{fig:simpleC.IRF}.
762
763 \begin{figure}[htbp]
764 \centering
765 \begin{tabular}{cc}
766 \includegraphics[width=\irfw, height=\irfh]{simpleC_11} &
767 \includegraphics[width=\irfw, height=\irfh]{simpleC_12} \\
768 \includegraphics[width=\irfw, height=\irfh]{simpleC_21} &
769 \includegraphics[width=\irfw, height=\irfh]{simpleC_22}
770 \end{tabular}
771 \caption{Impulse response functions for the simple Cholesky model}
772 \label{fig:simpleC.IRF}
773 \end{figure}
774
775 The default method for performing the bootstrap is the the most
776 straightforward residual-based bootstrap, that is the one put forward
777 by \cite{Runkle87}.
778
779 As an alternative, one may use bias-correction, which comes in two
780 flavors, both inspired by the procedure known as
781 ``bootstrap-after-bootstrap'' \citep{Kilian98}.
782 % Comment by Sven:
783 % I don't think we have to belittle our bias correction by saying
784 % that "fancy" alternatives are not implemented. Following our discussion,
785 % those are not sooo fancy, after all. So I commented out the footnote.
786 %\footnote{None of the
787 % fancier alternatives listed, for example, in \cite{Brug06} are
788 % available. They are planned, though.}
789
790 The one which corresponds more closely to \citeauthor{Kilian98}'s
791 procedure is what what we call the ``Full'' variant; The ``Partial''
792 variant applies the bias correction only for adjusting the VAR
793 coefficients used for generating the bootstrap replications, but
794 \emph{not} for computing the VMA representation. The interested user
795 may want to experiment with both.
796
797 The ``Partial'' and ``Full'' variant may either be enabled by setting the
798 bundle member \texttt{biascorr} to 1 and 2, respectively, before
799 calling \dtk{SVAR_boot}. For an example, look at the example file
800 \dtk{bias_correction.inp}. Alternatively, that choice can be specified
801 as the final (sixth) argument when calling \dtk{SVAR_boot}.
802
803 Another bootstrap choice which can either be specified before the call to
804 \dtk{SVAR_boot} or directly in that call is to use the so-called
805 \emph{wild} bootstrap, or the residual-based moving blocks bootstrap (MBB)
806 proposed by \cite{BrugJenTrenk16}.
807 As regards the wild bootstrap, instead of resampling the residuals to create
808 a new draw of artificial
809 bootstrap data, for each time period $t$ it takes the original
810 estimated residual vector and multiplies it by a random number $w_t$
811 with mean 0 and variance 1. This procedure is able to account for
812 several forms of heteroskedasticity in the errors. For IRFs the MBB-based
813 confidence bands may have better coverage properties especially at short
814 horizons.
815 Activate any of these
816 options by setting the bundle member \texttt{boottype} to the
817 appropriate value, as per the following table.
818 \begin{center}
819 \begin{tabular}{rccl}
820 \hline
821 \texttt{boottype} & Argument in \dtk{SVAR_boot} & Distribution & Description\\
822 \hline
823 1 & \emph{resampling}, \emph{resample} & (none) & non-wild\\
824 2 & \emph{wild}, \emph{wildN} & Gaussian & $w_t \sim N(0,1)$ \\
825 3 & \emph{wildR} & Rademacher & $P(w_t = \pm 1) = 0.5$ \\
826 4 & \emph{wildM} & Mammen & $w_t = \begin{cases}
827 -1/\phi & \frac{\phi}{\sqrt{5}} \\
828 \phi & 1 - \frac{\phi}{\sqrt{5}}
829 \end{cases}$ \\
830 5 & \emph{MBB} & (none) & moving blocks (non-wild) \\
831 \hline
832 \end{tabular}
833 \end{center}
834 where $\phi$ is the golden ratio (about 1.1618).
835 The value 1 is the default and
836 implies the usual residual resampling. For example, the following invocation
837 calls for a Gaussian wild bootstrap with partial bias correction (and through the 0 in
838 fourth position activates the table printout as explained above):
839 \begin{code}
840 SVAR_boot(&Mod, 5000, 0.95, 0, "wild", 1)
841 \end{code}
842
843 Finally: if you change the \texttt{optmeth} bundle element before
844 \dtk{SVAR_boot} is called, the choice affects the estimation of
845 the bootstrap artificial models. Hence, you may use one method for the
846 real data and another method for the bootstrap, if you so desire.
847 If you use the MBB option you can also add the \texttt{movblocklen}
848 bundle element (again, before the call to \dtk{SVAR_boot}) to give a
849 positive integer that sets a non-automatic choice for the block length of the
850 bootstrap innovations; the automatic choice currently being 10\% of the
851 sample length.
852
853 \subsection{More general restrictions and a shortcut}
854 \label{sec:OtherConstraints}
855
856 The internal element of the model bundle which contains the
857 constraints for a C model is a matrix called \texttt{Rd1} and the
858 number of its rows is kept as bundle element \texttt{nc1}. This matrix
859 contains the restrictions in a C model of the form
860 \[
861 R \VEC C = d
862 \]
863 by stacking horizontally the $R$ matrix and the $d$ vector, so that a
864 matrix $R^* = [R | d ]$ is stored as \texttt{Rd1}. All the
865 \dtk{SVAR_restrict} function does is adding rows to $R^*$ and
866 checking for redundant or inconsistent restrictions.
867
868 However, if you feel like building the matrix $R^*$ via \app{gretl}'s
869 ordinary matrix functions, all you have to do is to fill up the bundle
870 elements \texttt{Rd1} and \texttt{nc1} properly before calling
871 \dtk{SVAR_estimate()}. As an example, take the script contained in
872 Table \ref{tab:simpleC-base}, where we identify our C-model via the
873 (rather silly) constraint $c_{11} = c_{12}$. The equation above would
874 specialise to
875 \[
876 [1 \quad -1 \quad 0 \quad 0 ] \VEC C = 0
877 \]
878 and all you would have to do in order to modify the script to that
879 effect would be substituting the line
880 \begin{code}
881 SVAR_restrict(&Mod, "C", 1, 2, 0)
882 \end{code}
883 with
884 \begin{code}
885 Mod.Rd1 = {1, -1, 0, 0, 0}
886 Mod.nc1 = 1
887 \end{code}
888 Estimating the resulting model would give you
889 \begin{code}
890
891 coefficient std. error z p-value
892 -------------------------------------------------------
893 C[ 1; 1] 0.230119 0.0127062 18.11 2.62e-73 ***
894 C[ 2; 1] 0.230119 0.0127062 18.11 2.62e-73 ***
895 C[ 1; 2] -0.0616835 0.0182892 -3.373 0.0007 ***
896 C[ 2; 2] 1.32947 0.0755748 17.59 2.87e-69 ***
897
898 Log-likelihood = -276.913
899 \end{code}
900 where the two first coefficients are equal, as required.
901
902 That said, in many cases a triangular, Cholesky-style specification
903 for the $C$ matrix like the one analysed in this section is all that
904 is needed. When many variables are involved, the setting of the
905 $\frac{n \times (n-1)}{2}$ restrictions via the
906 \dtk{SVAR_restrict} function could be quite boring, although
907 easily done via a loop.
908
909 For these cases, the \texttt{SVAR} package provides an alternative
910 way: if you supply the \dtk{SVAR_setup} function with the string
911 \texttt{"plain"} as its first argument, the necessary restrictions are
912 set up automatically. Thus, the example considered above in Table
913 \ref{tab:simpleC-base} could by modified by replacing the lines
914 \begin{code}
915 Mod = SVAR_setup("C", X, Z, 3)
916 SVAR_restrict(&Mod, "C", 1, 2, 0)
917 \end{code}
918 with the one-liner
919 \begin{code}
920 Mod = SVAR_setup("plain", X, Z, 3)
921 \end{code}
922 and leaving the rest unchanged. Of course, when you have two
923 variables, such as in this case, there's not much difference, but for
924 larger systems the latter syntax is much more convenient.
925
926 Another advantage is that, in this case, the solution to the
927 likelihood maximisation problem is known analytically, so no numerical
928 optimisation technique is used at all. This makes computations much
929 faster, and for example allows you to make extravagant choices on, for
930 example, the number of bootstrap replications. Hence, if your C model
931 can be rearranged as a plain triangular model, it is highly advisable
932 to do so.
933
934 \section{More on plotting}
935 \label{sec:moreplots}
936
937 Traditionally, analysis of the Impulse Response Functions has been the
938 main object of interest in the applied SVAR literature, but is by no
939 means the only one. After estimation, two more techniques are readily
940 available for inspecting the results: the Forecast Error Variance
941 Decomposition and the Historical Decomposition. Since the results from
942 these two procedures are often visualised as graphs, we will describe
943 them here.
944
945 \subsection{Plotting the FEVD}
946 \label{sec:fevdplots}
947
948 Another quantity of interest that may be computed from the structural
949 VMA representation is the Forecast Error Variance Decomposition
950 (FEVD). Suppose we want to predict the future path of the observable
951 variables $h$ steps ahead, on the basis of the information set
952 $\InfSet{t-1}$. From equations \eqref{eq:vma} and \eqref{eq:svma} one
953 obtains that
954 \[
955 y_{t+h} - \hat{y}_{t+h} = \sum_{k=0}^h \Theta_k E(\PrE{t+h-k}) =
956 \sum_{k=0}^h M_k E(\StS{t+h-k})
957 \]
958
959 Since $E(\StS{t+h-k}) = I$ by definition, the forecast error variance
960 after $h$ steps is given by
961 \[
962 \Omega_h = \sum_{k=0}^h M_k M_k'
963 \]
964 hence the variance for variable $i$ is
965 \[
966 \omega^2_i = \left[ \Omega_h \right]_{i,i} = \sum_{k=0}^h e_i' M_k M_k' e_i =
967 \sum_{k=0}^h \sum_{l=1}^n ({}_km_{i.l})^2
968 \]
969 where $e_i$ is the $i$-th selection vector,\footnote{That is, a vector
970 with zeros everywhere except for a 1 at the $i$-th element.} so
971 ${}_km_{i.l}$ is, trivially, the $i,l$ element of $M_k$. As a
972 consequence, the share of uncertainty on variable $i$ that can be
973 attributed to the $j$-th shock after $h$ periods equals
974 \[
975 \FEVD{i,j,h} =
976 \frac{\sum_{k=0}^h ({}_km_{i.j})^2 }{\sum_{k=0}^h \sum_{l=1}^n
977 ({}_km_{i.l})^2 } .
978 \]
979
980 \begin{table}[htbp]
981 \begin{scode}
982 fevdmat = FEVD(&Mod)
983 print fevdmat
984
985 FEVDplot(&Mod, 1)
986 FEVDplot(&Mod, 2)
987 \end{scode}
988 \caption{FEVD: computation and output}
989 \label{tab:FEVDprint}
990 \end{table}
991
992 As shown in Table \ref{tab:FEVDprint}, after the model has been
993 estimated, it can be passed to another function called \texttt{FEVD}
994 to compute the Forecast Error Variance Decomposition, which is
995 subsequently printed. Its usage is very simple, since it only needs
996 one input (a pointer to the model bundle); like the \cmd{IRFplot}
997 function, you can also attach an extra optional parameter at the end
998 to control the position of the legend.
999
1000 \begin{figure}[htbp]
1001 \centering
1002 \begin{tabular}{cc}
1003 \includegraphics[width=\irfw, height=\irfh]{FEVD_1} &
1004 \includegraphics[width=\irfw, height=\irfh]{FEVD_2}
1005 \end{tabular}
1006 \caption{FEVD for the simple Cholesky model}
1007 \label{fig:FEVDplot}
1008 \end{figure}
1009
1010 Since the FEVD for a particular variable is expressed in terms of
1011 shares, it is quite common to depict it graphically as a histogram,
1012 with the horizon on the x-axis. This can be accomplished rather simply
1013 in SVAR by using the specialised function \cmd{FEVDplot()}, which
1014 needs two arguments: a pointer to the model bundle and the number of
1015 the variable you want the FEVD for. Running the code in Table
1016 \ref{tab:FEVDprint} you should see two graphs similar to Figure
1017 \ref{fig:FEVDplot}.
1018
1019 For saving the output to a file, its variant \cmd{FEVDsave()} works
1020 the same, except you need an extra argument (which goes first) with
1021 the filename you choose for the output.\footnote{See also the
1022 illustration of the \cmd{IRFsave} function at Section
1023 \ref{sec:bootstrap}.}
1024
1025
1026 \subsection{Historical decomposition}
1027 \label{sec:HD}
1028
1029 \begin{table}[htbp]
1030 \begin{scode}
1031 # turn extra output off
1032 set verbose off
1033
1034 # open the data and do some preliminary transformations
1035 open sw_ch14.gdt
1036 genr infl = 400*ldiff(PUNEW)
1037 rename LHUR unemp
1038 list X = unemp infl
1039 list Z = const
1040
1041 # load the SVAR package
1042 include SVAR.gfn
1043
1044 # set up the SVAR
1045 Mod = SVAR_setup("C", X, Z, 3)
1046
1047 # Specify the constraints on C
1048 SVAR_restrict(&Mod, "C", 1, 2, 0)
1049
1050 # Estimate
1051 SVAR_estimate(&Mod)
1052
1053 # Save the historical decomposition as a list of series
1054 list HD_infl = SVAR_hd(&Mod, 2)
1055
1056 # Just plot the historical decomposition for unemployment
1057 HDplot(&Mod, 2)
1058 \end{scode}
1059 \caption{Simple C-model with historical decomposition}
1060 \label{tab:simpleC-hd}
1061 \end{table}
1062
1063 A natural extension of the FEVD concept (see
1064 sections \ref{sec:intro} and \ref{sec:IRF-FEVD}) is the so-called
1065 \emph{historical decomposition} of observed time series, which can be
1066 briefly described as follows.
1067
1068 Consider the representations \eqref{eq:VAR} and \eqref{eq:svma};
1069 clearly, if one could observe the parameters of the system (the
1070 coefficients of the $\VarSym(\cdot)$ polynomial and the matrix $\mu$) plus
1071 the sequence of structural shocks $\StS{t}$, it would be possible to
1072 decompose the observed path of the $y_t$ variables into $n + 1$
1073 distinct components: first, a purely exogenous one, incorporating the
1074 term $\mu' x_t$ plus all the feedback effects given by the lag
1075 structure $\VarSym(L)$; this is commonly termed the ``deterministic
1076 component'' (call it $d_t$). The remainder $y_t - d_t$ can be
1077 therefore thought of as the superimposition of separate contributions,
1078 given by each structural shock hitting the system at a given time. In
1079 practice, we'd think of each individual series in the system as
1080 \[
1081 y_{it} - d_{i,t} = M_{i,1}(L) \StS{1,t} + \cdots + M_{i,n}(L) \StS{n,t}
1082 \]
1083 using representation \eqref{eq:svma}.
1084
1085 Note that each element of the sum on the right-hand side of the above
1086 equation is uncorrelated (by hypothesis) of all the other ones at all
1087 leads and lags. Therefore, the contribution of each shock to the
1088 visible path of the variable $y_{it}$ is distinct from the others. In
1089 a way, historical decomposition could be considered as a particular
1090 form of counterfactual analysis: each component $M_{i,j}(L) \StS{j,t}$
1091 shows what the history of $y_{i,t}$ would have been if the $j$-th
1092 shock had been the only one affecting the system.
1093
1094 From a technical point of view, the decomposition is computed via a
1095 ``rotated'' version of the system:\footnote{I know, I know: strictly
1096 speaking, it's not a rotation; for it to be a rotation, you ought to
1097 force $C$ to be orthogonal somehow; but let's not be pedantic, OK?}
1098 pre-multiplying equation \eqref{eq:VAR} by $C^{-1}$ gives
1099 \[
1100 y^*_t = {\mu^*}' x_t + \sum_{i=1}^p \VarSym^*_i y^*_{t-i} + \StS{t}
1101 \]
1102 where $y^*_t \equiv C^{-1} y_t$ and $\VarSym^*_i \equiv C^{-1}
1103 \VarSym_i C$. This makes it trivial to compute the historical
1104 contributions of the structural shocks $\StS{t}$ to the rotated
1105 variables $y^*_t$, which are then transformed back into the original
1106 series $y_t$.
1107
1108 The decomposition above can be performed in the SVAR package using the
1109 estimated quantities by the \dtk{SVAR_hd} function, which takes two
1110 arguments: a pointer to the SVAR model and an integer, indicating
1111 which variable you want the decomposition for. Upon successful
1112 completion, it will return a list of $n+1$ series, containing the
1113 deterministic component and the $n$ separate contributions by each
1114 structural shock to the observed trajectory of the chosen
1115 variable. The name of each variable so created will be given by the
1116 \verb|hd_| prefix, plus the names of the variable and of the shock
1117 (\verb|det| for the deterministic component).
1118
1119 \begin{figure}[htbp]
1120 \centering
1121 \includegraphics[scale=0.8]{Cmodel_hd}
1122 \caption{Simple C-model example: historical decomposition plot}
1123 \label{fig:Cmodel-hd}
1124 \end{figure}
1125
1126 A traditional way to represent the outcome of historical decomposition
1127 is, again, graphical. The most common variant depicts the single
1128 contributions as histograms against time and their sum (the stochastic
1129 component $y_t - d_t$) as a continuous line. The SVAR package provides
1130 a pair of functions for plotting such a graph on screen or saving it
1131 to a file, and the go by the name of \cmd{HDplot()} and
1132 \cmd{HDsave()}, respectively. See their description in Section
1133 \ref{sec:syntax} in the appendix and Figure \ref{fig:Cmodel-hd}, which
1134 shows the historical decomposition for the unemployment series we've
1135 been using as an example in this section.
1136
1137 \section{C-models with long-run restrictions (Blanchard-Quah style)}
1138 \label{sec:BlQuah}
1139
1140 \begin{table}[htbp]
1141 \begin{scode}
1142 set verbose off
1143 include SVAR.gfn
1144 open BlQuah.gdt --frompkg=SVAR
1145 set seed 1234 # make results reproducible
1146
1147 list X = DY U
1148 list exog = const time
1149 maxlag = 8
1150
1151 # set up the model
1152 BQModel = SVAR_setup("C", X, exog, maxlag)
1153 BQModel.horizon = 40
1154
1155 # set up the long-run restriction
1156 SVAR_restrict(&BQModel, "lrC", 1, 2, 0)
1157
1158 # cumulate the IRFs for variable 1
1159 SVAR_cumulate(&BQModel, 1)
1160
1161 # set up names for the shocks
1162 BQModel.snames = defarray("Supply", "Demand")
1163
1164 # do estimation
1165 SVAR_estimate(&BQModel)
1166
1167 # retrieve the demand shocks
1168 dShock = GetShock(&BQModel, 2)
1169
1170 # bootstrap (set 'quiet' off with trailing zero arg)
1171 bfail = SVAR_boot(&BQModel, 1024, 0.9, 0)
1172
1173 # page 662
1174 IRFsave("bq_Ys.pdf", &BQModel, 1, 1)
1175 IRFsave("bq_us.pdf", &BQModel, 1, 2)
1176 IRFsave("bq_Yd.pdf", &BQModel, -2, 1)
1177 IRFsave("bq_ud.pdf", &BQModel, -2, 2)
1178
1179 # now perform historical decomposition
1180 list HDDY = SVAR_hd(&BQModel, 1)
1181 list HDU = SVAR_hd(&BQModel, 2)
1182
1183 # cumulate the effect of the demand shock on DY
1184 series hd_Y_Demand = cum(hd_DY_Demand)
1185 # reproduce Figure 8
1186 gnuplot hd_Y_Demand --time-series --with-lines --output=display
1187
1188 # reproduce Figure 10
1189 gnuplot hd_U_Demand --time-series --with-lines --output=display
1190
1191 \end{scode}
1192 \caption{Blanchard-Quah example}
1193 \label{tab:BlQuah}
1194 \end{table}
1195
1196 An alternative way to impose restrictions on $C$ is to use long-run
1197 restrictions, as pioneered by \cite{BlanQuah1}. The economic
1198 rationale of imposing restrictions on the elements of $C$ is that $C$
1199 is equal to $M_0$, the instantaneous IRF. For example, Cholesky-style
1200 restrictions mean that the $j$-th shock has no instantaneous impact on
1201 the $i$-th variable if $i<j$. Assumptions of this kind are normally
1202 motivated by institutional factors such as sluggish adjustments,
1203 information asymmetries, technical constraints and so on.
1204
1205 Long-run restrictions, instead, stem from more theoretically-inclined
1206 reasoning: in \cite{BlanQuah1}, for example, it is argued that in the
1207 long run the level of GDP is ultimately determined by aggregate supply
1208 only. Fluctuations in aggregate demand, such as those induced by
1209 fiscal or monetary policy, should affect the level of GDP only in the
1210 short term. As a consequence, the impulse response of GDP with respect
1211 to demand shocks should go to 0 asymptotically, whereas the response
1212 of GDP to a supply shock should settle to some positive value.
1213
1214 \subsection{A modicum of theory}
1215 To translate this intuition into formulae, assume that the bivariate
1216 process GDP growth-unemployment
1217 \[
1218 x_t = \left[ \begin{array}{c} \Delta Y_t \\ U_t \end{array}\right]
1219 \]
1220 is $I(0)$ (which implies that $Y_t$ is $I(1)$), and that it admits a
1221 finite-order VAR representation
1222 \[
1223 \VarSym(L) x_t = \PrE{t}
1224 \]
1225 where the prediction errors are assumed to be a linear combination of
1226 demand and supply shocks
1227 \[
1228 \left[ \begin{array}{c} \PrE{t}^{\Delta Y} \\ \PrE{t}^U \end{array}\right]
1229 =
1230 C \left[ \begin{array}{c} \StS{t}^d \\ \StS{t}^s \end{array}\right] ,
1231 \]
1232
1233 Considering the structural VMA representation
1234 \begin{eqnarray*}
1235 \left[ \begin{array}{c} \Delta Y_t \\ U_t \end{array}\right] & = &
1236 \Theta(L) \PrE{t} =
1237 \PrE{t} + \Theta_1 \PrE{t-1} + \cdots = \\
1238 & = & C \StS{t} + \Theta_1 C \StS{t-1} + \cdots =
1239 M_0 \StS{t} + M_1 \StS{t-1} + \cdots ,
1240 \end{eqnarray*}
1241 it should be clear that the impact of demand shocks on $\Delta Y_t$
1242 after $h$ periods is given by the north-west element of $M_h$. Since
1243 $x_t$ is assumed to be stationary, $\lim_{h \to \infty} \Theta_h = 0$
1244 and the same holds for $M_k$, so obviously the impact of either shock
1245 on $\Delta Y_t$ goes to 0. However, the impact of $\StS{t}$ on the % was $u_t$ pre-v1.95
1246 \emph{level} of $Y_t$ is given by the \emph{sum} of the corresponding
1247 elements of $M_h$, since
1248 \[
1249 Y_{t+h} = Y_{t-1} + \sum_{i=0}^h \Delta Y_{t+i},
1250 \]
1251 so
1252 \[
1253 \pder{Y_{t+h}}{\StS{t}^d} =
1254 \sum_{i=0}^h \pder{\Delta Y_{t+i}}{\StS{t}^d} =
1255 \sum_{i=0}^h \left[M_i\right]_{11}
1256 \]
1257 and in the limit
1258 \[
1259 \lim_{h \to \infty} \pder{Y_{t+h}}{\StS{t}^d} = \sum_{i=0}^{\infty}
1260 \pder{\Delta Y_{t+i}}{\StS{t}^d} =
1261 \sum_{i=0}^{\infty} \left[M_i\right]_{11},
1262 \]
1263
1264 In general, if $x_t$ is stationary, the above limit is finite, but
1265 needn't go to 0; however, if we assume that the long-run impact of
1266 $\StS{t}^d$ on $Y_t$ is null, then
1267 \[
1268 \lim_{k \to \infty} \pder{Y_{t+k}}{\StS{t}^d} = 0
1269 \]
1270 and this is the restriction we want. In practice, instead of
1271 constraining elements of $M_0$, we impose an implicit constraint on
1272 the whole sequence $M_i$.
1273
1274 How do we impose such a constraint? First, write $\sum_{i=0}^{\infty}
1275 \Theta_i$ as $\Theta(1)$; then, observe that
1276 \[
1277 \Theta(1) C = \sum_{i=0}^{\infty} M_i ;
1278 \]
1279 the constraint we seek is that the north-west element of $\Theta(1) C$
1280 equals 0. The matrix $\Theta(1)$ is easy to compute after the VAR
1281 coefficients have been estimated: since $\Theta(L) = \VarSym(L)^{-1}$, an
1282 estimate of $\Theta(1)$ is simply
1283 \[
1284 \widehat{\Theta(1)} = \widehat{\VarSym(1)}^{-1}
1285 \]
1286 Of course, for this to work $\VarSym(1)$ needs to be invertible. This rules
1287 out processes with one or more unit roots. The cointegrated case,
1288 however, is an interesting related case and will be analysed in section
1289 \ref{sec:SVECs}.
1290
1291 The long-run constraint can then be written as
1292 \begin{equation}
1293 \label{eq:BQlongrun}
1294 R \VEC[\Theta(1) C] = 0,
1295 \end{equation}
1296 where $R = \left[ 1, 0, 0, 0 \right]$; since
1297 \[
1298 \VEC[\Theta(1) C] = [I \otimes \Theta(1)] \VEC(C),
1299 \]
1300 the constraint can be equivalently expressed as
1301 \begin{equation}
1302 \label{BQlongrun2}
1303 \left[ \Theta(1)_{11}, \Theta(1)_{12}, 0, 0 \right] \VEC(C) =
1304 \Theta(1)_{11} \cdot c_{11} + \Theta(1)_{12} \cdot c_{21} = 0.
1305 \end{equation}
1306 Note that we include in $R$ elements that, strictly speaking, are not
1307 constant, but rather functions of the estimated VAR parameters. Bizarre
1308 as this may seem, this poses no major inferential problems under a
1309 suitable set of conditions (see \cite{AG}, section 6.1).
1310
1311 \begin{table}[htbp]
1312 \begin{scode}
1313 coefficient std. error z p-value
1314 ---------------------------------------------------------
1315 C[ 1; 1] 0.0575357 0.0717934 0.8014 0.4229
1316 C[ 2; 1] 0.217542 0.0199133 10.92 8.80e-28 ***
1317 C[ 1; 2] -0.907210 0.0507146 -17.89 1.45e-71 ***
1318 C[ 2; 2] 0.199459 0.0111501 17.89 1.45e-71 ***
1319
1320 Estimated long-run matrix (restricted)
1321 longrun (2 x 2)
1322
1323 0.50080 0.0000
1324 0.088690 3.9133
1325
1326 Log-likelihood = -202.193
1327
1328 Bootstrap results (1024 replications, 0 failed)
1329
1330 coefficient std. error z p-value
1331 --------------------------------------------------------
1332 C[ 1; 1] 0.0563995 0.340707 0.1655 0.8685
1333 C[ 2; 1] 0.184285 0.0814261 2.263 0.0236 **
1334 C[ 1; 2] -0.769799 0.109725 -7.016 2.29e-12 ***
1335 C[ 2; 2] 0.171516 0.0830117 2.066 0.0388 **
1336
1337
1338 coefficient std. error z p-value
1339 ---------------------------------------------------------------
1340 LongRun[ 1; 1] 0.544885 0.168701 3.230 0.0012 ***
1341 LongRun[ 2; 1] 0.0285569 2.89306 0.009871 0.9921
1342 LongRun[ 1; 2] 0.00000 0.00000 NA NA
1343 LongRun[ 2; 2] 4.09942 2.08718 1.964 0.0495 **
1344 \end{scode}
1345 \caption{Output for the Blanchard-Quah model}
1346 \label{tab:BlQuahOutput}
1347 \end{table}
1348
1349 \subsection{Example}
1350
1351 The way all this is handled in \texttt{SVAR} is hopefully quite
1352 intuitive: an example script is reported in Table
1353 \ref{tab:BlQuah}. After reading the data in, the function
1354 \dtk{SVAR_setup} is invoked in pretty much the same way as in
1355 section \ref{sec:Cmodel}.
1356
1357 Then, the \dtk{SVAR_restrict} is used to specify the identifying
1358 restriction. Note that in this case the code for the restriction type
1359 is \texttt{"lrC"}, which indicates that the restriction applies to the
1360 long-run matrix, so the formula \eqref{BQlongrun2} is employed. Next,
1361 we insert into the model the information that we will want IRFs for
1362 $y_t$, so those for $\Delta y_t$ will have to be cumulated. This is
1363 done via the function \dtk{SVAR_cumulate()}, in what should be a
1364 rather self-explanatory way (the number 1 refers in this case to the
1365 position of $\Delta Y_t$ in the list \texttt{X}). Finally, a cosmetic
1366 touch: we overwrite the model's default shock labels with a string array
1367 containing \texttt{"Supply"} and \texttt{"Demand"}. The shock labels
1368 are always stored in the array \texttt{snames}.
1369
1370 When a model with long-run restrictions is estimated, the resulting
1371 long-run matrix is stored in the model bundle as member \texttt{lrmat},
1372 and is also printed out by default.
1373
1374 The bootstrap is invoked by \dtk{SVAR_boot}, which however by default
1375 does not produce any additional printout. To display the results
1376 straight away set the optional fourth (trailing) argument to 0.
1377
1378 \begin{figure}[htbp]
1379 \centering
1380 %\hspace{-1cm}
1381 \begin{tabular}{cc}
1382 \includegraphics[width=\irfw, height=\irfh]{bq_Yd} &
1383 \includegraphics[width=\irfw, height=\irfh]{bq_ud} \\
1384 \includegraphics[width=\irfw, height=\irfh]{bq_Ys} &
1385 \includegraphics[width=\irfw, height=\irfh]{bq_us}
1386 \end{tabular}
1387 \caption{Impulse response functions for the Blanchard-Quah model}
1388 \label{fig:BlQuah}
1389 \end{figure}
1390
1391 In Table \ref{tab:BlQuahOutput} we reported the output to the example
1392 code in Table \ref{tab:BlQuah}, while the pretty pictures are in
1393 Figure \ref{fig:BlQuah}.\footnote{I found it impossible to reproduce
1394 Blanchard and Quah's results \emph{exactly}. I believe this is due
1395 to different vintages of the data. Qualitatively, however, results
1396 are very much the same. } Note that in the two calls to
1397 \texttt{IRFplot} which are used to plot the responses to a demand
1398 shock, the number to identify the shock is not 2, but rather -2. This
1399 is a little trick the plotting functions use to flip the sign of the
1400 impulse responses, which may be necessary to ease their interpretation
1401 (since the shocks are identified only up to their sign).
1402
1403 Note that the bottom part of the scripts uses the functions described
1404 in section \ref{sec:HD} so to replicate figures 8 (p.~664) and 10
1405 (p.~665) in the original AER article, where the historical
1406 contribution of demand shocks to output and unemployment is
1407 reconstructed. The output on your screen should be roughly similar to
1408 Figure \ref{fig:BlQuah-HD-Output}.
1409
1410 \begin{figure}[hbtp]
1411 \centering
1412 \begin{tabular}{cc}
1413 \includegraphics[width=0.45\textwidth]{bqhdy} &
1414 \includegraphics[width=0.45\textwidth]{bqhdu} \\
1415 Output & Unemployment
1416 \end{tabular}
1417 \caption{Effects of a demand shock in the Blanchard-Quah model}
1418 \label{fig:BlQuah-HD-Output}
1419 \end{figure}
1420
1421 \subsection{Combining short- and long-run restrictions}
1422 \label{sec:C-combined}
1423
1424 In the previous example, it turned out that the estimated coefficient
1425 for $c_{1,1}$ was seemingly insignificant; if true, this would mean
1426 that the supply shock has no instantaneous effect on $\Delta Y_t$; in
1427 other words, the IRF of output to supply starts from 0. Leaving the
1428 economic implications aside, from a statistical viewpoint this could
1429 have suggested an alternative identification strategy or, more
1430 interestingly, to combine the two hypotheses into one.
1431
1432 \texttt{SVAR} allows the combination of short- and long-run
1433 restrictions in C models (but not in AB models, which are very rarely used
1434 in this context). The script presented in Table \ref{tab:BlQuah} is very easy to modify
1435 to this effect: in this case, we simply need to insert the line
1436 \begin{code}
1437 SVAR_restrict(&BQModel, "C", 1, 1, 0)
1438 \end{code}
1439 somewhere between the \dtk{SVAR_setup} and the
1440 \dtk{SVAR_estimate} function.
1441 The rest is unchanged, and below is the output.
1442
1443 %\pagebreak[4]
1444
1445 \begin{code}
1446 coefficient std. error z p-value
1447 --------------------------------------------------------
1448 C[ 1; 1] 0.00000 0.00000 NA NA
1449 C[ 2; 1] -0.230192 0.0128681 -17.89 1.45e-71 ***
1450 C[ 1; 2] -0.909033 0.0508165 -17.89 1.45e-71 ***
1451 C[ 2; 2] 0.199859 0.0111725 17.89 1.45e-71 ***
1452
1453 Overidentification LR test = 0.642254 (1 df, pval = 0.422896)
1454 \end{code}
1455
1456 Note that, since this model is over-identified, \texttt{SVAR}
1457 automatically computes a LR test of the overidentifying
1458 restrictions. Of course, all the subsequent steps (bootstrapping and
1459 IRF plotting) can be performed just like in the previous example if
1460 so desired.
1461
1462 \begin{table}[htbp]
1463 \begin{scode}
1464 set verbose off
1465 include SVAR.gfn
1466 open IS-LM.gdt --frompkg=SVAR
1467
1468 list X = q i m
1469 list Z = const time
1470
1471 ISLM = SVAR_setup("AB", X, Z, 4)
1472 ISLM.horizon = 48
1473
1474 SVAR_restrict(&ISLM, "Adiag", 1)
1475 SVAR_restrict(&ISLM, "A", 1, 3, 0)
1476 SVAR_restrict(&ISLM, "A", 3, 1, 0)
1477 SVAR_restrict(&ISLM, "A", 3, 2, 0)
1478 SVAR_restrict(&ISLM, "Bdiag", NA)
1479 ISLM.snames = defarray("uIS", "uLM", "uMS")
1480 SVAR_estimate(&ISLM)
1481
1482 Amat = ISLM.S1
1483 Bmat = ISLM.S2
1484
1485 printf "Estimated contemporaneous impact matrix (x100) =\n%10.6f", \
1486 100*inv(Amat)*Bmat
1487
1488 rej = SVAR_boot(&ISLM, 2000, 0.95)
1489 IRFplot(&ISLM, 1, 2)
1490 \end{scode}
1491 \caption{Estimation of an AB model --- example from \cite{LKBook04}}
1492 \label{tab:ABmodel}
1493 \end{table}
1494
1495 \section{AB models}
1496 \label{sec:ABmodels}
1497 \subsection{A simple example}
1498
1499 AB models are more general than the C model, but more rarely used in
1500 practice. In order to exemplify the way in which they are handled in
1501 the \texttt{SVAR} package, we will replicate the example given in
1502 section 4.7.1 of \cite{LKBook04}. See Table
1503 \ref{tab:ABmodel}.
1504
1505 This is an empirical implementation of a standard Keynesian IS-LM
1506 model in the formulation by \cite{Pagan95}. The vector of endogenous
1507 variables includes output $q_t$, interest rate $i_t$ and real money
1508 $m_t$; the matrices $A$ and $B$ are
1509 \[
1510 A = \left[ \begin{array}{ccc}
1511 1 & a_{12} & 0 \\ a_{21} & 1 & a_{31} \\ 0 & 0 & 1
1512 \end{array} \right]
1513 \qquad
1514 B = \left[ \begin{array}{ccc}
1515 b_{11} & 0 & 0 \\ 0 & b_{22} & 0 \\ 0 & 0 & b_{33}
1516 \end{array} \right]
1517 \]
1518 so for example the first structural relationship is
1519 \begin{equation}
1520 \label{eq:AB-IScurve}
1521 \PrE{t}^q = -a_{12} \PrE{t}^i + \StS{t}^{IS}
1522 \end{equation}
1523 which can be read as an IS curve. The LM curve is the second
1524 relationship, while money supply is exogenous.
1525
1526 The model is set up via the function \dtk{SVAR_setup}, like in the
1527 previous section. Note, however, that in this case the model code is
1528 \texttt{"AB"} rather than \texttt{"C"}. The base VAR has 4 lags, with
1529 the constant and a linear time trend as exogenous variables. The
1530 horizon of impulse response analysis is set to 48 quarters.
1531
1532 The constraints on the matrices $A$ and $B$ can be set up quite simply
1533 by using the function \dtk{SVAR_restrict} via a special syntax
1534 construct: the line
1535 \begin{code}
1536 SVAR_restrict(&ISLM, "Adiag", 1)
1537 \end{code}
1538 sets up a system of constraints such that all elements on the diagonal
1539 of $A$ are set to 1. More precisely, \dtk{SVAR_restrict(&Model,
1540 "Adiag", x)} sets all diagonal elements of $A$ to the value $x$,
1541 unless $x$ is \texttt{NA}. In that case, all \emph{non-diagonal}
1542 elements are constrained to 0, while diagonal elements are left
1543 unrestricted; in other words, the syntax
1544 \begin{code}
1545 SVAR_restrict(&ISLM, "Bdiag", NA)
1546 \end{code}
1547 is a compact form for saying ``$B$ is diagonal''. The other three
1548 constraints are set up as usual.
1549
1550 Estimation is then carried out via the \dtk{SVAR_estimate}
1551 function; as an example, Figure \ref{fig:Dynamic-IS} shows the effect
1552 on the interest rate of a shock on the IS curve. This example also
1553 shows how to retrieve estimated quantities from the model: after
1554 estimation, the bundle elements \texttt{S1} and \texttt{S2}
1555 contain the estimated $A$ and $B$ matrices; the $C$ matrix is then
1556 computed and printed out.
1557
1558 The output is shown below:
1559
1560 \begin{code}
1561 coefficient std. error z p-value
1562 ---------------------------------------------------------
1563 A[ 1; 1] 1.00000 0.00000 NA NA
1564 A[ 2; 1] -0.144198 0.280103 -0.5148 0.6067
1565 A[ 3; 1] 0.00000 0.00000 NA NA
1566 A[ 1; 2] -0.0397571 0.155114 -0.2563 0.7977
1567 A[ 2; 2] 1.00000 0.00000 NA NA
1568 A[ 3; 2] 0.00000 0.00000 NA NA
1569 A[ 1; 3] 0.00000 0.00000 NA NA
1570 A[ 2; 3] 0.732161 0.146135 5.010 5.44e-07 ***
1571 A[ 3; 3] 1.00000 0.00000 NA NA
1572
1573
1574 coefficient std. error z p-value
1575 --------------------------------------------------------
1576 B[ 1; 1] 0.00671793 0.000473619 14.18 1.15e-45 ***
1577 B[ 2; 1] 0.00000 0.00000 NA NA
1578 B[ 3; 1] 0.00000 0.00000 NA NA
1579 B[ 1; 2] 0.00000 0.00000 NA NA
1580 B[ 2; 2] 0.00858125 0.000581359 14.76 2.63e-49 ***
1581 B[ 3; 2] 0.00000 0.00000 NA NA
1582 B[ 1; 3] 0.00000 0.00000 NA NA
1583 B[ 2; 3] 0.00000 0.00000 NA NA
1584 B[ 3; 3] 0.00555741 0.000371320 14.97 1.21e-50 ***
1585
1586 Estimated contemporaneous impact matrix (x100) =
1587 0.675666 0.034313 -0.016270
1588 0.097430 0.863073 -0.409238
1589 0.000000 0.000000 0.555741
1590
1591 Bootstrap results (2000 replications)
1592
1593 coefficient std. error z p-value
1594 ---------------------------------------------------------
1595 A[ 1; 1] 1.00000 0.00000 NA NA
1596 A[ 2; 1] -0.0909784 0.395312 -0.2301 0.8180
1597 A[ 3; 1] 0.00000 0.00000 NA NA
1598 A[ 1; 2] -0.0377229 0.228185 -0.1653 0.8687
1599 A[ 2; 2] 1.00000 0.00000 NA NA
1600 A[ 3; 2] 0.00000 0.00000 NA NA
1601 A[ 1; 3] 0.00000 0.00000 NA NA
1602 A[ 2; 3] 0.782728 0.181538 4.312 1.62e-05 ***
1603 A[ 3; 3] 1.00000 0.00000 NA NA
1604
1605
1606 coefficient std. error z p-value
1607 ---------------------------------------------------------
1608 B[ 1; 1] 0.00635862 0.000850539 7.476 7.66e-14 ***
1609 B[ 2; 1] 0.00000 0.00000 NA NA
1610 B[ 3; 1] 0.00000 0.00000 NA NA
1611 B[ 1; 2] 0.00000 0.00000 NA NA
1612 B[ 2; 2] 0.00814276 0.00111305 7.316 2.56e-13 ***
1613 B[ 3; 2] 0.00000 0.00000 NA NA
1614 B[ 1; 3] 0.00000 0.00000 NA NA
1615 B[ 2; 3] 0.00000 0.00000 NA NA
1616 B[ 3; 3] 0.00512819 0.000478826 10.71 9.14e-27 ***
1617 \end{code}
1618
1619 \begin{figure}[htbp]
1620 \centering
1621 \includegraphics{dynamic_IS}
1622 \caption{$\StS{}^{IS} \to i$}
1623 \label{fig:Dynamic-IS}
1624 \end{figure}
1625
1626 \section{Checking for identification}
1627 \label{sec:SVARid}
1628
1629 Consider equation \eqref{eq:PrE-StS-AB} again, which we reproduce
1630 here for clarity:
1631 \[
1632 A \PrE{t} = B \StS{t}
1633 \]
1634 Since the $\StS{t}$ are assumed mutually incorrelated with unit variance,
1635 the following relation must hold:
1636 \begin{equation}
1637 \label{eq:AB-Sigma}
1638 A \Sigma A' = B B'
1639 \end{equation}
1640 If $C \equiv A^{-1}B$, equation (\ref{eq:AB-Sigma}) can be written as
1641 \[
1642 \Sigma = C C'.
1643 \]
1644
1645 The matrix $\Sigma$ can be consistently estimated via the sample
1646 covariance matrix of VAR residuals, but estimation of $A$ and $B$ is
1647 impossible unless some constraints are imposed on both matrices:
1648 $\hat{\Sigma}$ contains $\frac{n (n+1)}{2}$ distinct entries; clearly,
1649 the attempt to estimate $2 n^2$ parameters violates an elementary
1650 order condition.
1651
1652 The recursive identification scheme resolves the issue by fixing $A=I$
1653 and by imposing lower-triangularity of $B$. In general, however, one
1654 may wish to achieve identification by other means.\footnote{Necessary
1655 and sufficient conditions to achieve identification are stated in
1656 \cite{RR-W-Zha10} and \cite{Bacchiocchi11}.} The most immediate way
1657 to place enough constraints on the $A$ and $B$ matrices so to achieve
1658 identification is to specify a system of linear constraints; in other
1659 words, the restrictions on $A$ and $B$ take the form
1660 \begin{eqnarray}
1661 \label{eq:ImpConstA}
1662 R_a \VEC A & = & d_a \\
1663 \label{eq:ImpConstB}
1664 R_b \VEC B & = & d_b
1665 \end{eqnarray}
1666 % So in practice the only potentially meaningful cases that are ruled
1667 % out are nonlinear restrictions and cross-matrix restrictions.
1668
1669 This setup is perhaps overly general in most cases: the restrictions
1670 that are put almost universally on $A$ and $B$ are zero- or
1671 one-restrictions, that is constraints of the form, eg, $A_{ij} = 1$. In
1672 these cases, the corresponding row of $R$ is a vector with a 1 in a
1673 certain spot and zeros everywhere else. However, generality is nice
1674 for exploring the identification problem.
1675
1676 The order condition demands that the number of restrictions is at
1677 least $2 n^2 - \frac{n (n+1)}{2} = n^2 + \frac{n (n-1)}{2}$, so for
1678 the order condition to be fulfilled it is necessary that
1679 \begin{eqnarray*}
1680 0 < & \rk{R_a} & \le n^2 \\
1681 0 < & \rk{R_b} & \le n^2 \\
1682 n^2 + \frac{n (n-1)}{2} \le & \rk{R_a} + \rk{R_b} & \le 2 n^2
1683 \end{eqnarray*}
1684
1685 For the C model, $R_a = I_{n^2}$ and $d_a = \VEC I_n$, so to satisfy
1686 the order condition $\frac{n (n-1)}{2}$ constraints are needed on on
1687 $B$: in practice, for a C model we have one set of constraints which
1688 pertain to $B$, or, equivalently in this context, to $C$:
1689 \begin{equation}
1690 \label{eq:ImpConstC}
1691 R \VEC C = d
1692 \end{equation}
1693
1694 The problem is that the order condition is necessary, but not
1695 sufficient. It is possible to construct models in which the order
1696 condition is satisfied but there is an uncountable infinity of
1697 solutions to the equation $A \Sigma A' = B B'$. If you try to estimate
1698 such a model, you're bound to hit all sorts of numerical problems
1699 (apart from the fact, of course, that your model will have no
1700 meaningful economic interpretation).
1701
1702 In order to ensure identification, another condition, called the
1703 \emph{rank} condition, has to hold together with the order
1704 condition. The rank condition is described in \cite{AG} (chapter 4 for
1705 the AB model), and it involves the rank of a certain matrix, which can
1706 be computed as a function of the four matrices $R_a$, $d_a$, $R_b$ and
1707 $d_b$. The \texttt{SVAR} package contains a function for doing just
1708 that, whose name is \dtk{SVAR_ident}.\footnote{Starting in version 1.4
1709 of the SVAR addon this identification check is carried out by default.}
1710
1711 As a simple example, let's check that the plain model is in fact
1712 identified by running a simple variation of the example contained in
1713 Table \ref{tab:simpleC-base}:
1714
1715 \begin{code}
1716 set verbose off
1717
1718 include SVAR.gfn
1719 open sw_ch14.gdt
1720
1721 genr infl = 400*ldiff(PUNEW)
1722 rename LHUR unemp
1723
1724 list X = unemp infl
1725 list Z = const
1726
1727 Mod = SVAR_setup("C", X, Z, 3)
1728 SVAR_restrict(&Mod, "C", 1, 2)
1729
1730 # Now check for identification
1731 scalar is_identified = SVAR_ident(&Mod)
1732 if is_identified
1733 printf "Whew!\n"
1734 else
1735 printf "Blast!\n"
1736 endif
1737
1738 # Re-check, verbosely
1739 scalar is_identified = SVAR_ident(&Mod, 1)
1740 \end{code}
1741
1742 The above code should produce the following output:
1743
1744 \begin{code}
1745 Order condition OK
1746 Rank condition OK
1747 Whew!
1748 Constraints in implicit form:
1749
1750 Ra:
1751 1 0 0 0
1752 0 1 0 0
1753 0 0 1 0
1754 0 0 0 1
1755
1756 da:
1757 1
1758 0
1759 0
1760 1
1761
1762 Rb:
1763 0 0 1 0
1764
1765 db:
1766 0
1767
1768 no. of constraints on A: 4
1769 no. of constraints on B: 1
1770 no. of total constraints: 5
1771 no. of necessary restrictions for the order condition = 5
1772 Order condition OK
1773 rank condition: r = 5, cols(Q) = 5
1774 Rank condition OK
1775 \end{code}
1776
1777 \section{Structural VEC Models}
1778 \label{sec:SVECs}
1779
1780 This class of models was first proposed in \cite{KPSW91}.\footnote{A
1781 very nice paper in the same vein which is also frequently cited is
1782 \cite{GoNg2001}. A compact yet rather complete analysis of the main
1783 issues in this context can be found in \cite{Lut06}.} A SVEC is
1784 basically a C-model in which the interest is centred on classifying
1785 structural shocks as permanent or transitory by exploiting the
1786 presence of cointegration.
1787
1788 Suppose we have an $n$-dimensional system with cointegration rank $r$
1789 which can be represented as a finite-order VAR $\VarSym(L) y_t =
1790 \PrE{t}$. As is well known,\footnote{See \cite{joha-book}.} the system
1791 also admits the VECM representation
1792 \begin{equation}
1793 \label{eq:VECM}
1794 \Gamma(L) \Delta y_t = \mu_t + \alpha \beta' y_{t-1} + \PrE{t}
1795 \end{equation}
1796 in which $\alpha$ and $\beta$ are $r \times n$ matrices, with $0 \le r
1797 \le n$. If $r=n$, the system is stationary; if $r=0$, the system is
1798 $I(1)$. In the intermediate cases, $r$ is said to be the
1799 \emph{cointegration rank}.
1800
1801 In all these cases, it is also possible to express $\Delta y_{t}$ as a
1802 vector moving average process
1803 \begin{equation}
1804 \label{eq:coint-VMA}
1805 \Delta y_t = C(L) \PrE{t} .
1806 \end{equation}
1807 The main consequence of cointegration for eq.~(\ref{eq:coint-VMA}) is
1808 that $C(1)$ is a singular matrix, with rank $n-r$. The most important
1809 consequence of the above for structural estimation is that the $C(1)$
1810 matrix satisfies
1811 \[
1812 C(1) \alpha = 0 ;
1813 \]
1814 Moreover, as argued in section \ref{sec:BlQuah}, the $ij$-th element
1815 of $C(1)$ can be thought of as the long-run response of $y_{i,t}$ to
1816 $\PrE{j,t}$ or, more precisely
1817 \[
1818 C(1)_{ij} = \lim_{k \to \infty} \pder{y_{i, t+k}}{\PrE{j, t}}.
1819 \]
1820 Hence, the long-run response of $y_t$ to structural shocks is easily
1821 seen (via eq.~\ref{eq:PrE-StS-C}) to be $C(1) \cdot C$.
1822
1823 Now, define a transitory shock as a structural shock that has no
1824 long-run effect on any variable: therefore, the corresponding column
1825 of $C(1) \cdot C$ must be full of zeros. But this, in turn, implies
1826 that the corresponding column of $C$ must be a linear combination of
1827 the columns of $\alpha$. Since $\alpha$ has $r$ linearly independent
1828 columns, the vector of structural shocks can contain at most $r$ transitory
1829 shocks and $n-r$ permanent ones; the \texttt{SVAR} addon follows the
1830 widespread assumption that there are indeed $r$ transitory shocks.
1831
1832 By ordering the structural shocks with the permanent ones appearing first,
1833 \[
1834 \StS{t} = \left[ \begin{array}{c} \StS{t}^p \\ \StS{t}^t \end{array}\right]
1835 \]
1836 it's easy to see that a separation of the transitory shocks from the
1837 permanent ones can be achieved by imposing that the last $r$ columns
1838 of $C$ lie in the space spanned by $\alpha$; in formulae,
1839 \begin{equation}
1840 \label{eq:SVEC-id}
1841 \alpha_{\perp}' C J = 0 ,
1842 \end{equation}
1843 where $J$ is the matrix
1844 \[
1845 J = \left[ \begin{array}{c} 0_{n-r \times r} \\
1846 I_{r\times r} \end{array}\right]
1847 \]
1848 and $\perp$ is the ``nullspace'' operator.\footnote{If $M$ is an $r
1849 \times c$ matrix, with $r>c$ and $\rk{M} = c$, then $M_{\perp}$ is
1850 some matrix such that $M_{\perp}'M = 0$. Note that $M_{\perp}$ is
1851 not unique.} Equation \eqref{eq:SVEC-id} can be expressed in vector
1852 form as
1853 \[
1854 ( J' \otimes \alpha_{\perp}' ) \VEC(C) = 0 ;
1855 \]
1856 since $\alpha_{\perp}$ has $n-r$ columns, this provides $r\cdot(n-r)$
1857 constraints of the type $R \VEC(C) = d$, that we know how to handle.
1858 Note the convention to put those equations on top where the permanent
1859 shocks occur. Sometimes this requires a manual re-ordering of the variables,
1860 especially if some of them are restricted to be weakly exogenous.
1861
1862 Since $0 < r < n$, this system of constraints is not sufficient to
1863 achieve identification, apart from the special case $n =2$, $r=1$, so
1864 in general the partition between transitory and permanent shocks must
1865 be supplemented by extra constraints. Clearly, these can be short-run
1866 constraints on both kind of shocks, but long-run constraints only make
1867 sense on permanent ones.\footnote{The SVAR addon also allows to apply
1868 further long-run constraints manually in a \texttt{SVEC} model, using the
1869 same \texttt{lrC} code as before. However, getting these right is sometimes
1870 tricky given the reduced rank of the long-run impact matrix. Sometimes, for
1871 example, the restrictions might imply a different $\alpha$ matrix from what
1872 the reduced-form estimates yielded. These complications are currently not
1873 (always) handled automatically and remain the user's responsibility. You
1874 should double-check what your long-run constraints actually mean and how
1875 they interact.}
1876
1877
1878 \subsection{Syntax}
1879 \label{sec:KPSWsyntax}
1880
1881 Fort this type of model, the model code you have to supply to
1882 \dtk{SVAR_setup} is \cmd{"SVEC"}. This means that your model is a
1883 C-model in which, however, the structural shocks will be classified as
1884 transitory or permanent, depending on the cointegration properties you
1885 assume.
1886
1887 This is an important point: \texttt{SVAR} is not meant for doing
1888 inference on the cointegration part of your model. For determining the
1889 cointegration rank of your system and estimating the cointegration
1890 $\beta$, you're on your own. Of course, you can use \app{gretl}'s
1891 in-built commands, such as \cmd{johansen} and \cmd{vecm}, or pre-set
1892 them to some theory-derived value: \texttt{SVAR} won't care, and will
1893 blindly accept the matrix $\beta$ you supply it; the cointegration
1894 rank is implicitly assumed as the number of columns of the $\beta$
1895 matrix.
1896
1897 Another piece of information you must supply separately, prior to
1898 estimation, is how you want the deterministic terms (the constant and
1899 the trend) in your model to be treated; in practice, which of the
1900 famous ``five cases'' you want to apply to your model. In fact, the
1901 constant and the trend are subject to a special treatment in this
1902 class of models, so they will be dropped from the exogenous list
1903 \texttt{X}, if present, when you call \dtk{SVAR_setup} and re-added
1904 internally if needed. Unless you have extra exogenous variables, such
1905 as centred seasonals, you might just as well leave \texttt{X} as
1906 \texttt{null}. The five cases range from the most to the least
1907 restrictive, as per Table \ref{tab:5cases}.
1908
1909 \begin{table}[htbp]
1910 \centering
1911 \begin{tabular}{rrl}
1912 \hline
1913 Code & \cmd{vecm} option & Description\\
1914 \hline
1915 1 & \option{nc} & No constant, no trend \\
1916 2 & \option{rc} & Restricted constant, no trend \\
1917 3 & & Unrestricted constant, no trend \\
1918 4 & \option{crt} & Constant, restricted trend \\
1919 5 & \option{ct} & Constant, unrestricted trend \\
1920 \hline
1921 \end{tabular}
1922 \caption{The five cases for deterministic terms in cointegrated systems}
1923 \label{tab:5cases}
1924 \end{table}
1925
1926 This is not the place for explaining the differences between the five
1927 options; if you've come this far, you probably know already. If you
1928 don't, grab any decent econometrics textbook or the \emph{Gretl User's
1929 Guide} and look for the chapter on cointegration and VECMs.
1930
1931 For injecting the necessary information into the model bundle once
1932 you've set it up, there is a dedicated function whose name is
1933 \dtk{SVAR_coint}. It takes three compulsory parameters: the SVAR
1934 model (in pointer form), the ``deterministic terms code'' and the
1935 cointegration matrix $\beta$.
1936 Next is the loading matrix $\alpha$; this argument may be omitted or
1937 equivalently passed as an empty matrix \texttt{\{\}}, in which case
1938 it will be estimated via OLS. If, on the contrary, it is not empty,
1939 then it should be a $n \times r$ matrix that will be accepted at face
1940 value. Pre-setting $\alpha$ may be useful, in some cases, to force
1941 some of the variables to be weakly exogenous. Note that the
1942 \verb!$jbeta! and \verb|$jalpha| standard gretl accessors make it
1943 painless to fetch them from a Johansen-style VECM if necessary.
1944 This also means that the coefficients of any restricted deterministic
1945 terms must be included as part of the given $\beta$ matrix in the
1946 cases 2 and 4 (sometimes called $\beta^*$ in the literature).
1947
1948 Calling this function will
1949 \begin{enumerate}
1950 \item Set up a system of constraints such that the $n-r$ permanent
1951 shocks will come first in the ordering, followed by the $r$
1952 temporary ones. The shock names will be set accordingly.
1953 \item Prepare the estimation of the VECM parameters subject to the constraints
1954 implied by the given $\beta$ (and $\alpha$, if not empty): in practice, the
1955 matrix $\Sigma$ and the parameters $\mu$ and $\Gamma_i$ in equation
1956 \eqref{eq:VECM}. Internally, later everything will be transformed into
1957 the VAR form \eqref{eq:VAR} so that the VMA representation can be computed
1958 and everything will proceed like in an ordinary C model.
1959 \end{enumerate}
1960
1961 At that point, the rest of the model can be set up as usual. This involves
1962 setting extra restrictions, but note that long-run constraints (including
1963 those implied by the properties of $\beta$ and $\alpha$) also depend on
1964 estimated autoregressive parameters. Therefore the interplay of short- and
1965 long-run constraints can only be analyzed at estimation time, not when the
1966 restrictions are specified. Switching on the identification check may in some
1967 cases help to uncover redundant or contradictory constraints.
1968
1969 In the next subsection, we will
1970 provide an extended and annotated example.
1971
1972
1973 \begin{table}[htbp]
1974 \begin{scode}
1975 1 nulldata 116
1976 2 setobs 4 1970:1
1977 3 include SVAR.gfn
1978 4
1979 5 # grab data from AWM
1980 6 join AWM.gdt YER PCR ITR
1981 7
1982 8 # transform into logs
1983 9 series y = 100 * ln(YER)
1984 10 series c = 100 * ln(PCR)
1985 11 series i = 100 * ln(ITR)
1986 12 list X = c i y
1987 13
1988 14 # find best lag
1989 15 var 8 X --lagselect
1990 16 p = 3
1991 17
1992 18 # check for the "balanced growth path" hypothesis
1993 19 johansen p X
1994 20 vecm p 2 X
1995 21 restrict
1996 22 b[1,1] = -1
1997 23 b[1,2] = 0
1998 24 b[1,3] = 1
1999 25
2000 26 b[2,1] = 0
2001 27 b[2,2] = -1
2002 28 b[2,3] = 1
2003 29 end restrict
2004 30
2005 31 # ok, now go for the real thing
2006 32 x = SVAR_setup("SVEC", X, const, p)
2007 33 matrix b = I(2) | -ones(1,2)
2008 34 SVAR_coint(&x, 3, b, {}, 1)
2009 35 x.horizon = 40
2010 36 SVAR_restrict(&x, "C", 1, 2, 0)
2011 37
2012 38 SVAR_estimate(&x)
2013 39 loop j = 1..3
2014 40 FEVDplot(&x, j)
2015 41 endloop
2016 42
2017 43 SVAR_boot(&x, 1024, 0.90)
2018 44 loop j = 1..3
2019 45 IRFplot(&x, 1, j, 2)
2020 46 endloop
2021 \end{scode}
2022 \caption{The \texttt{awm.inp} script}
2023 \label{tab:awmscript}
2024 \end{table}
2025
2026 \subsection{A hands-on example}
2027 \label{sec:KPSWexample}
2028
2029 In this example, we will go through a pseudo-replication of the
2030 simpler of the two examples presented in \cite{KPSW91}: the structure
2031 of the model will be kept the same, but we will use a different
2032 dataset. While the original article used post-WWII data for the US
2033 economy, we will use the so-called AWM dataset, which is supplied among
2034 \app{gretl}'s sample datasets. AWM stands for Area-Wide Model, and is
2035 a quarterly dataset of the Euro area, which spans the 1970-1998
2036 period. It was originally developed by \cite{AWM} but has been used in
2037 countless other benchmark studies. The script is supplied in the
2038 examples directory as \texttt{Traditional/awm.inp}, but we reproduce it here as
2039 table \ref{tab:awmscript} for your convenience.
2040
2041 The model comprises three variables, all in logs: real GDP ($y_t$),
2042 real private consumption ($c_t$) and real investment ($i_t$); these
2043 should, in theory, follow the same stochastic trend (the so-called
2044 ``balanced growth path''), so that there ought to be two cointegration
2045 relationships:
2046 \begin{eqnarray*}
2047 c_t &=& y_t + z^c_t \\
2048 i_t &=& y_t + z^i_t
2049 \end{eqnarray*}
2050
2051 The general idea of the script is: use \app{gretl}'s internal
2052 functions to estimate the VECM and test whether the ``balanced growth
2053 path'' hypothesis is in fact tenable on this particular dataset. Then,
2054 set up the structural part of the model, estimate it and do a few
2055 plots.
2056
2057 \begin{figure}[htbp]
2058 \centering
2059 \includegraphics[height=4.75cm]{awm-irfy}
2060 \includegraphics[height=4.75cm]{awm-irfc}
2061 \includegraphics[height=4.75cm]{awm-irfi}
2062 \caption{Impulse responses to a permanent shock}
2063 \label{fig:AWM-irfs}
2064 \end{figure}
2065
2066 More in detail, the script goes like this:
2067 \begin{description}
2068 \item[Lines 1--7] Create an empty quarterly dataset, populate it with
2069 the relevant variables from the \texttt{AWM.gdt} file.
2070 \item[lines 8--13] Transform the series to logarithms and group them
2071 into the list \texttt{X}.
2072 \item[lines 14--30] Run some preliminary checks: find the best lag
2073 length for the VAR, check that the cointegration rank is in fact 2
2074 and that the cointegration matrix is the one hypothesised by
2075 economic theory.
2076 \item[Line 32] Set up the SVAR object. Note the usage of the
2077 \texttt{SVEC} code.
2078 \item[Lines 33--36] Set up the cointegration infrastructure
2079 (deterministic terms, $\beta$, etcetera).
2080 \item[lines 35--36] Set the horizon for IRF computation to a higher
2081 value than the default and add an extra restriction to one of the
2082 temporary shocks to achieve identification. Here we assume that the
2083 idiosyncratic shock on investment does not affect consumption
2084 instantaneously.
2085 \item[lines 38--42] Estimate the model and plot the FEVD graphs.
2086 \item[lines 43--46] Bootstrap the model and plot the IRFs with a
2087 90\% confidence interval.
2088 \end{description}
2089
2090 A selection of the output is shown below, while Figure
2091 \ref{fig:AWM-irfs} is the equivalent of \citeauthor{KPSW91}'s figure 2
2092 (p. 820).\footnote{Note the usage of the fourth, optional parameter in
2093 the call to IRFplot to move the legend to the bottom of the figure.}
2094 Considering that the data span a different period and describe a
2095 different economy, the similarity between the original figure and the
2096 replicated one is quite remarkable.
2097
2098 \begin{code}
2099 # ok, now go for the real thing
2100 ? x = SVAR_setup("SVEC", X, const, p)
2101 ? matrix b = I(2) | -ones(1,2)
2102 Generated matrix b
2103 ? SVAR_coint(&x, 3, b, {}, 1)
2104 Unestricted constant, beta =
2105 1.00000 0.00000
2106 0.00000 1.00000
2107 -1.00000 -1.00000
2108
2109 alpha is unrestricted
2110 ? x.horizon = 40
2111 ? SVAR_restrict(&x, "C", 1, 2, 0)
2112 ? SVAR_estimate(&x)
2113 Optimization method = Scoring algorithm
2114 Unconstrained Sigma:
2115 0.29538 0.39670 0.22203
2116 0.39670 1.64419 0.55188
2117 0.22203 0.55188 0.32538
2118
2119
2120 coefficient std. error z p-value
2121 ---------------------------------------------------------
2122 C[ 1; 1] 0.485389 0.0391266 12.41 2.44e-35 ***
2123 C[ 2; 1] 1.09533 0.0948831 11.54 7.92e-31 ***
2124 C[ 3; 1] 0.516670 0.0406739 12.70 5.71e-37 ***
2125 C[ 1; 2] 0.00000 0.00000 NA NA
2126 C[ 2; 2] 0.373888 0.0245469 15.23 2.18e-52 ***
2127 C[ 3; 2] -0.211184 0.0138649 -15.23 2.18e-52 ***
2128 C[ 1; 3] 0.244504 0.0160525 15.23 2.18e-52 ***
2129 C[ 2; 3] -0.551965 0.0501828 -11.00 3.86e-28 ***
2130 C[ 3; 3] -0.117619 0.0210737 -5.581 2.39e-08 ***
2131
2132 Estimated long-run matrix
2133 longrun (3 x 3)
2134
2135 1.1036 0.0000 0.0000
2136 1.1036 0.0000 0.0000
2137 1.1036 0.0000 0.0000
2138
2139 Log-likelihood = -295.974
2140 \end{code}
2141
2142 %%%%%%%%%%%%%%%%%%%
2143 % sign restrictions
2144
2145 \section{Set-identified SVARs}\label{sec:SR}
2146
2147 Starting with version 1.9 the SVAR addon also makes it possible to
2148 estimate set-identified structural VAR models. What is currently
2149 still missing is a graphical interface and some other final bits of
2150 integration. With this new functionality there is surely also an
2151 extended potential for wrong and unsupported user input which may not
2152 always be caught properly. For example, calling some of the
2153 traditional functions when working with a set identified model may
2154 lead to breakage. This will be fixed and improved as time goes by.
2155
2156 Some artificial as well as real-life example scripts are included with
2157 SVAR to demonstrate the usage of sign restrictions and set
2158 identification in general. These are: \texttt{ChoMoreno.inp},
2159 \texttt{exotic1.inp}, \texttt{exotic2.inp},
2160 \dtk{spaghetti_plot.inp},
2161 \dtk{mixed_example.inp}, \dtk{supply_demand.inp}, \dtk{KilianMurphy_relaxed.inp}, and
2162 \dtk{Uhlig_example.inp}
2163
2164 \subsection{Notation}
2165
2166 At the risk of repeating some parts of earlier sections, here is some notation first:
2167 the reduced-form VAR is assumed to be
2168 \[
2169 y_t = \mu_t + \sum_{i=1}^p \Phi_i y_{t-1} + \PrE{t},
2170 \]
2171 where $\PrE{t} = y_t - E(y_t |F_{t-1})$ and
2172 $\Sigma \equiv E(\PrE{t} \PrE{t}')$; $F_{t-1}$ is the information set
2173 at $t-1$. The structural model can be written as
2174 \[
2175 A \PrE{t} = B \StS{t} .
2176 \]
2177 The relationship between the VAR shocks and the structural ones is,
2178 therefore,
2179 \[
2180 \PrE{t} = C \StS{t} ,
2181 \]
2182 where $C = A^{-1} B$, which entails $\Sigma = CC'$.
2183
2184 In order to write down the VMA representation, we assume that the
2185 $\Phi(L)$ polynomial is invertible, so $y_t$ can be written as
2186 $ y_t = m_t + \Theta(L) \PrE{t}$, where $\Theta(L) =
2187 \Phi(L)^{-1}$. Therefore, the structural VMA representation of the
2188 process is
2189 \begin{equation}
2190 \label{eq:structVMA}
2191 y_t = m_t + M_0 \StS{t} + M_1 \StS{t-1} + \cdots
2192 \end{equation}
2193 where $M_i = \Theta_i C$; since $\Theta_0 = I$, $M_0$ is simply equal
2194 to $C$. As for $C$, it is assumed that it can be written as
2195 \begin{equation}
2196 \label{eq:rotation}
2197 C = K Q
2198 \end{equation}
2199 where $K$ is the Cholesky decomposition of $\Sigma$ and $Q$ is an
2200 orthogonal matrix $Q'Q = I$.
2201
2202 Set identification is typically achieved by stipulating conditions on
2203 the elements of the $M_i$ matrices.
2204
2205 \subsection{Set identification}
2206
2207 The apparatus we have makes it possible to handle very general set
2208 constraints on the $M_i$ matrices, that can be expressed as
2209 $g(M_i) \in A$, where $g$ is a pretty arbitrary function and $A$ is a
2210 pretty arbitrary set. In most cases, however, identification is
2211 attained by simple \emph{sign restrictions}, that is constraints of
2212 the kind
2213 \[
2214 [M_k]_{i,j} > 0 \qquad \mathrm{or} \qquad [M_k]_{i,j} < 0
2215 \]
2216 where we're using the notation $[A]_{i,j}$ to indicate the element on row
2217 $i$ and column $j$ of the matrix $A$ and of course $k$ can be any
2218 non-negative integer. The general case may be more involved; a
2219 real-life example is provided by the ``elasticity bounds'' constraints
2220 used in \citet{KilianMurphy2014}, where you have
2221 \[
2222 a < \frac{[M_k]_{i,j}}{[M_k]_{l,j}} < b .
2223 \]
2224
2225 These constraints are often imposed for a contiguous range of lags:
2226 when $h=0$, restrictions implicitly apply to $C$, since $M_0 = C$;
2227 however, one could conceivably impose restrictions on
2228 $\underline{H} \le h \le \overline{H}$, where $\underline{H}$ should
2229 in most cases (but not always) be 0.\footnote{Something that is impossible,
2230 at the moment, is imposing cross-matrix (cross-horizon) constraints, such
2231 as, for example, $[M_0]_{i,j} > [M_1]_{i,j}$. This approach might be
2232 implemented when we become aware that it is needed or being used
2233 already.} Each restriction corresponds to an
2234 a-priori idea of the impact of the $j$-th structural shock on the
2235 $i$-th variable. Of course, the ordering of the structural shocks is
2236 arbitrary, so the user is required to make a choice here (see below).
2237
2238 \subsubsection{Sign restrictions (practicalities)}
2239
2240 After having initially set up the model bundle appropriately (see
2241 below), sign restrictions in the narrow or plain sense are specified
2242 through the \dtk{SVAR_SRplain} function.
2243
2244 The full documentation is in the appendix, but the gist is: this
2245 function gives you a way to indicate the sign of the impact that of a
2246 certain shock is assumed to have on a certain variable, and optionally
2247 over which set of lags. Internally, each call to
2248 \dtk{SVAR_SRplain} adds a row vector to the \texttt{SRest} matrix
2249 contained in the bundle referenced as the first argument; the
2250 restriction matrix is simply created by stacking these rows
2251 vertically.
2252
2253 For example, a minimal call of the function would read
2254 \begin{code}
2255 SVAR_SRplain(&mod, "price", "monetary", "+")
2256 \end{code}
2257 and it would mean that the shock named \texttt{monetary} has a
2258 positive instantaneous impact on \texttt{price}; in other words,
2259 $[M_0]_{ij} > 0$, where $i$ is the ordinal number of the variable
2260 \texttt{price} in the input list and $j$ is the ordinal number of the
2261 string \texttt{monetary} in the \texttt{snames} array inside the model
2262 bundle.
2263
2264 One could constrain non-instantaneous IRFs by using the full syntax
2265 \begin{code}
2266 SVAR_SRplain(&mod, "y", "shock", "+", len, start)
2267 \end{code}
2268 where \texttt{len} and \texttt{start} are nonegative integers. They
2269 both default to 0, so for example:
2270 \begin{code}
2271 SVAR_SRplain(&mod, "bar", "foo", "-", 3)
2272 \end{code}
2273 means that the shock named \texttt{foo} has a negative impact on the
2274 observable variable \texttt{bar} over the horizon from 0 to 3 (hence,
2275 four elements of the IRF are constrained). In practice, the number of
2276 constraints is \texttt{len}+1.
2277
2278 Finally, by indicating a starting lag for the constraint, the sign
2279 restrictions would be applied to the responses from \texttt{start} to
2280 \texttt{start}+\texttt{len}. Therefore, the code
2281 \begin{code}
2282 SVAR_SRplain(&mod, "quantity", "supply", "+", 4, 2)
2283 \end{code}
2284 means that the shock named \texttt{supply} has a positive impact on the
2285 observable variable \texttt{quantity} over the horizon from 2 to 6;
2286 again, note that the number of restricted IRFs is \texttt{len}
2287 $+1 = 5 = (6-2+1)$.
2288
2289 \subsubsection{Interval restrictions}
2290
2291 A plain sign restriction specifies an interval with upper or lower bound zero
2292 into which the impulse response is supposed to fall. A generalization of this idea is to
2293 specify an arbitrary interval with a lower or upper bound or both, none of which has
2294 to be zero. This idea was already mentioned above in the guise of ``elasticity bounds''.
2295
2296 The \dtk{SVAR_SRfull} function allows to use such restrictions, see the appendix
2297 for its documentation. These restrictions can be ``static" in the sense that they only
2298 apply to a certain horizon, for example on impact; or just like sign restrictions they
2299 can be ``dynamic" and associated with a range of horizons.
2300
2301
2302 \subsubsection{General (``exotic'') set restrictions}
2303
2304 General set restrictions are specified via the function
2305 \dtk{SVAR_SRexotic}, which takes 2 mandatory arguments and 2 optional ones
2306 (again, see the appendix).
2307
2308 The string you pass as argument \#2 must contain a valid hansl
2309 expression, in terms of a matrix whose name nust be \texttt{M},
2310 yielding a scalar. This code snippet is assumed to perform some kind
2311 of check on the elements of the matrix, the convention being that a
2312 non-zero result implies that the restriction holds. For example, the
2313 string
2314 \begin{code}
2315 string boundscheck = "abs(M[1,1]) < 0.1"
2316 \end{code}
2317 will check whether $-0.1 < [M_i]_{1,1} < 0.1$ for a certain horizon $i$
2318 which must not enter the expression, however. In order to impose
2319 this restriction on horizons 0 through 2, i.e. on $M_0, M_1$ and $M_2$,
2320 you invoke the function like this:
2321 \begin{code}
2322 string boundscheck = "abs(M[1,1]) < 0.1"
2323 SVAR_SRexotic(&mod, boundscheck, 2)
2324 \end{code}
2325
2326 If you want more restrictions, you just invoke the function several times
2327 with suitable strings as arguments.
2328
2329 % (I think the following not suitable/needed for the public: [Sven])
2330 % Internally, the exotic restrictions are stored in a bundle named
2331 % \texttt{exoticSR} inside the main model bundle, which contains a
2332 % string array (named \texttt{checks}) with the $p$ restriction strings
2333 % and a $p \times 2$ matrix called \texttt{spans} with the initial and
2334 % final period the restriction applies to (NB: \texttt{spans} is
2335 % 1-based, rather than 0-based).
2336
2337 \subsection{Mixed restrictions}
2338 \label{sec:mixed}
2339
2340 In some cases, set restrictions may be supplemented by exact restrictions on the
2341 $C$ matrix. The syntax for specifying constraints of this kind is
2342 strightforward, and is absolutely similar to the one used for C-models (see
2343 section \ref{sec:baseest}). So, for example, to set $C_{4,2} = 0$ you would
2344 insert in your script a line like
2345 \begin{code}
2346 SVAR_restrict(&Mod, "C", 4, 2, 0)
2347 \end{code}
2348 and more general constraints can be specified by suitably constructing the
2349 \texttt{Rd1} member of the model bundle.
2350
2351 Since $M_0 = C$ (see equation \ref{eq:structVMA}) these are typically used to
2352 set to 0 some instantaneous response; more sophisticated alternatives, though
2353 possible, are very seldom used in the literature.
2354
2355 Given the peculiar nature of set-based inference there are some limitations on
2356 the type of point constraints that can be specified in this context. At present,
2357 two types of restrictions are not allowed:
2358 \begin{description}
2359 \item[cross-shocks constraints]: for example, something like
2360 $C_{2,3} = C_{4,1}$ is not allowed, altough it is perfectly
2361 possible to set both elements to 0. Note that this does \emph{not}
2362 rule out constraints pertaining to the same shock on several
2363 variables. For instance, something like $C_{1,3} = C_{2,3}$: this
2364 would mean that the instantaneous impact of shock number 3 is the
2365 same for variables 1 and 2. This possibility, however, requires
2366 setting up an appropriate row of the bundle element \texttt{Rd1} by
2367 hand: see Section \ref{sec:OtherConstraints}.
2368 \item[non-zero constraints]: that is, something like $C_{i,j} = 1$; this
2369 limitation may be relaxed in the future, but we're not aware of
2370 non-zero restriction having ever been used in the literature (if
2371 anybody has evidence to the contrary, please let us know).
2372 \end{description}
2373
2374 \subsection{The workflow for set identification}
2375
2376 \begin{enumerate}
2377 \item First of all the model should be set up as usual through \dtk{SVAR_setup},
2378 but now with model code ``SR''. This automatically arranges for the reduced-form
2379 parameters to be estimated (or if you're a Bayesian: to calculate the likelihood-based
2380 ingredient to update your prior).
2381 \item However, this setup can only initialize the shock names under the key \texttt{snames}
2382 generically by copying the variable names. Thus it will normally be useful
2383 to modify some of these names with meaningful shock labels. For example:
2384 \begin{code}
2385 Mod.snames[1] = "monetary"
2386 \end{code}
2387
2388 \item Next the restrictions have to be formulated and imposed on the model,
2389 namely through any number of calls to the functions \dtk{SVAR_SRplain},
2390 \dtk{SVAR_SRfull}, or \dtk{SVAR_SRexotic}. If necessary, add point
2391 restrictions using \dtk{SVAR_restrict}.
2392
2393 \item The core of set-identified SVAR estimation happens now: a large number of
2394 random orthogonal matrices $Q$ are generated, and the IRFs are computed
2395 according to equation \eqref{eq:rotation}. If $Q$ is such that all the
2396 constraints are satisfied, those IRFs are kept as ``good''. The process goes
2397 on until the number of ``good'' draws reaches a prescribed number (typically,
2398 a few hundred).
2399
2400 The randomized drawing is performed by the function
2401 \dtk{SVAR_SRdraw}. This is the heavy number-crunching part.\footnote{With
2402 the computing power these days even that will typically not give you enough
2403 time to get coffee, unless you need a monster number of draws.} At this
2404 stage one also chooses the desired coverage level of the error bands
2405 (confidence intervals, credible sets, whatever) presumably to be plotted
2406 later. A more detailed description of what this function does is provided in
2407 section \ref{sec:SRdraw_details}, although for the precise details there's no
2408 substitute to studying the code.
2409
2410 \item Plotting; after having collected all the draws which fulfilled the imposed
2411 identification restrictions, SVAR offers two variants for the graphical
2412 representation of the results, functions again documented in the appendix:
2413 \begin{itemize}
2414 \item Standard -- these plots resemble the traditional IRF graphs and are produced
2415 by the function \dtk{SVAR_SRirf}. The centers of the
2416 IRF distributions as well as their lower and upper error bounds are calculated
2417 separately for each horizon. It is a well-known criticism that the resulting plotted
2418 lines can be a combination of very different draws, possibly distorting the impression
2419 that is conveyed by the plot. Other researchers have countered this criticism by
2420 remarking that one just needs to know what is being done. So now you know.
2421 \item Spaghetti -- this kind of plot is provided by \dtk{SVAR_spagplot} which
2422 literally gives the user everything identified by the
2423 set restrictions; each accepted draw's IRF is drawn, and one can hopefully judge
2424 whether they have the same tendency or are constantly crossing each other.
2425 \end{itemize}
2426
2427 \end{enumerate}
2428
2429 \subsection{Historical and forecast error variance decompositions}
2430
2431 The set identification methods revolve around the IRF properties of the
2432 admissible models, and several approaches to analyze and display the
2433 impulse responses have been presented. What remains to be explained
2434 is the usage of other usual types of analyses such as estimates of historical
2435 shock developments (historical decomposition, HD) and the relative contributions
2436 of the identified shocks to the dynamics of the endogenous variables (forecast
2437 error variance decomposition, FEVD).\footnote{Most of these require a fully
2438 identified model, i.e. where the number of identified shocks corresponds to
2439 the number of endogenous variables. This might be partly generalized in the
2440 future.}
2441
2442 A well-known complication in the set identification context is that by its very
2443 nature there exists no point estimate of the IRFs, but the standard HD and FEVD
2444 require unique coefficients. On a technical level, any of the accepted model draws
2445 can be chosen and thus there are many possible HD and FEVD variants. Therefore
2446 the relevant functions \dtk{SVAR_hd}, \texttt{FEVD}, and also \texttt{GetShock}
2447 (which stores the estimated historical shock realization as a gretl series into the
2448 workfile) take as an additional argument an integer as an index to pick a certain
2449 accepted model draw.
2450 For example, the \texttt{ChoMoreno.inp} example script shipped with the SVAR
2451 addon produces 256 accepted draws and its model bundle has the name ``mod''.
2452 After it is run we could in principle pick arbitrarily any draw between 1 and 256.
2453
2454 % 112th accepted draw to produce the HD
2455 % for inflation -- which is the 2nd variable in the model -- as follows:
2456
2457 % \begin{code}
2458 % list inflHD = SVAR_hd(&mod, 2, 112)
2459 % \end{code}
2460
2461 % In the same fashion we could extract the history of the demand shock (the 1st one)
2462 % by writing
2463
2464 % \begin{code}
2465 % series demandshock = GetShock(&mod, 1, 112)
2466 % \end{code}
2467
2468 % ... or retrieve the FEVD numbers with this call:
2469
2470 % \begin{code}
2471 % matrix allfevd = FEVD(&mod, 112)
2472 % \end{code}
2473
2474 However, the aim is typically to use a draw which is somehow representative of the entire
2475 model distribution. Thus the possibility of specifying a draw index manually is only offered for
2476 more flexibility as a kind of override option.
2477
2478 While it is beyond the scope of this user guide to provide a discussion of the possible conceptual
2479 approaches to find a suitable unique model among the many accepted draws, the \texttt{SVAR}
2480 addon provides the \dtk{SVAR_SRgetbest} convenience function to help with this task.
2481
2482 For example, continuing with \texttt{ChoMoreno.inp}, say you are most interested in the
2483 impulse response of inflation (\texttt{INFL}, 2nd variable) to the shock \texttt{Demand}
2484 (1st shock) not immediately, but after one quarter.
2485 That is, you want to find that accepted model which has a
2486 response of inflation to a demand impulse at lag 1 which is as close as
2487 possible to the median response across all accepted draws.
2488 The relevant call to find this model's index number would be:
2489
2490 \begin{code}
2491 SVAR_SRgetbest(&mod, "INFL", "Demand", 1, , 1)
2492 \end{code}
2493
2494 The function is documented in the appendix, but note that the first scalar argument with value 1
2495 chooses the starting IRF horizon where 0 would be equivalent to the contemporaneous impact,
2496 so here it is after one period. The following argument would determine
2497 how many of the following periods should be considered; here we do not want to consider anything
2498 beyond the first lag, so we can leave it at the default value zero and hence do not need to specify
2499 that argument. The trailing argument value 1 chooses the median as the target (0 would be
2500 the mean).\footnote{The concrete targeted number turns out to be $0.171304$. This could also
2501 be found inside the bundle with $nv=2$ and $ns=1$ (and of course $n=3$) as
2502 \texttt{mod.SRirfmeds[2, (ns-1)*n + nv]} or equivalently \texttt{mod.SRirfmeds[2, 2]}.}
2503
2504 We find that the representative model in this particular sense is the one with index 58;
2505 by construction the associated impulse response value is very close to the median, namely $0.171297$.
2506 The \dtk{SVAR_SRgetbest} function stores this index number 58 in the model bundle under the key
2507 \texttt{bestdraw}. The functions that require a unique model parametrization such as
2508 \dtk{SVAR_hd}, \texttt{FEVD}, \texttt{GetShock}, and \texttt{IRFplot}
2509 will automatically use the associated draw (unless the user overrides it with her own choice as
2510 described above). This carries over to the higher-level interface functions such that you could write
2511 calls like the following as always:
2512
2513 \begin{code}
2514 FEVDplot(&mod, 1)
2515 IRFplot(&mod, 1, 2)
2516 HDplot(&mod)
2517 \end{code}
2518
2519 Since a single accepted draw by itself does not contain any information about the parameter uncertainty,
2520 this kind of IRF plot only shows a single line without any intervals. For specially designed plots for the
2521 set-identified situation please refer to the functions \dtk{SVAR_SRirf} and \dtk{SVAR_spagplot}
2522 as explained above.
2523
2524 % end sign restrictions part
2525 %%%%%%%%%%%%%%%%%%%
2526
2527 \bibliography{SVAR}
2528
2529 \appendix
2530
2531 \pagebreak
2532
2533 \section{The GUI interface}
2534 \label{sec:GUI}
2535
2536 This section introduces the GUI interface with which most of the
2537 available calculations can be accomplished as well and which can be
2538 accessed via the \emph{Model $>$ Time Series $>$ Multivariate $>$
2539 Structural VAR}
2540 menu entry of the the graphical \app{gretl} client. While we recommend
2541 using the script interface to access the full capabilities of the SVAR
2542 package, the GUI interface may be less intimidating for less
2543 experienced users. The GUI component covers everything but
2544 \begin{enumerate}
2545 \item the SVEC case (see section \ref{sec:SVECs}) where the
2546 cointegration properties of the system are exploited for special
2547 long-run restrictions.
2548 \item Set-restricted models, described in section \ref{sec:SR}.
2549 \end{enumerate}
2550 For the GUI in the SVEC case there is a preliminary additional
2551 function package \emph{SVEC\_GUI} available on the gretl package
2552 server which uses this SVAR addon as its backend.
2553
2554 \begin{figure}[htbp]
2555 \centering
2556 \includegraphics[scale=0.5]{GUI_SVAR.png}
2557 \caption{Plain Cholesky model through the GUI interface (earlier SVAR version)}
2558 \label{fig:GUI-plain}
2559 \end{figure}
2560
2561
2562 Many important contents of the window displayed in Figure
2563 \ref{fig:GUI-plain} should be rather self-explanatory; the model type
2564 chooser, the list of endogenous VAR variables, another (optional) list
2565 of exogenous variables, the lag order, and further down the number of
2566 bootstrap replications along with the nominal bootstrap confidence
2567 level (leave the number of replications at the default value zero to
2568 skip the bootstrap), and finally the choice of the precise
2569 optimization algorithm from the drop-down menu at the bottom, where as
2570 before the scoring algorithm is the default.
2571
2572 The other function parameters will be explained now. First there are
2573 three checkboxes that specify the deterministic terms to be included
2574 in the model.\footnote{The seasonal dummies are automatically
2575 centered, which should only matter in the rather exotic case without
2576 a constant term, however.} Note that it is still possible to
2577 manually specify the deterministic terms as in the script interface,
2578 namely as part of the exogenous regressor list. Next, the
2579 \emph{horizon} parameter sets the desired maximum impulse response
2580 horizon as explained above for the script interface, and can be left
2581 at zero to invoke the default settings.
2582
2583 \subsection{Identifying constraints}
2584
2585 The two central inputs for the C and AB model types are the
2586 identifying constraints. In the SVAR GUI they must be given as pattern
2587 matrices that can only have two types of entries: Each entry with a
2588 "missing" value denotes an unrestricted element, and every entry with
2589 a valid numerical value will be restricted to just that value. You can
2590 either pre-define the pattern matrices before you call the SVAR
2591 package and then choose the corresponding name of the matrix in the
2592 drop-down menu, or you have to click on the ``+'' button next to the
2593 function argument field and specify the matrix on the spot in the
2594 following standard \app{gretl} matrix creation dialog.\footnote{Hint:
2595 with recent gretl versions it is possible to initialize the matrix
2596 to hold only missing values, by entering \texttt{na} or \texttt{nan}
2597 as the initial fill value. Then you just have to edit the actually
2598 restricted elements afterwards.} If you do not wish to restrict any
2599 of the involved matrices, just leave the function argument at the
2600 default "null" value.
2601
2602 For a C model, as indicated by the function argument labels the first
2603 restriction pattern matrix refers to the short-run restrictions, while
2604 the second pattern matrix must be used for the long-run
2605 restrictions. If you choose an AB model instead, these matrix inputs
2606 serve to hold the restrictions on B and A, respectively. Note the
2607 reversed ordering of B and A here, which reflects the fact that if A
2608 is the identity matrix then B is the same thing as the short-run
2609 restriction C matrix, so these latter two matrices belong together.
2610
2611 \subsection{Bootstrap parameters and cumulation}
2612
2613 The next checkbox after the bootstrap specification concerns the
2614 activation of the bias correction that was already explained in
2615 relation to the script interface. Following is another checkbox that
2616 activates a check for identification, see section \ref{sec:SVARid}.
2617
2618 Towards the end of the SVAR GUI window you have another matrix
2619 argument which serves to tell the package which of the impulse
2620 responses should be provided in cumulated form. You need to provide a
2621 (row or column) vector that holds the corresponding integer indices of
2622 the variables to be cumulated referring to the list of endogenous
2623 variables. Say your list of endogenous variables is ``foo baz bar''
2624 and the responses of \emph{foo} and \emph{bar} should be cumulated,
2625 then you would need to pass a vector \texttt{\{1, 3\}} (or
2626 \texttt{\{1; 3\}}).\footnote{This way of specifying the responses to
2627 be cumulated in the GUI of SVAR may change in the future, perhaps by
2628 using another list of variables instead.} Note that you can type an
2629 expression of this sort into the matrix entry box directly, as shown in
2630 Figure~\ref{fig:matrix-entry}.
2631
2632 \begin{figure}[htbp]
2633 \centering
2634 \includegraphics[scale=0.5]{dialog_mat.png}
2635 \caption{Entering a matrix specification directly}
2636 \label{fig:matrix-entry}
2637 \end{figure}
2638
2639 \subsection{The output window}
2640
2641 After specifying all necessary function arguments and clicking OK, you
2642 are presented---possibly after having to wait for the CPU intensive
2643 bootstrap to finish---with a first output window holding the basic
2644 estimation results, for example of the C matrix or of the A and B
2645 matrices. If the provided restrictions are over-identifying the
2646 corresponding LR test result is also printed out.
2647
2648 In the SVAR output window (see Figure~\ref{fig:GUI-output} below)
2649 three toolbar buttons deserve special mention: The ``Save'' button
2650 allows you to save the printed output, but more importantly you can
2651 also save the entire bundle that was returned by the SVAR package as
2652 an icon (element) of the current \app{gretl} session. When you open
2653 (view) the bundle again later, some information about the model
2654 specification will also be shown. (And the session can in turn later
2655 be saved into a session file.) Next, for saving only selected members
2656 of the SVAR bundle there is the ``Save bundle content''
2657 button. Finally you have the ``Graph'' button which provides the
2658 access to the central SVAR analyses, namely the impulse responses, the
2659 error variance as well as the historical decompositions.
2660
2661 \subsection{An example}
2662
2663 For example, suppose we wanted to estimate a C model like the one used
2664 as example so far, with the only difference that we want the $C$
2665 matrix to be \emph{upper} triangular, rather than lower
2666 triangular. Via a script, you would use the function
2667 \dtk{SVAR_restrict()}, as in
2668 \begin{code}
2669 # Force C_{2,1} to 0
2670 SVAR_restrict(&Mod, "C", 2, 1, 0)
2671 \end{code}
2672 but you can do the same via the GUI interface by using a pattern
2673 matrix, which must be a $n \times n$ matrix (that is, the same
2674 size as $C$).
2675
2676 \begin{figure}[htbp]
2677 \centering
2678 \includegraphics[scale=0.5]{TMPL.png}
2679 \caption{Template matrix}
2680 \label{fig:tmpl}
2681 \end{figure}
2682
2683 Suppose we call the pattern matrix \texttt{TMPL} and that we select
2684 the option ``Build Numerically'' (of course, with 2 rows and 2 columns
2685 in this example). When you're done, you return to the main SVAR
2686 window (be sure to select C-model as the model type). After clicking
2687 ``OK'', the results window will appear, as in
2688 Figure~\ref{fig:GUI-output}. Note that the estimated $C$ matrix is now
2689 upper triangular.\footnote{The same pattern matrix can also be used
2690 in scripting for the \dtk{SVAR_restrict()} function, since gretl 2024c.}
2691
2692 From the output window, you can save the model bundle to the Icon view
2693 by clicking on the leftmost icon\footnote{The visual appearance of the
2694 icons on your computer may be different from the one shown in Figure
2695 \ref{fig:tmpl}, as they depend on your software setup. The number
2696 and ordering of the icons, however, should be the same on all
2697 systems.} and re-use it as needed for further processing.
2698 \begin{figure}[htbp]
2699 \centering
2700 \includegraphics[scale=0.5]{Output.png}
2701 \caption{Output window}
2702 \label{fig:GUI-output}
2703 \end{figure}
2704
2705 %\appendix
2706
2707 \clearpage
2708
2709 \section{Some details of the numerical algorithm in \texttt{SVAR\_SRdraw}}
2710 \label{sec:SRdraw_details}
2711
2712 We explore the space of possible rotations via $H$ random draws from the space
2713 of rotation matrices. Once the VAR parameters ($\hat{\Phi}_i$ and
2714 $\hat{\Sigma}$) are computed, this can be done by either
2715 \begin{enumerate}
2716 \item applying the random rotation (\ref{eq:rotation}) to the Cholesky factor of
2717 $\hat{\Sigma}$, and computing the $M_i$ matrices from the $\hat{\Phi}_i$
2718 matrices, or
2719 \item sampling from the posterior distribution\footnote{The standard
2720 Normal-inverse Wishart distribution is used.} of the parameter and get new
2721 matrices $\tilde{\Sigma}$ and $\tilde{\Phi}_i$, and then compute the $M_i$
2722 matrices from those.
2723 \end{enumerate}
2724 Let's call option 1 the ``frequentist'' option and option 2 the ``Bayesian''
2725 option. However, let us be clear that option 1 uses the fixed point estimates of
2726 the reduced-form coefficients and therefore does not take parameter uncertainty
2727 into account. This current state of affairs could be generalized even within the
2728 frequentist paradigm, e.g. by adding another bootstrap layer. Furthermore,
2729 option 2 effectively applies some perturbation to the reduced-form coefficients
2730 centered around the likelihood point estimates, which essentially corresponds to
2731 a flat or uninformative Bayesian prior. Some might argue that this kind of prior
2732 is relatively close in spirit to a frequentist approach.
2733
2734 In any case, this choice corresponds to a Boolean flag which is the third
2735 argument to the \dtk{SVAR_SRdraw} function: the default, 0, is to skip the
2736 sampling from the posterior and just use the frequentist point estimates.
2737
2738 What happens inside this function? First, the relevant items from the model
2739 bundle are copied: this of course includes the VAR parameters and
2740 $\hat{\Sigma}$, but we'll also need $(X'X)^{-1}$ for the Bayesian option. Then,
2741 for each iteration:
2742
2743 \begin{enumerate}
2744 \item For the Bayesian option, first we draw from the posterior of the
2745 VAR parameters (this is where we need $(X'X)^{-1}$); in the
2746 frequentist case, we just use $\hat{\Phi}_i$ and $\hat{\Sigma}$.
2747 \item We then create a bundle containing the draw above, a generated rotation
2748 matrix $Q$ and the number of deterministic terms in the VAR; this bundle is
2749 used by the \verb|gen_irfs| internal function that computes the IRFs for the
2750 simulated parameters. Note that:
2751 \begin{itemize}
2752 \item We generate the rotation matrix $Q$, but we \emph{don't} perform any
2753 kind of sign checks on its elements. If no point restriction are present, we
2754 just use the QR decomposition algorithm; otherwise, we generate the columns
2755 of $Q$ sequentially in such a way that the matrix $C$ in equation
2756 \eqref{eq:rotation} satisfies them by construction. Our algorithm is
2757 comparable to the one described in \cite{AriasEtAl2018}.
2758 \item we generate one $Q$ per iterations, so the number that
2759 \citet{KilianLuetkepohl2017book} call $N$ on page\footnote{This is the page
2760 of the official CUP version. In the ``unofficial'' pdf file that has been
2761 circulating for a while it's on page 432.} 441 (Step 2) is fixed at 1
2762 (this wouldn't be difficult to change if needed);
2763 \item we compute all the IRFs up to the desired horizon even if we do not need
2764 all of them for checking the sign restrictions. (Perhaps we could optimise
2765 this, but the computational gain would likely be marginal.)
2766 \end{itemize}
2767 \item Now we check if the generated $M_i$ matrices satisfy the restrictions;
2768 this entails three steps:
2769 \begin{enumerate}
2770 \item For each set of sign restrictions, we generate a row vector with $n$
2771 elements telling us if that particular restriction is met by each of the
2772 rotated shocks. The convention is that 1 means ``yes'', 0 means ``no'' and
2773 -1 means ``yes, but the sign of the shock must be flipped''.
2774 \item All these row vectors are coalesced into a matrix and passed to the
2775 \verb|check_id| function, that checks if there is a sensible way to map
2776 the rotated shocks to the desired structural shocks. Note that this
2777 function returns a matrix in which there could be more than one candidate
2778 for each shock. The internal function \texttt{normalize} takes care of
2779 establishing a one-to-one correspondence; if the sign restrictions are
2780 met, then we reshuffle the IRFs taking care of the structural shocks
2781 desired ordering and possible sign flips.
2782 \item At this point --if the draw is still considered good to go-- the $M_i$
2783 matrices should contain the IRFs in the appropriate positions:
2784 $[M_k]_{i,j}$ contains the impact at $k$ steps of the $j$-th shock to the
2785 $i$-th observable, where the ordering of the observables is the one
2786 implicit in the input list and the order of the shocks is the one given by
2787 the \texttt{snames} bundle element. Therefore, we can proceed with
2788 checking the exotic restrictions (if any).
2789 \item Checking the \emph{exotic} restrictions is done in a conceptually
2790 simple way: Provided that the current draw has not failed any of the
2791 imposed restrictions up to this point, the derived impulse responses are
2792 internally relabeled as ``M" and each of the supplied exotic restriction
2793 expression is applied verbatim to the IRF matrix $M$, separately for each
2794 of the specified horizons.
2795 \item{} [tba: explain check of super-exotic restrictions]
2796
2797 \end{enumerate}
2798 \item If all the restrictions are met, we accept the draw and store the
2799 results away as an element of the bundle array that we eventually
2800 return. Otherwise the draw is discarded.
2801 \end{enumerate}
2802
2803 \clearpage
2804
2805 \section{Alphabetical list of (public) functions}
2806 \label{sec:syntax}
2807
2808 The name of the model bundle which is passed around in pointer form between
2809 most of these functions is determined by the user when the bundle is assigned
2810 from a call to \dtk{SVAR_setup}. To avoid confusion, it is assumed in the
2811 following that that bundle is named \texttt{"Smod"} (although the internal
2812 name of the argument inside the local function scope is of course arbitrary
2813 and need not be harmonized).
2814
2815 (The function signatures below are given as-is with the asterisk ``*'' denoting
2816 the pointer argument, but remember that in \emph{gretl}'s language \emph{hansl}
2817 in a function call the pointer has to be
2818 specified with an ampersand character, as in ``\verb|&Smod|''.)
2819
2820
2821 \begin{funcdoc}{FEVD (bundle *Smod, int drawix[0])}
2822 \noindent Returns an $h \times n^2$ matrix with
2823 the Forecast Error Variance Decomposition from the
2824 structural IRFs, as contained in the model \texttt{Smod}.
2825 The FEVD for variable $k$ is the block of
2826 columns from $(k-1) n + 1$ to $k n$ (where $n$ is the number of
2827 variables in the VAR).
2828
2829 The \texttt{drawix} argument can typically be omitted, see \texttt{GetShock}.
2830 \end{funcdoc}
2831
2832 \begin{funcdoc}{FEVDplot (bundle *Smod, int vnum[0], int keypos[0:2:1], int drawix[0])}
2833 \noindent Plots on screen the Forecast Error Variance Decomposition for a
2834 variable.
2835
2836 \noindent Arguments:
2837 \begin{enumerate}
2838 \item A bundle holding the model.
2839 \item The progressive number of the variable (0 means all).
2840 \item The position of the legend, if any (optional; default = right).
2841 \end{enumerate}
2842
2843 The \texttt{drawix} argument can typically be omitted, see \texttt{GetShock}.
2844 \end{funcdoc}
2845
2846 \begin{funcdoc}{FEVDsave (string outfilename, bundle *Smod, int vnum[0], int keypos[0:2:1], \\
2847 int drawix[0])}
2848 \noindent Saves the Forecast Error Variance Decomposition for a variable to a
2849 graphic file, whose format is identified by its extension.
2850
2851 \noindent Arguments:
2852
2853 \begin{enumerate}
2854 \item The graphic file name.
2855 \item A bundle holding the model.
2856 \item The progressive number of the variable (0 means all).
2857 \item The position of the legend, if any (optional; default = right).
2858 \end{enumerate}
2859
2860 The \texttt{drawix} argument can typically be omitted, see \texttt{GetShock}.
2861 \end{funcdoc}
2862
2863 \begin{funcdoc}{GetShock (bundle *Smod, int i[1], int drawix[0])}
2864 \noindent Equivalent to the recommended \dtk{SVAR_getshock}, but with an alternative
2865 interface:
2866 Instead of specifying the name of the shock of interest its position in the
2867 names of shocks array (\texttt{Smod.snames}) must be given in \texttt{i}.
2868 \end{funcdoc}
2869
2870 \begin{funcdoc}{HDplot (bundle *Smod, int vnum[0], int drawix[0])}
2871 \noindent Plots on screen the Historical Decomposition for a variable.
2872
2873 \noindent Arguments:
2874 \begin{enumerate}
2875 \item A bundle holding the model.
2876 \item The progressive number of the variable (0 means all).
2877 \end{enumerate}
2878
2879 The \texttt{drawix} argument can typically be omitted, see \texttt{GetShock}.
2880 \end{funcdoc}
2881
2882 \begin{funcdoc}{HDsave (string outfilename, bundle *Smod, int vnum[0], int drawix[0])}
2883 \noindent Saves the Historical Decomposition for a variable to a graphic file,
2884 whose format is identified by its extension.
2885
2886 \noindent Arguments:
2887 \begin{enumerate}
2888 \item The graphic file name.
2889 \item A bundle holding the model (pointer form).
2890 \item The progressive number of the variable (0 means all).
2891 \end{enumerate}
2892
2893 The \texttt{drawix} argument can typically be omitted, see \texttt{GetShock}.
2894 \end{funcdoc}
2895
2896 \begin{funcdoc}{IRFplot (bundle *Smod, int snum, int vnum, int keypos[0:2:1], int drawix[0])}
2897 \noindent Plots an impulse response function on screen.
2898
2899 \noindent Arguments:
2900
2901 \begin{enumerate}
2902 \item A bundle holding the model.
2903 \item The progressive number of the shock (may be negative, in which
2904 case the IRF is flipped).
2905 \item The progressive number of the variable.
2906 \item The position of the legend, if any (optional; default = right).
2907 \end{enumerate}
2908
2909 The \texttt{drawix} argument can typically be omitted, see \texttt{GetShock}.
2910 \end{funcdoc}
2911
2912 % \begin{funcdoc}{IRF_plotdata (bundles bs, scalar coveralpha[0.9])}
2913 % \noindent [Function name and usage subject to change.]
2914 % Relating to a set identified (sign restricted) model, this function uses
2915 % all accepted draws to construct some summary measures needed for the
2916 % (standard) IRF plots, like horizon-by-horizon means and quantiles.
2917 % Although it is by nature more like a private function, it is formally public to
2918 % enable certain kinds of unsupported hacks (see elsewhere).
2919 % \end{funcdoc}
2920
2921 \begin{funcdoc}{IRFsave (string outfilename, bundle *Smod, int snum, int vnum,
2922 int keypos[0:2:1], int drawix[0])}
2923 \noindent Saves an impulse response function to a graphic file, whose format is
2924 identified by its extension.
2925
2926 \noindent Arguments:
2927
2928 \begin{enumerate}
2929 \item The graphic file name.
2930 \item A bundle holding the model (pointer form).
2931 \item The progressive number of the shock (may be negative, in which
2932 case the IRF is flipped).
2933 \item The progressive number of the variable.
2934 \item The location of the legend / key; 0=off, 1=outside/right (default), 2=below
2935 \end{enumerate}
2936
2937 The \texttt{drawix} argument can typically be omitted, see \texttt{GetShock}.
2938 \end{funcdoc}
2939
2940 \begin{funcdoc}{\detokenize{SVAR_boot} (bundle *Smod, int rep[0::2000], scalar alpha[0:1:0.9], bool
2941 quiet[1],\\
2942 string btypestr[null], int biascorr[-1:2:-1])}
2943 \noindent Perform a bootstrap analysis of a model. Returns the number of
2944 bootstrap replications in which the model failed to converge.
2945
2946 \noindent Arguments:
2947
2948 \begin{enumerate}
2949 \item A bundle holding the model (pointer form).
2950 \item (Optional) the number of bootstrap replications (default: 2000).
2951 \item (Optional) the coverage probability used for the confidence bands (e.g.\
2952 for 0.90 the 0.05 and 0.95 quantiles will be used; default: 0.9).
2953 \item (Optional) omit the table with bootstrap means and standard
2954 errors (default: yes).
2955 \item (Optional) the choice of bootstrap type: can be any one of
2956 ``resampling'', one of the wild variants---namely ``wildN'' (with
2957 ``wild'' as an alias), ``wildR'' or ``wildM''---or ``MBB'' for
2958 moving blocks. The default is to leave the choice in the model
2959 as-is.
2960 \item (Optional) bias correction choice: 0 for none, 1 for partial,
2961 2 for full; the default value of $-1$ preserves whatever setting
2962 is the model.
2963 \end{enumerate}
2964 Note that the bias correction option currently only applies to
2965 non-SVEC models.
2966 \end{funcdoc}
2967
2968 \begin{funcdoc}{\detokenize{SVAR_coint} (bundle *Smod, int dcase[1:5:3],
2969 matrix jbeta, matrix jalpha[null],\\
2970 bool verbose[0]), list rexo[null])}
2971 \noindent Necessary for a SVEC model, adds the needed information
2972 for subsequent estimation.
2973
2974 \noindent Arguments:
2975 \begin{enumerate}
2976 \item A bundle holding the model.
2977 \item A code for the constant/trend combination (1 to 5, as per
2978 Johansen; default 3).
2979 \item The cointegration matrix (required\footnote{In the accompanying but
2980 technically separate package \dtk{SVEC_GUI} the corresponding input is optional and
2981 would be automatically estimated.}).
2982 \item The loadings matrix (optional, will be estimated via OLS if
2983 omitted or empty).
2984 \item An optional verbosity switch (default 0).
2985 \item (Currently unused: list of further restricted exogenous
2986 variables)
2987 \end{enumerate}
2988 \end{funcdoc}
2989
2990 \begin{funcdoc}{\detokenize{SVAR_cumulate} (bundle *Smod, int nv)}
2991 \noindent Stores into the model the fact that the cumulated IRFs for
2992 the \texttt{nv}-th variable are desired. This is typically used jointly
2993 with long-run restrictions.
2994 \end{funcdoc}
2995
2996 \begin{funcdoc}{\detokenize{SVAR_estimate} (bundle *Smod, int verbosity[1])}
2997 \noindent Estimates the model by maximum likelihood. Its second argument is a
2998 scalar, which controls the verbosity of output. If omitted,
2999 standard output is printed. If set to 2 or higher, the output of the
3000 identification check is printed, too.
3001
3002 If you're sure about it, the identification check before
3003 the estimation of the structural form can be suppressed in
3004 \dtk{SVAR_setup} (or by manually setting \texttt{Smod.checkident}
3005 to 0).
3006 \end{funcdoc}
3007
3008 \begin{funcdoc}{\detokenize{SVAR_getshock} (bundle *Smod, string sname[null], int drawix[0])}
3009 \noindent Returns a series for the current workfile, namely the estimate of the
3010 structural shock given in \texttt{sname} via equation \eqref{eq:PrE-StS-AB},
3011 in which VAR residuals are used instead of the one-step-ahead prediction errors
3012 $\PrE{t}$. If omitted, the default is to retrieve the first shock.
3013
3014 The \texttt{drawix} argument is only meaningful in the set identification
3015 (sign restriction) case and overrides from which of the accepted model draws
3016 the coefficients should be taken. Normally this draw index should instead be determined
3017 with the help of the \dtk{SVAR_SRgetbest} function and can be omitted here.
3018 This index can range from 1 to the number
3019 of accepted draws. In order to work the SR type model must have been set up such that all
3020 accepted draws are stored in the model bundle. (See \dtk{SVAR_setup},
3021 default is yes.)
3022 \end{funcdoc}
3023
3024 \begin{funcdoc}{\detokenize{SVAR_HD} (bundle *Smod, string vname[null], int drawix[0])}
3025 \noindent Returns a list of series with
3026 the ``historical decomposition'' of the variable given in \texttt{vname},
3027 decomposing it into a deterministic component
3028 and $n$ stochastic components. The names of the resulting series are
3029 as follows: if the name of the decomposed variable is \texttt{foo},
3030 then the historical component attributable to the first structural
3031 shock is called \dtk{hd_foo_1}, the one attributable to the
3032 second structural shock is called \dtk{hd_foo_2}, and so
3033 on. Finally, the one for the first deterministic component is called
3034 \dtk{hd_foo_det}.
3035
3036 If the \texttt{vname} argument is omitted, the default is to target the first variable.
3037
3038 The \texttt{drawix} argument can typically be omitted, see \dtk{SVAR_getshock}.
3039 \end{funcdoc}
3040
3041 \begin{funcdoc}{\detokenize{SVAR_hd} (bundle *Smod, int nv, int drawix[0])}
3042 \noindent Equivalent to the recommended \dtk{SVAR_HD}, but with an alternative
3043 interface:
3044 Instead of specifying the name of the target variable its position in the
3045 list of endogenous variables must be given in \texttt{nv}.
3046 \end{funcdoc}
3047
3048
3049 \begin{funcdoc}{\detokenize{SVAR_ident} (bundle *Smod, int verbose[0])}
3050 \noindent Returns a 0/1 scalar checking if a model is identified by applying (among other things)
3051 the algorithm described in \cite{AG}.
3052 Its second argument controls the verbosity of output.
3053 If set to a non-zero value, a representation of the restrictions and
3054 a few messages are printed as checks are performed.
3055
3056 In case redundant restrictions are found, these are dropped in the
3057 model bundle to facilitate further estimation.
3058 \end{funcdoc}
3059
3060 \begin{funcdoc}{\detokenize{SVAR_namedrestrict} (bundle *Smod, string code,
3061 string yname, string sname, scalar d[0])}
3062 \noindent An alternative interface for point restrictions, requiring the
3063 names of the respective shock and variable pair instead of the index numbers
3064 used in \dtk{SVAR_restrict}. An example based on the main sample script
3065 is given in the included script file \dtk{simple_C_named.inp}.
3066
3067 For the first two arguments \texttt{Smod} and \texttt{code}, see the explanation
3068 for \dtk{SVAR_restrict}. However, the type codes \texttt{"Adiag"} and
3069 \texttt{"Bdiag"} make no sense here and are not allowed.
3070
3071 The next two string arguments \texttt{yname} and
3072 \texttt{sname} refer to the variable and shock names in the model; while the shock
3073 names have to be user-defined before calling this function, the variable names
3074 are automatically taken from the model setup. Using unrecognized names will cause
3075 an error. Notice that for the A-matrix in an AB model no shock is directly
3076 involved, and thus it may be more natural to use the indexation form in
3077 \dtk{SVAR_restrict}.
3078
3079 Finally, the scalar restriction value \texttt{d} works again as in
3080 \dtk{SVAR_restrict}, with the same default value of zero.
3081 \end{funcdoc}
3082
3083 \begin{funcdoc}{\detokenize{SVAR_restrict} (bundle *Smod, string code,
3084 numeric r, int c[0], scalar d[0])}
3085 \noindent Sets up point constraints for an existing model. The function
3086 takes at most five arguments:
3087 \begin{enumerate}
3088 \item A pointer to the model for which we want to set up the
3089 restriction(s).
3090 \item A code for which type of restriction we want:
3091 \begin{description}
3092 \item[\texttt{"C"}] Applicable to C-type models (including SVEC). Used for short-run
3093 restrictions.
3094 \item[\texttt{"lrC"}] Applicable to C-type models (including SVEC in principle).
3095 Used for long-run restrictions.
3096 \item[\texttt{"A"}] Applicable to AB models. Used for constraints on
3097 the $A$ matrix.
3098 \item[\texttt{"B"}] Applicable to AB models. Used for constraints on
3099 the $B$ matrix.
3100 \item[\texttt{"Adiag"}] Applicable to AB models. Used for constraints on
3101 the whole diagonal of the $A$ matrix (see below).
3102 \item[\texttt{"Bdiag"}] Applicable to AB models. Used for constraints on
3103 the whole diagonal of the $B$ matrix (see below).
3104 \end{description}
3105 \item A numeric input, namely a matrix or an integer, whose interpretation depends
3106 on the restriction type:
3107 \begin{description}
3108 \item[Case 1a] applies to codes \texttt{"C"}, \texttt{"lrC"},
3109 \texttt{"A"} and \texttt{"B"}, and \texttt{r} is a scalar integer: Then the
3110 argument indicates the row of the restricted element. This input can be combined
3111 with the remaining two optional arguments.
3112 \item[Case 1b] applies to the same model codes as before, but \texttt{r} is an
3113 n-by-n matrix: Then the input is taken to be a full restriction pattern matrix,
3114 i.e. any valid number in that matrix is taken directly as a restricted value,
3115 while unrestricted elements must be given as NAs. Typically, a previously created
3116 named matrix argument will be used, but an anonymous matrix literal for on-the-fly
3117 use is also valid, as per standard hansl syntax. In this matrix usage case, the
3118 remaining arguments \texttt{c} and \texttt{d} are redundant and unused.
3119 \item[Case 2] applies to codes \texttt{"Adiag"} and
3120 \texttt{"Bdiag"}. The argument specifies what kind of restriction
3121 is to be placed on the diagonal: any valid scalar indicates that
3122 the diagonal of $A$ (or $B$) is set to that value. Almost
3123 invariably, this is used with the value 1. IMPORTANT: if this
3124 argument is \texttt{NA}, all \emph{non-diagonal} elements are
3125 constrained to 0, while diagonal elements are left unrestricted.
3126 \end{description}
3127 \item An integer: the column of the restricted element, for the codes
3128 \texttt{"C"}, \texttt{"lrC"}, \texttt{"A"} and
3129 \texttt{"B"}. Otherwise, unused and can then be omitted.
3130 \item A scalar: for the codes \texttt{"C"}, \texttt{"lrC"},
3131 \texttt{"A"} and \texttt{"B"}, the fixed value to which the matrix
3132 element should be set (may be omitted if 0). Otherwise, unused and
3133 can then be omitted.
3134 \end{enumerate}
3135
3136 A few examples:
3137 \begin{itemize}
3138 \item \dtk{SVAR_restrict(&M, "C", 3, 2, 0)}; in a C model called
3139 \texttt{M}, sets $C_{3,2} = 0$. As a consequence, the IRF for
3140 variable number 3 with respect to the shock number 2 starts from
3141 zero.
3142 \item \dtk{SVAR_restrict(&foo, "A", 1, 2, 0)}; in an AB model called
3143 \texttt{foo}, sets $A_{1,2} = 0$.
3144 \item \dtk{SVAR_restrict(&MyMod, "lrC", 5, 3, 0)}; in a C model
3145 called \texttt{MyMod}, restricts $C$ such that the long-run impact
3146 of shock number 3 on variable number 5 is 0. This implies that the
3147 cumulated IRF for variable 5 with respect to shock 3 tends to zero.
3148 \item \dtk{SVAR_restrict(&Mod2, "B", \{NA, 0; NA, NA\})} specifies a
3149 pattern matrix in a 2-dimensional system to restrict the 1,2-element of
3150 the B matrix to zero.
3151 \item \dtk{SVAR_restrict(&bar, "Adiag", 1)}; in an AB model called
3152 \texttt{bar}, sets $A_{i,i} = 1$ for $1 \le i \le n$.
3153 \item \dtk{SVAR_restrict(&baz, "Bdiag", NA)}; in an AB model called
3154 \texttt{baz}, sets $B_{i,j} = 0$ for $i \ne j$.
3155 \end{itemize}
3156
3157 If the restrictions are found to conflict with other ones already
3158 implied by the pre-existing constraints, they will just be ignored and
3159 a warning will be printed.
3160
3161 Note that this function can be used (albeit in a limited way) in the
3162 context of set-identified models. See section \ref{sec:mixed} for more details.
3163 \end{funcdoc}
3164
3165 \begin{funcdoc}{\detokenize{SVAR_setup} (string type, list Y, list X, int varorder,
3166 bool checkident[1])}
3167 \noindent Returns a bundle with the initialised model.
3168
3169 \noindent Arguments:
3170 \begin{enumerate}
3171 \item A type string: valid values are \texttt{"C"},
3172 \texttt{"plain"}, \texttt{"AB"}, \texttt{"SVEC"}, and now also \texttt{"SR"}.
3173 \item A list containing the endogenous variables.
3174 \item A list containing the exogenous variables.
3175 \item A positive integer, the VAR order.
3176 \item A switch: For traditional (non set-identified) models it means to activate or suppress
3177 the automatic identification check before estimation of the structural form (default on).
3178 Otherwise (for type \texttt{"SR"}) this doesn't make sense, and the meaning of the switch
3179 is instead whether to store all the produced IRF data from the accepted draws into the
3180 model bundle (default yes). Since the bundle's size will be much larger with all the draws,
3181 sometimes you may want to avoid the storage. (You do not need to keep the raw data for
3182 standard IRF plots, but you will need it for "spaghetti" plots and in case you change your
3183 mind about the coverage probability of the error bands later.)
3184 \end{enumerate}
3185 \end{funcdoc}
3186
3187 \begin{funcdoc}{\detokenize{SVAR_spagplot} (bundle Smod, string vname, string sname,
3188 string fname (optional))}
3189 \noindent Relating to a set identified (sign restricted) model, does a
3190 ``spaghetti'' plot of the IRFs, i.e. simply plotting the IRF of each accepted
3191 draw as a thin line. This complementary analysis avoids the criticism of
3192 aggregating horizon-per-horizon.
3193 In order to work the data of the draws must have been stored inside the model
3194 bundle (which is the default).
3195
3196 The plot will be displayed in interactive mode unless a file name or path
3197 location in the ``fname'' argument, in which case the file extension determines
3198 the output graphics format produced by gnuplot.
3199
3200 \noindent Arguments:
3201 \begin{enumerate}
3202 \item the model bundle (not pointerized, since nothing will be stored)
3203 \item the name of the target variable
3204 \item the name of the shock of interest
3205 \item optional file name (inside the current workdir) or full path of the output file
3206 (default: display plot on screen)
3207 \end{enumerate}
3208
3209
3210 \end{funcdoc}
3211
3212 \begin{funcdoc}{\detokenize{SVAR_SRdraw} (bundle *Smod, int rep, bool
3213 DO\_BAYES[0], scalar coveralpha[0.9],\\
3214 int maxiter[10000])}
3215
3216 \noindent Relating to a set identified (sign restricted) model, this function
3217 draws random rotations of the arbitrary baseline Cholesky model
3218 until \texttt{rep} draws satisfying the sign restrictions have come up,
3219 or until the \texttt{maxiter} limit is hit. Therefore the number of good
3220 draws can be anything between zero and \texttt{rep}.
3221 If the DO\_BAYES flag is on, the VAR parameters (including Sigma)
3222 are resampled too (from a standard Normal-Wishart distribution); otherwise,
3223 they are kept fixed at the OLS estimates.
3224
3225 This is the heart of the set identification algorithm
3226 and will take a while to run. (The goal is to speed it up in the future, e.g. by
3227 parallelizing it on multicore machines.)
3228
3229 \emph{Returns}: \texttt{array of bundles}, one for each accepted draws.
3230 By default you would \emph{not} need to produce or grab this object directly
3231 because this array would be stored inside the main model bundle as member
3232 \dtk{acc_draws} and then processed automatically. So only use it under
3233 special circumstances.
3234
3235 \noindent Arguments:
3236 \begin{enumerate}
3237 \item pointer to the SVAR model bundle
3238 \item the number of (accepted) draws $H$ to aim for
3239 \item Boolean flag for the Bayesian option
3240 (default = 0 $\to$ frequentist / no parameter uncertainty)
3241 \item the desired empirical coverage of the calculated intervals (default 90\%)
3242 \item Maximum number of attempted draws (default = 10000)
3243 \end{enumerate}
3244 \end{funcdoc}
3245
3246 \begin{funcdoc}{\detokenize{SVAR_SRexotic} (bundle *Smod, string chkstr, strings shocks, \\
3247 int length[0], int ini[0])} % left bool needs_model undocumented for now (Sven)
3248
3249 \noindent Relating to a set identified (sign restricted) model, this is an experimental function serving
3250 to specify "exotic" restrictions, i.e. those that intrinsically involve more than one
3251 variable-shock pair.\footnote{Here we are not talking about the case of having several
3252 restrictions where each of them concerns a different variable-shock pair. Such a scenario
3253 is of course already covered
3254 by the more standard approaches, see \dtk{SVAR_SRplain, SVAR_SRfull}, simply
3255 applying and combining several restrictions. Instead, the question here is how to deal
3256 with any additional restriction which intrinsically links more than one impulse response.}
3257 See section \ref{sec:SR} for an explanation of the usage.
3258
3259 \noindent Arguments:
3260 \begin{enumerate}
3261 \item model bundle in pointerized form
3262 \item A string with a valid numerical evaluation of some function of the individual IRFs.
3263 This expression will be evaluated at each of the horizons specified by \texttt{ini} and
3264 \texttt{length}. In this expression string the IRF matrix must be hardcoded as "M", so
3265 the concrete impulse responses (variable-shock pairs) must appear as "M[2,1]", or "M[2,4]",
3266 etc.
3267 Cross-horizon restrictions are not possible (yet?).
3268 \item array of strings, the collection of all shock names that play a role in this restriction\footnote{%
3269 This information is in principle already contained in the restriction expression, but we are too
3270 lazy to parse that string properly and want to be on the safe side, so we shift that responsibility
3271 to the user -- later on it may also serve as a cross-check to catch unwanted input errors.}
3272 \item see \dtk{SVAR_SRplain (length)}
3273 \item see \dtk{SVAR_SRplain (ini)}
3274 \end{enumerate}
3275
3276 \end{funcdoc}
3277
3278 \begin{funcdoc}{\detokenize{SVAR_SRfull} (bundle *Smod, string yname, string sname, scalar lo (optional),\\
3279 scalar hi (optional), int ini[0], int fin[0])}
3280
3281 \noindent Relating to a set identified (sign restricted) model, this function serves to impose restrictions that
3282 are more general than sign restrictions in the narrow sense but are still not "exotic" in the
3283 sense that they only conern a single IRF (single variable-shock pair).
3284
3285 \noindent Arguments:
3286 \begin{enumerate}
3287 \item model bundle in pointerized form
3288 \item name of the target variable of the relevant IRF
3289 \item name of the shock of the relevant IRF
3290 \item lower bound for the IRF to satisfy this restriction (default is minus infinity)
3291 \item upper bound for the IRF to satisfy this restriction (default is infinity)
3292 \item starting horizon from which to evaluate the IRF (default zero is on impact)
3293 \item end horizon up to which to evaluate the IRF (default zero is on impact)
3294 \end{enumerate}
3295 Each of the bounds \texttt{lo, hi} is optional, but at least one of them has to be specified
3296 to make it a meaningful restriction. In contrast, both \texttt{ini, fin} could be left at their defaults
3297 (be omitted), which would mean a restriction only associated with the impact effect.
3298 \end{funcdoc}
3299
3300 \begin{funcdoc}{\detokenize{SVAR_SRirf} (bundle Smod, strings whichvars [optional], \\
3301 strings whichshocks [optional], bool meanormed[0])}
3302 \noindent Relating to a set identified (sign restricted) model, does IRF plots
3303 based on all accepted draws. The empirical coverage level of the plotted
3304 confidence bands (or credible sets, if you like) must have been chosen
3305 previously at the stage of getting the draws (see
3306 \dtk{SVAR_SRdraw}, but also see \dtk{SVAR_SRresetalpha}).% \footnote{%
3307 % If you change your mind about the desired coverage level
3308 % but want to avoid re-running the computationally intensive drawing stage, the following hack
3309 % should work in theory: (1) Set the bundle element \texttt{Smod.SRcoveralpha} to the desired level.
3310 % (2) Call the relevant helper function like this:
3311 % \dtk{ bundle newIrfdata = IRF_plotdata(Smod.acc_draws, Smod.SRcoveralpha)}.
3312 % (3) Copy over the following
3313 % elements from \texttt{newIrfdata} to \texttt{Smod} and observe the internally different names:
3314 % \dtk{irfSRmeans $\rightarrow$ SRirfmeans, lo_cb $\rightarrow$ SRlo_cb,
3315 % hi\_cb $\rightarrow$ SRhi\_cb, irfSRmeds $\rightarrow$ SRirfmeds.}
3316 % This hack is not
3317 % guaranteed to work in the future. (We should probably add a helper function to automate this.) }
3318
3319 \emph{Returns}: \texttt{array of strings}, where each string array element holds the created
3320 gnuplot plotting code for one of the chosen set of sign-restricted / set-identified IRF plots,
3321 for potential further use. Simply ignore or discard the return value if it is not needed.
3322
3323 \noindent Arguments:
3324
3325 \begin{enumerate}
3326 \item the model bundle (not pointerized, since nothing will be stored)
3327 \item array of strings: collection of all target variable names to consider (default: all)
3328 \item array of strings: collection of all shock names of interest (default: all)
3329 \item switch to choose medians as the center line of the plots (default: 0/mean)
3330 \end{enumerate}
3331 It is not possible to exclude single variable-shock pairs, simply delete any unwanted plots afterwards.
3332 \end{funcdoc}
3333
3334 \begin{funcdoc}{\detokenize{SVAR_SRgetbest} (bundle *Smod, string vname, string sname,
3335 int ini[0::0], \\ int length[0::0], int disttarg[0:1:0], string loss[null]) }
3336 \noindent Relating to a set identified (sign restricted) model, this function returns
3337 the (scalar) index number among all accepted draws of that particular draw which has
3338 a certain impulse response (as specified by the user in this call) closest to the central
3339 tendency of all draws. Also stores this number in the model bundle under ``bestdraw''.
3340
3341 \noindent Arguments:
3342 \begin{enumerate}
3343 \item A bundle holding the model (pointer form).
3344 \item The name of the target variable in the interesting IRF.
3345 \item The name of the shock in the interesting IRF.
3346 \item The first period/horizon at which the IRF should be compared. (Default 0, on impact)
3347 \item The length of the horizon over which the IRF should be compared. (Default 0, only
3348 for the single period given before)
3349 \item A switch choosing whether to target the mean (0) or the median (1) of the IRF
3350 distribution. (Default 0)
3351 \item The loss function name to evaluate deviations from the target. Possible values are
3352 ``quad'' (default) and ``abs''.
3353 \end{enumerate}
3354 \end{funcdoc}
3355
3356 \begin{funcdoc}{\detokenize{SVAR_SRplain} (bundle *Smod, string yname, string sname, string what, \\
3357 int length[0], int ini[0])}
3358 \noindent Relating to a set identified model, this function serves to impose standard
3359 sign restrictions.
3360
3361 \noindent Arguments:
3362
3363 \begin{enumerate}
3364 \item model bundle in pointerized form
3365 \item name of the target variable of the relevant IRF
3366 \item name of the shock of the relevant IRF
3367 \item either "+" or "-" to specify the wanted sign
3368 \item for how many (horizon) periods after \texttt{ini} the restriction should apply (default zero,
3369 just at the particular point given by \texttt{ini})
3370 \item starting horizon from which to evaluate the IRF (default zero / on impact)
3371 \end{enumerate}
3372 Both \texttt{length, ini} could be left at their defaults
3373 (be omitted), which would mean a restriction only associated with the impact effect. If only the
3374 trailing argument \texttt{ini} is omitted, then the restriction must hold up to horizon \texttt{length}.
3375 \end{funcdoc}
3376
3377 \begin{funcdoc}{\detokenize{SVAR_SRresetalpha} (bundle *Smod, scalar alpha)}
3378 \noindent Relating to a set identified model, this function allows to redefine the
3379 desired coverage level of the pointwise confidence intervals without having to
3380 repeat the time-consuming model drawing stage. If necessary, this function would
3381 typically be called before \dtk{SVAR_SRirf}.
3382
3383 \noindent Arguments:
3384
3385 \begin{enumerate}
3386 \item model bundle in pointerized form
3387 \item desired new coverage probability of IRF confidence intervals
3388 \end{enumerate}
3389
3390 \end{funcdoc}
3391
3392 %---------------------------------------------------------------------------------------------------
3393
3394 \section{Contents of the model bundle}
3395
3396 \label{sec:bundle_struct}
3397
3398 \centering
3399 \begin{tabular}{rp{0.8\textwidth}}
3400 \hline
3401 \multicolumn{2}{c}{\textbf{Basic setup}} \\
3402 \hline
3403 \texttt{step} & done so far \\
3404 \texttt{type} & integer, model type (1: PLAIN, 2: C, 3: AB, 4: SVEC)\\
3405 \texttt{n, k} & numbers of endogenous and exogenous variables \\
3406 \texttt{p} & VAR order \\
3407 %\texttt{k} & number of exogenous variables \\
3408 \texttt{T} & number of observations \\
3409 \texttt{t1, t2} & initial and final observations \\
3410 \texttt{Y} & endogenous variables data matrix \\
3411 \texttt{X} & exogenous variables data matrix \\
3412 \dtk{calc_lr} & switch to get long-run matrix \texttt{lrmat} in short-run models \\
3413 \texttt{checkident} & switch indicating whether to check
3414 identification before estimation\\
3415 \texttt{calinfo} & bundle, calendar info: the ``t1'', ``t2'' and
3416 ``pd'' keys are taken from the corresponding
3417 accessors when the model was created. The
3418 ``limitobs'' matrix is a 2-row matrix with a
3419 numerical representation of the dates for the
3420 first and last observations
3421 \end{tabular}
3422
3423 \begin{tabular}{rp{0.8\textwidth}}
3424 \hline
3425 \multicolumn{2}{c}{\textbf{VAR}} \\
3426 \hline
3427 \texttt{VARpar} & autoregressive parameters \\
3428 \texttt{mu} & coefficients for the deterministic (/exogenous) terms \\
3429 \texttt{U} & residuals from base VAR (As matrix; this used to be
3430 \texttt{E} before the notation change in version 1.95.
3431 Please adapt your scripts.) \\
3432 \texttt{Sigma} & unrestricted residual covariance matrix \\
3433 \texttt{jalpha} & (SVEC only) cointegration loadings \\
3434 \texttt{jbeta} & (SVEC only) cointegration coefficients \\
3435 \texttt{crank} & (SVEC only) cointegration rank (inferred from jbeta)\\
3436 \texttt{jcase} & (SVEC only) deterministic setup (1 to 5)\\
3437 \end{tabular}
3438
3439 \begin{tabular}{rp{0.8\textwidth}}
3440 \hline
3441 \multicolumn{2}{c}{\textbf{SVAR setup}} \\
3442 \hline
3443 \texttt{Rd1} & short-run constraints on B (and therefore C in non-AB models) \\
3444 \texttt{Rd1l} & long-run constraints on C \\
3445 \texttt{Rd0} & short-run constraints on A in AB models \\
3446 \texttt{horizon} & horizon for structural VMA \\
3447 \texttt{cumul} & vector of cumuland variables \\
3448 \texttt{ncumul} & number of cumuland variables \\
3449 \texttt{Ynames} & names for VAR variables (string array)\\
3450 \texttt{Xnames} & names for exogenous (string array)
3451 variables, if any \\
3452 \texttt{snames} & names for shocks (string array) \\
3453 \texttt{optmeth} & integer between 0 and 4, optimisation method \\
3454 \texttt{normalize} & switch for shock rescaling, see section \ref{sec:IRF-FEVD} \\
3455 \end{tabular}
3456
3457 \begin{tabular}{rp{0.8\textwidth}}
3458 \hline
3459 \multicolumn{2}{c}{\textbf{SVAR post-estimation}} \\
3460 \hline
3461 \texttt{S1, S2, C} & estimated A, B, C \\
3462 % \texttt{S2} & estimated B \\
3463 % \texttt{C} & estimated C \\
3464 \texttt{lrmat} & estimated long-run matrix \\
3465 \texttt{theta} & identified coefficients as vector \\
3466 \texttt{vcv} & covariance matrix of these coefficients \\
3467 \texttt{IRFs} & IRF matrix (see section \ref{sec:baseest})\\
3468 \texttt{LL0, LL1} & Unrestricted and restricted maximized likelihoods \\
3469 \end{tabular}
3470
3471 \begin{tabular}{rp{0.8\textwidth}}
3472 \hline
3473 \multicolumn{2}{c}{\textbf{Bootstrap-related}} \\
3474 \hline
3475 \texttt{nboot} & integer, number of bootstrap replications \\
3476 \dtk{boot_alpha} & scalar, bootstrap confidence level (coverage)\\
3477 \texttt{bootdata} & output from the bootstrap (see section \ref{sec:bootstrap})\\
3478 \texttt{biascorr} & 0 for no bias correction, 1 for
3479 partial, 2 for full\\
3480 \texttt{BCiter} & integer, number of replications for the bias correction \\
3481 \texttt{boottype} & 1 for standard residual resampling, 2-4 for residual-based
3482 wild bootstraps (2: Normal, 3: Rademacher, 4: Mammen), 5 for moving blocks \\
3483 \texttt{movblocklen} & integer, changes the block length for the moving blocks bootstrap
3484 (otherwise: use 10\% of the sample length)
3485 \end{tabular}
3486
3487 \begin{tabular}{rp{0.8\textwidth}}
3488 \hline
3489 \multicolumn{2}{c}{\textbf{Set-identification (sign restrictions) -related}} \\
3490 \hline
3491 \texttt{SRiter} & integer, number of draws actually done \\
3492 \texttt{SRacc} & integer, number of accepted draws stored and used\\
3493 \dtk{SRid_snames} & strings array, names of those shocks that are subject
3494 to sign (and similar) restrictions, subset of \texttt{snames}\\
3495 \texttt{SRest} & matrix, internal representation of the (non-exotic) set identification
3496 restrictions; each row has: variable id number, lower bound, upper bound, starting
3497 horizon, end horizon, shock id number \\
3498 \texttt{exoticSR} & bundle, holding internal representation of exotic (and in the future also
3499 super-exotic) restrictions; contains a strings array \texttt{checks} with the user-supplied
3500 restriction expressions, a two-column matrix \texttt{spans} with starting and ending horizons
3501 for the respective restriction, and a vector \texttt{super} holding indicators (zero or one)
3502 whether the restriction is super-exotic\footnote{see the documentation about this special feature,
3503 when it is ready}\\
3504 \texttt{SRcoveralpha} & scalar, chosen coverage of the confidence intervals (or credible sets)\\
3505
3506 \texttt{SRirfmeans} & matrix, holding the horizon-by-horizon pointwise means of
3507 the accepted IRF draws; horizons in $h+1$ rows and the variable/shock combinations
3508 in $n*numshocks$ columns\\
3509
3510 \texttt{SRirfmeds} & matrix, holding the horizon-by-horizon pointwise medians of
3511 the accepted IRF draws; dimensions see \texttt{SRirfmeans}\\
3512
3513 \texttt{SRirfserrs} & matrix, the horizon-by-horizon pointwise (pseudo) standard errors
3514 of the accepted IRF draws; dimensions see \texttt{SRirfmeans}\\
3515
3516 \dtk{SRlo_cb} & matrix, the horizon-by-horizon pointwise lower bounds of the
3517 confidence intervals (or credible sets), quantile-based (not symmetric around the
3518 means or medians); dimensions see \texttt{SRirfmeans}\\
3519
3520 \dtk{SRhi_cb} & matrix, ditto for the upper bounds\\
3521
3522 \texttt{storeSRirfs} & switch indicating whether the IRF outcomes from all accepted draws
3523 will be stored in the main model bundle (see also \dtk{acc_draws})\\
3524 \dtk{acc_draws} & array of bundles, collecting the outcomes and data of all accepted
3525 draws; this member is absent if suppressed at the setup stage. The data type and the
3526 stored representation of the draws is still experimental and subject to change.\\
3527
3528 \texttt{bestdraw} & positive integer to index the best of all accepted draws in \dtk{acc_draws}
3529 according to criteria specified in call to \dtk{SVAR_SRgetbest}. Zero if undefined.
3530 \end{tabular}
3531
3532 \section{Changelog (after v1.2)}
3533 \label{sec:changelog}
3534
3535 \subsection*{for gretl version 2024c, October 2024}
3536 \begin{itemize}
3537 \item Get rid of version number since SVAR is a gretl addon, and starting
3538 with gretl 2024b such official addons inherit the version number directly
3539 from gretl itself.
3540 \item Extend the \dtk{SVAR_restrict} function to accept full restriction pattern matrices.
3541 \item Extend the \dtk{SVAR_SRirf} function to return the created plotting codes
3542 in a strings array (returned nothing before, just ran the plots).
3543 \item Use a more efficient normal-inverse-Wishart generation algorithm.
3544 \item Properly generate the uniformly distributed rotation matrices (internally
3545 with the new \dtk{gen_haar} function).
3546 \item Fix a bug with the spaghetti plot (for set-id models) in case of partial
3547 identification.
3548 \item Try to fix more sub-cases with only ``exotic'' restrictions (and no standard
3549 set-id restrictions); but probably more work needed.
3550 \item Fix minor bug (not noticeable with standard usage): do not internally
3551 require the bundle member E from the old-style (pre 1.95) notation anymore.
3552 While we're at it, do not carry this compatiblity copy around anymore at
3553 all, so the estimated residuals are now exclusively in the matrix member U.
3554 \end{itemize}
3555
3556 \subsection*{Version 2.1, November 2023}
3557 \begin{itemize}
3558 \item Add the ``calinfo'' bundle to the model bundle.
3559 \item Switch to the ``stacked-bars'' version for historical
3560 decomposition plots.
3561 \end{itemize}
3562
3563 \subsection*{Version 2.0, June/July 2023}
3564 \begin{itemize}
3565 \item Implement mixed (sign- and zero-) restrictions. Deprecate \cmd{SRgetbest}
3566 in favour of \dtk{SVAR_SRgetbest}.
3567 \item Move the internal function drawbootres to the extra addon, and along the
3568 way fix a bug with the moving blocks bootstrap, the explicit choice of the
3569 block length was not honored (probably introduced in 2021).
3570 \item Fix for "spaghetti" plots with output paths that include spaces.
3571 \end{itemize}
3572
3573 \subsection*{Version 1.98, May 2023}
3574 \begin{itemize}
3575 \item Fix documentation on sign restrictions.
3576 \end{itemize}
3577
3578 \subsection*{Version 1.97, July 2022}
3579 \begin{itemize}
3580 \item Fix fatal bug preventing the output of plots with HDsave() and
3581 FEVDsave(). Use the new commute() function internally.
3582 \end{itemize}
3583
3584 \subsection*{Version 1.96, December 2021}
3585 \begin{itemize}
3586 \item Fix bug in path to plot files on MS Windows.
3587 \end{itemize}
3588
3589 \subsection*{Version 1.95, June 2021}
3590 \begin{itemize}
3591 \item Start cleaning up and modernizing the internals, and big jump
3592 making 2021a the required gretl version because of that.
3593 \item Swap notation to stay in line with most of the literature, $\varepsilon$ are now the structural shocks and $u$ become the prediction errors (reduced form). For SVAR scripting
3594 this means that the residual matrix \texttt{E} in the bundle is now called \texttt{U}.
3595 \end{itemize}
3596
3597 \subsection*{Version 1.94, April 2021}
3598 \begin{itemize}
3599 \item Fix bug (introduced in 1.32 or so): for AB-models, the $C$ matrix was
3600 not updated over bootstrap iterations, leading to zero-width confidence
3601 intervals for the impact effect.
3602 \item Bump version requirement to 2018c to accommodate some internal changes.
3603 \end{itemize}
3604
3605 \subsection*{Version 1.93, December 2020}
3606 \begin{itemize}
3607 \item Add helper function SVAR\_SRresetalpha. (Hide IRF\_plotdata as
3608 redundant because of that.)
3609 \item Enable saving sign-restriction spaghetti plot to file.
3610 \end{itemize}
3611
3612 \subsection*{Version 1.92, August/September 2020}
3613 \begin{itemize}
3614 \item Clarify documentation for Bayesian draws in set-id models.
3615 \item Replace deprecated funcerr() with errorif(), therefore need gretl 2020b
3616 for the sign restriction part.
3617 \end{itemize}
3618
3619 \subsection*{Version 1.91, April 2020}
3620 \begin{itemize}
3621 \item Minor plot legend fix for GUI usage; a fix of DoF calculation for
3622 Bayesian redrawing; catch the case of no accepted draws more gracefully.
3623 \item Introduce new convenience function SRgetbest to find the best draw
3624 according to user-specified IRF criterion.
3625 \item New functions with alternative interface: SVAR\_HD (wrapper for SVAR\_hd)
3626 and SVAR\_getshock (wrapper for GetShock).
3627 \end{itemize}
3628
3629 \subsection*{Version 1.90, March 2020}
3630 \begin{itemize}
3631 \item Major new feature: set-identified model estimation (a.k.a. sign restrictions;
3632 scripting interface only).
3633
3634 \end{itemize}
3635
3636 \subsection*{Version 1.52, November 2019}
3637 \begin{itemize}
3638 \item Fix the Luetkepohl (2008) check for SVECs with weakly exogenous variables,
3639 and actually process the existing extra check whether a restriction might be redundant,
3640 which is relevant mostly in the case of some weakly exogenous variables.
3641 Also for SVECs, check whether a long-run restriction really applies to a permanent shock.
3642
3643 \item The identification check output is now suppressed by default to avoid clutter.
3644 (It is still run by default, but quietly.)
3645
3646 \item Some documentation updates.
3647
3648 \end{itemize}
3649
3650
3651 \subsection*{Version 1.51, September 2019}
3652 \begin{itemize}
3653 \item Also add the moving blocks bootstrap by \cite{BrugJenTrenk16} as an option.
3654 \end{itemize}
3655
3656 \subsection*{Version 1.5, September 2019}
3657 \begin{itemize}
3658
3659 \item The documentation of the bootstrap $\alpha$ level did not match the actual
3660 implementation. This has been changed such that \dtk{boot_alpha} really
3661 represents the nominal coverage of the confidence intervals around each impulse
3662 response. (This quantity is often denoted with $1 - \alpha$ instead, but for
3663 backward compatibility we stick to $\alpha$.)
3664 Attention: This change means that existing scripts will produce systematically
3665 different (wider) confidence bands with this version.
3666
3667 \item Add the option 'boottype' to choose some wild bootstrap variants to account for
3668 heteroskedasticity.
3669
3670 \item Reformat the identification check output.
3671
3672 \item Add the possibility to choose the bias correction directly in the call to \dtk{SVAR_boot}.
3673
3674 \end{itemize}
3675
3676 \subsection*{Version 1.4, March 2019}
3677 \begin{itemize}
3678
3679 \item catches of wrong user input: catch the case when no restrictions are given,
3680 to prevent other errors; catch a missing cointegration setup when trying to
3681 estimate a SVEC; add a linear dependency check on the exogenous terms
3682 in \dtk{SVAR_setup}; catch the case where restrictions would not work
3683 (\texttt{imp2exp}) and print out a message
3684
3685 \item fixes in the SVEC case especially with further exogenous variables:
3686 fix indexing error and mis-concatenation, and companion matrix in \dtk{vecm_est}
3687 with exogenous; and fix the restricted terms in the bootstrap
3688
3689 \item internal changes: simplify centered seasonals creation in determ(),
3690 replace isnull with !exists (and vice versa)
3691
3692 \item interface: allow omission of alpha in \dtk{SVAR_coint}
3693
3694 \item New argument 'checkident' in SVAR\_setup. Checking identification is now default
3695 in script use.
3696
3697 \item A new restriction check in the SVEC case (Luetkepohl 2008).
3698
3699 \end{itemize}
3700
3701 \subsection*{Version 1.36, July 2018}
3702 \begin{itemize}
3703 \item Update this documentation to reflect previous changes.
3704
3705 \item fix a transposed matrix product in SVECM estimation for cases 2
3706 and 4
3707 \end{itemize}
3708
3709 \subsection*{Version 1.35, May 2018}
3710 \begin{itemize}
3711 \item Enable 0 index (meaning ``all'') in plotting functions
3712 \end{itemize}
3713
3714 \subsection*{Version 1.33 and 1.34, April 2018}
3715 \begin{itemize}
3716 \item Fix breakage in \verb|init_C| function
3717 \item Allow a C-model with no estimated parameters
3718 \item Fix constant in cointegrated case
3719 \end{itemize}
3720
3721 \subsection*{Version 1.31 and 1.32, January 2018}
3722 \begin{itemize}
3723 \item Update this documentation to reflect some previous changes.
3724
3725 \item Fix failing printout for bootstrap.
3726 (v1.32: Sanitize further the printout of the long-run matrix.)
3727
3728 \item Enable long-run matrix calculation and reporting also for SVEC models.
3729 \end{itemize}
3730
3731 \subsection*{Version 1.3, December 2017}
3732
3733 \begin{itemize}
3734
3735 \item The full bias correction now also corrects the estimated A/B/C matrices
3736 explicitly, not only the implied IRFs.
3737
3738 \item Make it clear that long-run restrictions are not supported in AB models.
3739
3740 \item Calculate the long-run matrix and put it into the model bundle as \texttt{lrmat}.
3741 Also add a boolean switch \dtk{calc_lr} to the model bundle to force its
3742 calculation when it would normally not be done
3743 (in models with short-run constraints only).
3744
3745 \item The case of a SVEC model with Blanchard-Quah restrictions on top might
3746 not have been handled correctly, and should be OK now (but the bootstrap is
3747 currently not allowed in this case).
3748
3749 \item Require \texttt{gretl} version $>$2016c or $>$2017a due to internal changes.
3750
3751 \end{itemize}
3752 \end{document}
3753
3754 %%% Local Variables:
3755 %%% mode: latex
3756 %%% TeX-master: t
3757 %%% End:
3758