Skip to content

Commit

Permalink
Added week 10 materials
Browse files Browse the repository at this point in the history
  • Loading branch information
wmutschl committed Dec 19, 2024
1 parent 6fefbe4 commit 1a98287
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 199 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/dynare-6.2-matlab-r2024b-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,13 @@ jobs:
addpath("Dynare-6.2-arm64/matlab");
cd("progs/matlab");
keatingSR;
BlanchardQuahLR;
BlanchardQuahLR;
- name: Run week 10 codes
uses: matlab-actions/run-command@v2
with:
command: |
addpath("Dynare-6.2-arm64/matlab");
cd("progs/matlab");
RWZSRLR;
bootstrappingStdIRFs_RWZSRLR;
11 changes: 10 additions & 1 deletion .github/workflows/dynare-6.2-matlab-r2024b-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,13 @@ jobs:
addpath("dynare/matlab");
cd("progs/matlab");
keatingSR;
BlanchardQuahLR;
BlanchardQuahLR;
- name: Run week 10 codes
uses: matlab-actions/run-command@v2
with:
command: |
addpath("dynare/matlab");
cd("progs/matlab");
RWZSRLR;
bootstrappingStdIRFs_RWZSRLR;
11 changes: 10 additions & 1 deletion .github/workflows/dynare-6.2-matlab-r2024b-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,13 @@ jobs:
addpath("D:\hostedtoolcache\windows\dynare-6.0\matlab");
cd("progs/matlab");
keatingSR;
BlanchardQuahLR;
BlanchardQuahLR;
- name: Run week 10 codes
uses: matlab-actions/run-command@v2
with:
command: |
addpath("D:\hostedtoolcache\windows\dynare-6.0\matlab");
cd("progs/matlab");
RWZSRLR;
bootstrappingStdIRFs_RWZSRLR;
23 changes: 3 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ Familiarize yourself with

</details>

<!---

<details>
<summary> Week 10: Asymptotic and Bootstrap Inference in SVARs Identified By Exclusion Restrictions: Theory</summary>
Expand All @@ -205,34 +204,18 @@ Familiarize yourself with
* implement both short-run and long-run restrictions using numerical optimization
* understand pros and cons of asymptotic inference for the impulse-response function of SVAR models
* understand pros and cons of bootstrap inference for the impulse-response function of SVAR models
### To Do
* [x] Review the solutions of [last week's exercises](https://github.com/wmutschl/Quantitative-Macroeconomics/releases/latest/download/week_8.pdf) and write down all your questions
* [x] Read Kilian and Lütkepohl (2007, Ch. 4.1, Ch. 7.6, Ch.8, Ch.9, Ch.10.1, 10.3, 10.4, 10.5, 11.1, 11.2, 11.3). Make note of all the aspects and concepts that you are not familiar with or that you find difficult to understand.
* [x] Do exercises 1 and 2 of problem set 9
* [x] If you have questions, get in touch with me via email or (better) [schedule a meeting](https://schedule.mutschler.eu)
</details>
<details>
<summary> Week 10: Bootstrap Inference in SVARs Identified By Exclusion Restrictions</summary>
### Goals
* implement and compare asymptotic and bootstrap standard deviations of structural IRFs
* implement and compare asymptotic and bootstrap confidence intervals of structural IRFs
* implement and compare asymptotic and bootstrap standard deviations and confidence intervals of structural IRFs

### To Do

* [x] Review the solutions of [last week's exercises](https://github.com/wmutschl/Quantitative-Macroeconomics/releases/latest/download/week_9.pdf) and write down all your questions
* [x] Read Kilian and Lütkepohl (2007, Ch. 12.1-12.5, Ch. 12.9). Make note of all the aspects and concepts that you are not familiar with or that you find difficult to understand.
* [x] Read Kilian and Lütkepohl (2007, Ch. 4.1, Ch. 7.6, Ch.8, Ch.9, Ch.10.1, 10.3, 10.4, 10.5, 11.1, 11.2, 11.3, 12.1-12.5, Ch. 12.9). Make note of all the aspects and concepts that you are not familiar with or that you find difficult to understand.
* [x] We will do the exercises in class.
* [x] If you have questions, get in touch with me via email or (better) [schedule a meeting](https://schedule.mutschler.eu)

</details>

<!---
<details>
<summary> Week 11: Introduction to Bayesian estimation and the Gibbs sampler</summary>
Expand Down
93 changes: 50 additions & 43 deletions exercises/svar_IS_LM.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,74 @@
\(\Delta m_t\) the growth in M1 and \(\Delta p_t\) the inflation rate in the CPI\@.
There are four shocks in the system: an aggregate supply (AS), a money supply (MS), a money demand (MD) and an aggregate demand (IS) shock.
Ignoring the lagged dependent variables for \textbf{expository} purposes (\(B_1=\cdots =B_p=0\)),
the unrestricted structural VAR model can be simply written as \(B_0 y_t = \varepsilon_t\). That is:
the unrestricted structural VAR model can be simply written as \(B_{0} y_t = \varepsilon_t\).
That is:
\begin{align}
\Delta gnp_t &= -b_{12}\Delta i_t -b_{13}(i_t-\Delta p_t) -b_{14}(\Delta m_t-\Delta p_t) + \varepsilon_t^{AS} \label{eq:AS}\\
\Delta i_t &= -b_{21}\Delta gnp_t -b_{23}(i_t-\Delta p_t) -b_{24}(\Delta m_t-\Delta p_t) + \varepsilon_t^{MS} \label{eq:MS}\\
i_t - \Delta p_t &= -b_{31}\Delta gnp_t -b_{32}\Delta i_t -b_{34}(\Delta m_t-\Delta p_t) + \varepsilon_t^{MD} \label{eq:MD}\\
\Delta m_t - \Delta p_t &= -b_{41}\Delta gnp_t -b_{42}\Delta i_t - b_{43} (i_t-\Delta p_t) + \varepsilon_t^{IS} \label{eq:IS}
\end{align}
where \(b_{ij}\) denotes the \(ij\)th element of \(B_0\).
where \(b_{ij}\) denotes the \(ij\)th element of \(B_{0}\).
Consider the following identification restrictions:

\begin{itemize}
\item Money supply shocks do not have contemporaneous effects on output growth, i.e.\
\begin{align*}
\frac{\partial \Delta gnp_t}{\partial \varepsilon_t^{MS}}=0
\end{align*}
\item Money demand shocks do not have contemporaneous effects on output growth, i.e.\
\begin{align*}
\frac{\partial \Delta gnp_t}{\partial \varepsilon_t^{MD}}=0
\end{align*}
\item Monetary authority does not react contemporaneously to changes in the price level.\\Hint: compute from equation~\eqref{eq:MS}:
\begin{align*}
\frac{\partial \Delta i_t}{\partial \Delta p_t}=0
\end{align*}
\item Money supply shocks, money demand shocks and aggregate demand shocks do not have long-run effects on the log of real GNP:
\begin{align*}
\frac{\partial gnp_t}{\partial \varepsilon_t^{MS}}=0,\qquad \frac{\partial gnp_t}{\partial \varepsilon_t^{MD}}=0,\qquad \frac{\partial gnp_t}{\partial \varepsilon_t^{IS}}=0
\end{align*}
\item The structural shocks are uncorrelated with covariance matrix \(E(\varepsilon_t \varepsilon_t')=\Sigma_\varepsilon \).
In other words, the variances are \textbf{not} normalized.
\item Money supply shocks do not have contemporaneous effects on output growth, i.e.\
\begin{align*}
\frac{\partial \Delta gnp_t}{\partial \varepsilon_t^{MS}}=0
\end{align*}

\item Money demand shocks do not have contemporaneous effects on output growth, i.e.\
\begin{align*}
\frac{\partial \Delta gnp_t}{\partial \varepsilon_t^{MD}}=0
\end{align*}

\item Monetary authority does not react contemporaneously to changes in the price level.\\Hint: compute from equation~\eqref{eq:MS}:
\begin{align*}
\frac{\partial \Delta i_t}{\partial \Delta p_t}=0
\end{align*}

\item Money supply shocks, money demand shocks and aggregate demand shocks do not have long-run effects on the log of real {GNP}:
\begin{align*}
\frac{\partial gnp_t}{\partial \varepsilon_t^{MS}}=0,\qquad \frac{\partial gnp_t}{\partial \varepsilon_t^{MD}}=0,\qquad \frac{\partial gnp_t}{\partial \varepsilon_t^{IS}}=0
\end{align*}

\item The structural shocks are uncorrelated with covariance matrix \(E(\varepsilon_t \varepsilon_t')=\Sigma_{\varepsilon} \).
In other words, the variances are \textbf{not} normalized.
\end{itemize}
Solve the following exercises:

\begin{enumerate}
\item Derive the implied exclusion restrictions on the matrices \(B_0\), \(B_0^{-1}\) and \(\Theta(1)\).
\item Consider data given in the csv file \texttt{gali1992.csv}.
Estimate a VAR(4) model with a constant.
\item Estimate the structural impact matrix using a nonlinear equation solver,
i.e.\ the objective is to find the unknown elements of \(B_0^{-1}\) and the diagonal elements of \(\Sigma_\varepsilon \) such that
\begin{align*}
\begin{bmatrix}
vech(B_0^{-1} \Sigma_\varepsilon B_0^{-1'}-\hat{\Sigma}_u)\\
\text{short-run restrictions on~}B_0 \text{~and~} B_0^{-1} \\
\text{long-run restrictions on~}\Theta(1)\\
\end{bmatrix}
\end{align*}
is minimized.
Normalize the shocks such that the diagonal elements of \(B_0^{-1}\) are positive.
\item Use the implied estimates of \(B_0^{-1}\) and \(\Sigma_\varepsilon\) to plot the structural impulse responses functions
for (i) real GNP, (ii) the yield on Treasury Bills, (iii) the real interest rate and (iv) real money growth.
Add 68\% and 95\% confidence intervals using a bootstrap approach.

\item Derive the implied exclusion restrictions on the matrices \(B_{0}\), \(B_{0}^{-1}\) and \(\Theta(1)\).

\item Consider data given in the csv file \texttt{gali1992.csv}.
Estimate a VAR{(4)} model with a constant.

\item Estimate the structural impact matrix using a nonlinear equation solver,
i.e.\ the objective is to find the unknown elements of \(B_{0}^{-1}\) and the diagonal elements of \(\Sigma_{\varepsilon} \) such that
\begin{align*}
\begin{bmatrix}
vech(B_{0}^{-1} \Sigma_{\varepsilon} B_{0}^{-1'}-\hat{\Sigma}_u)\\
\text{short-run restrictions on~}B_{0} \text{~and~} B_{0}^{-1} \\
\text{long-run restrictions on~}\Theta(1)\\
\end{bmatrix}
\end{align*}
is minimized.
Normalize the shocks such that the diagonal elements of \(B_{0}^{-1}\) are positive.

\item Use the implied estimates of \(B_{0}^{-1}\) and \(\Sigma_{\varepsilon}\) to plot the structural impulse responses functions
for (i) real GNP, (ii) the yield on Treasury Bills, (iii) the real interest rate and (iv) real money growth.
Add 68\% and 95\% confidence intervals using a bootstrap approach.
\end{enumerate}

\paragraph{Readings}
\begin{itemize}
\item \textcite{Gali_1992_HowWellDoes}
\item \textcite{Gali_1992_HowWellDoes}
\end{itemize}

\begin{solution}\textbf{Solution to \nameref{ex:svarISLM}}
\ifDisplaySolutions
\ifDisplaySolutions%
\input{exercises/svar_IS_LM_solution.tex}
\fi
\newpage
Expand Down
12 changes: 6 additions & 6 deletions exercises/svar_IS_LM_solution.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
b_{21} & 1 & b_{23} & b_{24}\\
b_{31} & b_{32} & 1 & b_{34}\\
b_{41} & b_{42} & b_{43} & 1
\end{bmatrix}}_{B_0}
\end{bmatrix}}_{B_{0}}
\begin{bmatrix}
\Delta gnp_t\\
\Delta i_t\\
Expand Down Expand Up @@ -49,7 +49,7 @@
\Theta(1) = {A(1)}^{-1} B^{-1}_0
\end{align*}

Now let's derive the restrictions on the impact matrix \(B_0^{-1}\):
Now let's derive the restrictions on the impact matrix \(B_{0}^{-1}\):
\begin{itemize}
\item Money supply shocks do not have contemporaneous effects on output growth, i.e.\
\begin{align*}
Expand All @@ -63,7 +63,7 @@
\end{itemize}
Summarizing this yields two restrictions:
\begin{align*}
B_0^{-1} =
B_{0}^{-1} =
\begin{pmatrix}
* & 0 & 0 & *\\
* & * & * & *\\
Expand All @@ -72,7 +72,7 @@
\end{pmatrix}
\end{align*}

Next, let's derive the restrictions on the structural matrix \(B_0\):
Next, let's derive the restrictions on the structural matrix \(B_{0}\):
\begin{itemize}
\item Monetary authority does not react contemporaneously to changes in the price level.
This can be computed directly from equation~\eqref{eq:MS}:
Expand All @@ -82,7 +82,7 @@
\end{itemize}
Summarizing this yields one restriction:
\begin{align*}
B_0 =
B_{0} =
\begin{pmatrix}
1 & * & * & *\\
* & 1 & -b_{24} & b_{24}\\
Expand Down Expand Up @@ -110,7 +110,7 @@

Lastly, we need to keep in mind that the variance of the structural shocks is not normalized:
\begin{align*}
\Sigma_\varepsilon =
\Sigma_{\varepsilon} =
\begin{pmatrix}
\sigma_{11} & 0 & 0 & 0\\
0 & \sigma_{22} & 0 & 0\\
Expand Down
57 changes: 33 additions & 24 deletions exercises/svar_bootstrap_std_irf.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,56 @@
where the structural impulse response of variable \(i\) to shock \(j\) at horizon \(h\) are simply denoted as \(\theta \equiv \Theta_{ij,h}\).
As an exact closed-form solution for the asymptotic standard errors of \(\theta \) are only available under restrictive assumptions,
we will rely on a numerical approximation using a bootstrap approach.

\begin{enumerate}

\item Reconsider an exercise (of your choice) from the lecture on SVAR models identified with exclusion restrictions
and re-estimate the structural impulse response function.

\item Compute \(\widehat{std}(\hat{\theta}^\ast)\) via a bootstrap approximation by following these steps:
\item Compute \(\widehat{std}(\hat{\theta}^{\ast})\) via a bootstrap approximation by following these steps:

\begin{itemize}
\item Write a function \texttt{bootstrapDGP(VAR,opt)} which implements a standard residual-based bootstrap approach
using sampling with replacement techniques on the residuals.
Furthermore, the initial values should be drawn randomly in blocks.
Hint: Use the companion form to do the simulations.
\item Set bootstrap repetitions \(B\) equal to 1000 (or higher)
and initialize a \(K \times K \times H \times B\) array \texttt{THETAstar},
where the first dimension corresponds to variable \(i=1,\ldots,K\),
the second dimension to shock \(j=1,/ldots,K\),
the third dimension to the horizon of the IRFs \(h=0,\ldots,H\)
and the fourth dimension to the bootstrap repetition \(b=1.,\ldots,B\).
\item For \(b=1,\ldots,B\) do the following (you may also try \texttt{parfor} instead of \texttt{for}
in order to make use of Matlab's parallel computing toolbox -- if installed):
\begin{itemize}
\item Compute a bootstrap DGP \(y_t^{b}\) using the function \texttt{bootstrapDGP(VAR,opt)}.
\item Estimate the reduced-form and structural impulse response function on this artificial dataset
with the same methodology, settings and identification restrictions as in the estimation of the original dataset.
\item Store the structural IRFs in \texttt{THETAstar} at position \texttt{(:,:,:,b)}.
\end{itemize}
\item Compute the standard deviation of the bootstrap structural IRFs using \texttt{std(THETAstar,0,4)}.

\item Write a function \texttt{bootstrapDGP(VAR,opt)} which implements a standard residual-based bootstrap approach
using sampling with replacement techniques on the residuals.
Furthermore, the initial values should be drawn randomly in blocks.
Hint: Use the companion form to do the simulations.

\item Set bootstrap repetitions \(B\) equal to 1000 (or higher)
and initialize a \(K \times K \times H \times B\) array \texttt{THETAstar},
where the first dimension corresponds to variable \(i=1,\ldots,K\),
the second dimension to shock \(j=1,/ldots,K\),
the third dimension to the horizon of the IRFs \(h=0,\ldots,H\)
and the fourth dimension to the bootstrap repetition \(b=1.,\ldots,B\).

\item For \(b=1,\ldots,B\) do the following (you may also try \texttt{parfor} instead of \texttt{for}
in order to make use of Matlab's parallel computing toolbox---if installed):
\begin{itemize}
\item Compute a bootstrap DGP \(y_t^{b}\) using the function \texttt{bootstrapDGP(VAR,opt)}.
\item Estimate the reduced-form and structural impulse response function on this artificial dataset
with the same methodology, settings and identification restrictions as in the estimation of the original dataset.
\item Store the structural IRFs in \texttt{THETAstar} at position \texttt{(:,:,:,b)}.
\end{itemize}

\item Compute \texttt{std(THETAstar,0,4)}, i.e.\ the standard deviation of the bootstrapped structural IRFs.

\end{itemize}

\item Plot approximate 68\% and 95\% confidence intervals for the structural impulse response functions according to the Delta method:
\begin{align*}
\hat{\theta} \pm z_{\gamma/2} \widehat{std}(\hat{\theta}^\ast)
\hat{\theta} \pm z_{\gamma/2} \widehat{std}(\hat{\theta}^{\ast})
\end{align*}
where \(z_{\gamma/2}\) is the \(\gamma/2\) quantile of the standard normal distribution.
where \(z_{\gamma/2}\) is the \(\gamma/2\) quantile of the standard normal distribution.

\end{enumerate}

\paragraph{Readings}
\begin{itemize}
\item \textcite[Ch.~12.1-12.5, 12.9]{Kilian.Lutkepohl_2017_StructuralVectorAutoregressive}
\item \textcite[Ch.~12.1-12.5, 12.9]{Kilian.Lutkepohl_2017_StructuralVectorAutoregressive}
\end{itemize}

\begin{solution}\textbf{Solution to \nameref{ex:BootstrapStandardDeviationStructuralIRFs}}
\ifDisplaySolutions
\ifDisplaySolutions%
\input{exercises/svar_bootstrap_std_irf_solution.tex}
\fi
\newpage
Expand Down
3 changes: 2 additions & 1 deletion exercises/svar_bootstrap_std_irf_solution.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
\lstinputlisting[style=Matlab-editor,basicstyle=\mlttfamily,title=\lstname]{progs/matlab/bootstrapDGP.m}
The main script might look like this:
\lstinputlisting[style=Matlab-editor,basicstyle=\mlttfamily,title=\lstname]{progs/matlab/bootstrappingStdIRFs_RWZSRLR.m}
\end{enumerate}

\end{enumerate}
14 changes: 7 additions & 7 deletions exercises/svar_inference_exclusion_restrictions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
\item Given a bootstrap approximation to the distribution of the structural impulse-response function,
discuss how to construct bootstrap confidence intervals from this distribution.
Particularly, explain
\begin{enumerate}
\item intervals based on bootstrap standard errors
\item Efron's percentile interval
\item equal-tailed percentile-t intervals
\end{enumerate}
\begin{enumerate}
\item intervals based on bootstrap standard errors
\item Efron's percentile interval
\item equal-tailed percentile-t intervals
\end{enumerate}

\end{enumerate}

\paragraph{Readings}
\begin{itemize}
\item \textcite[Ch.~12.1-12.5, 12.9]{Kilian.Lutkepohl_2017_StructuralVectorAutoregressive}
\item \textcite[Ch.~12.1-12.5, 12.9]{Kilian.Lutkepohl_2017_StructuralVectorAutoregressive}
\end{itemize}

\begin{solution}\textbf{Solution to \nameref{ex:InferenceExclusionRestrictions}}
\ifDisplaySolutions
\ifDisplaySolutions%
\input{exercises/svar_inference_exclusion_restrictions_solution.tex}
\fi
\newpage
Expand Down
Loading

0 comments on commit 1a98287

Please sign in to comment.