diff --git a/data/MonPol.csv b/data/MonPol.csv new file mode 100644 index 0000000..eb15f60 --- /dev/null +++ b/data/MonPol.csv @@ -0,0 +1,86 @@ +dgdp,inflat,fed funds rate,, +0.939240246972531,0.914137586596212,8.48,, +0.843122236850036,0.904924207998135,7.92,, +1.54999133645754,0.62008351782157,7.9,, +0.756094702653513,1.01430099650548,8.1,, +0.956306794180819,0.518835205609321,7.83,, +0.400917820750806,-0.488564558274277,6.92,, +0.959518845097932,0.609877857869151,6.21,, +0.482179396011588,0.696746654012429,6.27,, +0.55289357398658,1.1994726899689,6.22,, +1.05779166601212,1.12690026375014,6.65,, +0.863554282913356,1.05572518456194,6.84,, +1.69657997768286,0.928578100790844,6.92,, +0.51593528175249,0.777320100269037,6.67,, +1.2761513356196,1.14115866259272,7.15,, +0.514958054456088,1.21151092708845,7.98,, +1.32643511685762,1.08651298691035,8.47,, +0.934488455384667,1.12991816560231,9.45,, +0.745465679198787,1.60296950426311,9.73,, +0.789965918233975,0.779110667406485,9.08,, +0.218043204841706,1.01171875514621,8.61,, +1.03925269786919,1.70622492868711,8.25,, +0.396649029724472,0.98472425861263,8.24,, +-0.00151373459800652,1.71224849275222,8.16,, +-0.879997005037126,1.68417097976436,7.74,, +-0.485601456353493,0.744788088341238,6.43,, +0.672662020935491,0.591862167050692,5.86,, +0.42036397971799,0.759096407979257,5.65,, +0.391244228963842,0.826008130222817,4.82,, +1.0916709746682,0.675834699750055,4.02,, +1.05693552650428,0.765808340327624,3.77,, +1.026541785988,0.760698488424737,3.26,, +1.04686285903847,0.871898124412837,3.03,, +0.183613797773887,0.725362703377186,3.04,, +0.637749724645801,0.719445100363373,3,, +0.525024119141904,0.461805042037724,3.06,, +1.31194669904812,0.825501533718125,2.99,, +0.968825346253311,0.500911638590139,3.21,, +1.35856988016224,0.566219442093995,3.94,, +0.642040395636741,0.922306012008789,4.49,, +1.10447774929628,0.580581339996229,5.17,, +0.245024000683657,0.731790089543381,5.8,, +0.214732454265459,0.813954527988813,6.02,, +0.836938846235967,0.503006303756763,5.8,, +0.694798123482656,0.543438824173506,5.72,, +0.682672279825965,0.88546310426085,5.37,, +1.71401154660157,0.85595465240516,5.24,, +0.866086053021149,0.573798195302231,5.31,, +1.085668340555,0.865285633720703,5.28,, +0.766172044013501,0.606976415822885,5.28,, +1.47176177580957,0.229638467415782,5.52,, +1.24730225387066,0.498754151103924,5.53,, +0.764257404176419,0.537730737805248,5.51,, +0.940237578622714,0.20576711094651,5.52,, +0.895200912177415,0.328472284315865,5.5,, +1.31083668654492,0.511814556968659,5.53,, +1.71615743695077,0.467787112568658,4.86,, +0.886879571751138,0.364890664115933,4.73,, +0.778666018654803,0.746299200136491,4.75,, +1.26364436082906,0.740172723716171,5.1,, +1.7801926989639,0.734734395483144,5.3,, +0.261047534918475,0.984845479638352,5.68,, +1.93185856258128,0.780602031862031,6.27,, +0.0835733500192646,0.909907477734237,6.52,, +0.590000716465397,0.710188940786338,6.47,, +-0.330271338003286,0.95221678378698,5.6,, +0.653598770300505,0.698521109071748,4.33,, +-0.274541606086132,0.281876127396004,3.5,, +0.352576440374378,-0.0749015192718616,2.13,, +0.855198292057935,0.31892750485963,1.73,, +0.529201025205111,0.783146305174228,1.75,, +0.498462251350361,0.536817071291011,1.74,, +0.0206421538518953,0.589613597618495,1.44,, +0.404351781447531,1.02339553580453,1.25,, +0.794435538282187,-0.16374030086024,1.25,, +1.66222980750285,0.743404784218228,1.02,, +0.89544976785362,0.378823180229801,1,, +0.701736071090977,0.842856484884919,1,, +0.708219043205077,0.782681585154705,1.01,, +0.73185231498644,0.635706474767517,1.43,, +0.863886566189876,1.06785478719553,1.95,, +0.99286446714143,0.503952683039529,2.47,, +0.425307133731621,0.67351835034674,2.94,, +0.756753882741123,1.50310183603494,3.46,, +0.515464977792135,0.928030395145925,3.98,, +1.30328254543576,0.519729744923097,4.45,, \ No newline at end of file diff --git a/exam/midterm_exam_WS2324.tex b/exam/midterm_exam_WS2324.tex new file mode 100644 index 0000000..0f4dcdf --- /dev/null +++ b/exam/midterm_exam_WS2324.tex @@ -0,0 +1,219 @@ +% !TeX encoding = UTF-8 +% !TeX spellcheck = en_US +% !TEX root = midterm_exam_WS2324.tex +\documentclass{article} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage[a4paper,top=2cm]{geometry} +\usepackage{amssymb,amsmath,amsfonts} +\usepackage[english]{babel} +\usepackage[a4paper]{geometry} +\usepackage{enumitem} +\usepackage{booktabs} +\usepackage{csquotes} +\usepackage{graphicx} +\usepackage[numbered,framed]{matlab-prettifier} +\usepackage{url} +%\parindent0mm +%\parskip1.5ex plus0.5ex minus0.5ex +\usepackage[backend=biber,style=authoryear]{biblatex} +\addbibresource{../literature/_biblio.bib} +\begin{document} + +\title{Quantitative Macroeconomics} +\author{Midterm Exam} +\date{Winter 2023/2024} +\maketitle + +\section*{General information} +\begin{itemize} + \item Answer \textbf{all} of the following \textbf{four} exercises in English. + \item All assignments will be given the same weight in the final grade. + \item Hand in your solutions before January, 10 2024 at 3pm. + \item The solution files should contain your executable (and commented) script files + as well as all additional documentation as \texttt{pdf}, not \texttt{txt}, \texttt{md}, \texttt{tex}, \texttt{doc} or \texttt{docx}. + Your \texttt{pdf} files may also include scans or pictures of handwritten notes. + \item Please e-mail ALL the solution files to \url{willi.mutschler@uni-tuebingen.de}. + I will confirm the receipt of your work also by email (typically within the hour). If not, please resend it to me. + \item All students must work on their own, please also give your student ID number and the name of the module you want to earn credits for. + \item It is advised to regularly check Ilias and your emails in case of urgent updates. + \item If there are any questions, do not hesitate to contact Willi Mutschler. +\end{itemize} + +\newpage + + +\section[Theoretical and Simulated Moments]{Theoretical and Simulated Moments\label{ex:TheoreticalAndSimulatedMoments}} +\begin{enumerate} + \item Derive the unconditional first two moments (i.e.\ theoretical mean, covariance and autocovariance matrix) of the covariance stationary VAR(1) model: \(y_t = \nu + A y_{t-1} + u_t\) + \item Simulate \(R=100\) datasets each with \(T=100\) observations for + \begin{align*} + y_t = \begin{pmatrix}0.2 &0.3 \\-0.6 & 1.1 \end{pmatrix} y_{t-1} + u_t + \end{align*} + provided that \(u_t \sim WN(0,\Sigma_u)\) and \(\Sigma_u = \begin{pmatrix}0.9 & \\ 0.2 & 0.5 \end{pmatrix}\). + \item Compute the sample mean and sample covariance matrix for each of the \(R\) datasets. + Then take the average and compare the results with part (1). + \item How does your choice of \(R\) or \(T\) change your results? + +\end{enumerate} + +\newpage + + +\section{Properties Of Lag-Order Selection Criteria} +Assume that the true Data-Generating-Process (DGP) follows the following VAR(4) model +\begin{align*} +y_t = \begin{pmatrix} +2.4 & 1.0\\ +0 & 1.1 +\end{pmatrix} +y_{t-1}+ +\begin{pmatrix} +-2.15 & -0.9\\ +0 & -0.41 +\end{pmatrix} +y_{t-2}+ +\begin{pmatrix} +0.852 & 0.2\\ +0& 0.06 +\end{pmatrix} +y_{t-3}+ +\begin{pmatrix} +-0.126 & 0\\ +0 & 0.0003 +\end{pmatrix} +y_{t-4} ++ u_t +\end{align*} +where \(u_t\) is a Gaussian white noise with contemporary covariance matrix \(\Sigma_u = \begin{pmatrix} +0.9&0.2\\0.2&0.5 +\end{pmatrix}\). + +Perform a Monte-Carlo analysis to study both the finite-sample as well as asymptotic properties +of the Akaike Information Criterion (AIC) and the Schwarz Information Criterion (SIC): +\begin{align*} +AIC(m) &= \log(det(\tilde{\Sigma}_u(m))) + \frac{2}{T}\varphi(m)\\ +SIC(m) &= \log(det(\tilde{\Sigma}_u(m))) + \frac{\log T}{T}\varphi(m) +\end{align*} +where \(\tilde{\Sigma}_u=T^{-1}\sum_{t=1}^T \hat{u}_t\hat{u}_t'\) is the residual covariance matrix estimator +for a reduced-form VAR model of order $m$ based on OLS residuals \(\hat{u}_t\). +The function \(\varphi(m)\) corresponds to the total number of regressors in the system of VAR equations. +The VAR order is chosen such that the respective criterion is minimized over the possible orders \(m = 0,\ldots,p^{max}\). +To this end, do the following. + +\begin{itemize} + \item Set the number of Monte Carlo repetitions \(R=100\) and \(p^{max}=8\). + \item Initialize output matrices \(aic\) and \(sic\) each of dimension \(R \times 5\). + \item For \(r=1,\ldots,R\) do the following: + \begin{itemize} + \item Simulate \(10100\) observations for the DGP given above and discard the first 100 observations as burn-in phase. + Save the remaining 10000 observations in a matrix \(Y\). + \item Compute the lag criteria for 5 different sample sizes \(T=\{80, 160, 240, 500, 10000\} \), + i.e.\ use the last \(T\) observations of your simulated data matrix \(Y\) for computations. + \item Save the chosen lag order in the corresponding output object at position \([r,j]\) where \(j=1,\ldots,5\) indicates the corresponding sample size. + \end{itemize} + \item Look at the frequency tables of your output objects for the different subsamples. Hint: \texttt{tabulate(aic(:,1))} displays a frequency table for the AIC criterion with sample size equal to 80. +\end{itemize} +Given your results, do you agree with the following (general) findings? +\begin{enumerate} + \item AIC is not consistent for the true lag order, whereas SIC is consistent. + \item AIC never (asymptotically) selects a lag order that is lower than the true lag order. + \item In finite samples, we usually have \(\hat{p}_{SIC} \leq \hat{p}_{AIC}\). + \item In finite samples, AIC has a tendency to overestimate the lag order, SIC has a tendency to underestimate the lag order; hence, one should rely on AIC in finite samples. +\end{enumerate} + +\newpage + +\section[Sign-identified Monetary SVAR Model for US]{Sign-identified Monetary SVAR Model for US\label{ex:SignIdentifiedMonetarySVARUS}} +Consider data for \(y_t = (\Delta gnp_t,\Delta p_t,i_t)'\), + where \(gnp_t\) denotes the log of U.S. real GNP, + \(p_t\) the consumer price index in logs, + and \(i_t\) the federal funds rate. + Data is given in the csv file \texttt{MonPol.csv} containing the sample period of 1970Q1 to 2011Q1. + +We will use the following sign restrictions pattern to identify the structural shocks: +\begin{align} +B_0^{-1}=\begin{bmatrix} + + & + & -\\ + + & - & -\\ + + & * & + + \label{eq:signpattern} +\end{bmatrix} +\end{align} +where \(*\) denotes an unrestricted value. + +\begin{enumerate} +\item Read the short summary paper by \textcite{Wolf_2022_WhatCanWe} and provide economic intuition for the pattern given in equation \eqref{eq:signpattern}. +\item Write a script that estimates the structural impulse response function via sign restrictions. +To this end: + \begin{itemize} + \item Estimate a VAR(4) model with constant by using ordinary least-squares. + Compute the lower Cholesky decomposition of your estimated residual covariance matrix, i.e.\ \( P = chol(\hat{\Sigma}_u) \). + \item Set the IRF horizon \(H=20\) and the number of required sign-identified draws to \(N=1000\). + \item Initialize an array \texttt{IRFvals} of dimension + (i) number of variables \(K\) by (ii) number of shocks \(K\) by (iii) horizon \(H\) by (iv) number of draws \(N\). + This array will store \(n=1,\ldots,N\) sign-identified impulse response functions \(\theta_{jkhn}\) for variable \(j=1,\ldots,K\) + with respect to shock \(k=1,\ldots,K\) at horizon \(h=0,\ldots,H\), where \(K\) is the number of variables. + + \item Initialize \texttt{n=1} and write a while loop that executes the following steps: + \begin{itemize} + \item Draw an orthogonal rotation matrix \(Q\) using the function \texttt{drawRotationMatrixQ.m} in the appendix. + \item Compute the implied rotated impact matrix \(\widetilde{B}_0^{-1}=PQ\). + \item Note that \(\widetilde{B}_0^{-1}\) is a valid impact matrix, because \(\hat{\Sigma}_u = \widetilde{B}_0^{-1} \widetilde{B}_0^{-1'}\). + However, we will only accept those impact matrices \(\widetilde{B}_0^{-1}\) that full-fill the sign restrictions in equation~\eqref{eq:signpattern}. + Therefore, use if statements to check whether \(\widetilde{B}_0^{-1}\) is a valid impact matrix: + \begin{itemize} + \item If the pattern is correct, increase \(n\) by 1 and compute the implied IRFs. Store these into \texttt{IRFvals(:,:,:,n)}. + \item If the pattern is incorrect, don't change the value of \(n\), discard this draw and go back to the beginning of the loop. + \end{itemize} + \item End the while loop if \texttt{n=N}. + \end{itemize} + \item Plot \textbf{ALL} \(N\) impulse response functions that full-fill the sign pattern for (i) the level of GDP, (ii) CPI inflation and (iii) the Federal Funds rate. + \\Hint: The graphs should look similar to figure~\ref{fig:signSVAR} in the appendix. + That is, in each subplot compute and plot \texttt{IRFS = squeeze(IRFvals(ivar,ishock,1:nsteps,:))}. + \end{itemize} +\end{enumerate} + +\newpage + +\section[Historical Decomposition]{Historical Decomposition} +Reconsider the SVAR model of \textcite{Rubio-Ramirez.Waggoner.Zha_2010_StructuralVectorAutoregressions} +(i.e. the exercise called \emph{Combining Short-Run And Long-Run Restrictions}). + +A historical decomposition is a tool to quantify how important a structural shock was +in driving the behavior of the endogenous variables in a specific time period in the past. +It allows to track at each point in time the role of structural shocks +in driving the VAR's endogenous variables away from their steady state. + +Given the notation used in the lecture, the historical decomposition for a VAR(1) +is based on the following recursive Wold representation: +\begin{align*} +y_t = A^t y_0 + \sum_{j=0}^{t-1} A^j B_0^{-1} \varepsilon_{t-j} +\end{align*} +Therefore, the historical decomposition of say \(y_{2}\) is given as a function of present and past structural shocks +plus the initial condition: +\begin{align*} +y_{2} = \underbrace{A^2 y_0}_{\text{initial}} + \underbrace{A B_0^{-1}}_{\Theta_1} \varepsilon_{1} + \underbrace{B_0^{-1}}_{\Theta_0} \varepsilon_{2} +\end{align*} +Write an algorithm to compute the historical decomposition of the federal funds rate with respect to the three shocks in the model. + +Hints: +\begin{itemize} + \item Use the companion form. +\end{itemize} + +\newpage +\appendix + +\printbibliography +\newpage +\section{Codes} +\lstinputlisting[label=drawRotationMatrixQ,title=\lstname,style=Matlab-editor,basicstyle=\footnotesize\mlttfamily,title=\lstname]{../progs/matlab/drawRotationMatrixQ.m} + +\newpage + +\section{Figures} +\begin{figure}[htbp]\caption[]{Sign-identified IRFs}\label{fig:signSVAR} + \includegraphics[width=\textwidth]{../plots/signIRFs.jpg} +\end{figure} + +\end{document} \ No newline at end of file diff --git a/literature/_biblio.bib b/literature/_biblio.bib index 91995bf..434fb43 100644 --- a/literature/_biblio.bib +++ b/literature/_biblio.bib @@ -318,6 +318,18 @@ @incollection{Ploberger_2010_LawLargeNumbers isbn = {978-0-230-23885-5 978-0-230-28083-0} } +@article{Rubio-Ramirez.Waggoner.Zha_2010_StructuralVectorAutoregressions, + title = {Structural {{Vector Autoregressions}}: {{Theory}} of {{Identification}} and {{Algorithms}} for {{Inference}}}, + author = {{Rubio-Ram{\'i}rez}, Juan F. and Waggoner, Daniel F. and Zha, Tao}, + year = {2010}, + month = apr, + journal = {Review of Economic Studies}, + volume = {77}, + number = {2}, + pages = {665--696}, + doi = {10.1111/j.1467-937X.2009.00578.x} +} + @incollection{Schorfheide_2010_BayesianMethodsMacroeconometrics, title = {Bayesian Methods in Macroeconometrics}, booktitle = {Macroeconometrics and {{Time Series Analysis}}},