%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Beamer Presentation
% LaTeX Template
% Version 1.0 (10/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ----------------------------------------------------------------------------------------
%	PACKAGES AND THEMES
% ----------------------------------------------------------------------------------------

\documentclass[hyperref={colorlinks=true}]{beamer}

\mode<presentation> {

  % The Beamer class comes with a number of default slide themes
  % which change the colors and layouts of slides. Below this is a list
  % of all the themes, uncomment each in turn to see what they look like.

  \usetheme{default}
  % \usetheme{AnnArbor}
  % \usetheme{Antibes}
  % \usetheme{Bergen}
  % \usetheme{Berkeley}
  % \usetheme{Berlin}
  % \usetheme{Boadilla}
  % \usetheme{CambridgeUS}
  % \usetheme{Copenhagen}
  % \usetheme{Darmstadt}
  % \usetheme{Dresden}
  % \usetheme{Frankfurt}
  % \usetheme{Goettingen}
  % \usetheme{Hannover}
  % \usetheme{Ilmenau}
  % \usetheme{JuanLesPins}
  % \usetheme{Luebeck}
  % \usetheme{Madrid}
  % \usetheme{Malmoe}
  % \usetheme{Marburg}
  % \usetheme{Montpellier}
  % \usetheme{PaloAlto}
  % \usetheme{Pittsburgh}
  % \usetheme{Rochester}
  % \usetheme{Singapore}
  % \usetheme{Szeged}
  % \usetheme{Warsaw}

  % As well as themes, the Beamer class has a number of color themes
  % for any slide theme. Uncomment each of these in turn to see how it
  % changes the colors of your current slide theme.

  % \usecolortheme{albatross}
  % \usecolortheme{beaver}
  % \usecolortheme{beetle}
  % \usecolortheme{crane}
  % \usecolortheme{dolphin}
  % \usecolortheme{dove}
  % \usecolortheme{fly}
  % \usecolortheme{lily}
  % \usecolortheme{orchid}
  \usecolortheme{rose}
  % \usecolortheme{seagull}
  % \usecolortheme{seahorse}
  % \usecolortheme{whale}
  % \usecolortheme{wolverine}

  % \setbeamertemplate{footline} % To remove the footer line in all slides uncomment this line
  % \setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line

  % \setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line
}

\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{cancel}
\usepackage{amsmath}
\usepackage{amssymb}
% \usepackage{showframe}
\usepackage{caption}

%\usepackage{subcaption}
\usepackage{tcolorbox}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{array}
\usepackage{pgfplots}
\tcbuselibrary{skins}


\usepackage{subfig}
\beamertemplatenavigationsymbolsempty
\usepackage{color, colortbl}
\definecolor{LRed}{rgb}{1,.8,.8}
\definecolor{MRed}{rgb}{1,.6,.6}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shapes.multipart,fit,shapes.misc,positioning}
\newcommand{\der}[2]{\frac{\partial #1}{\partial #2}}
%\usepackage[labelformat=empty]{caption}

\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}

\newcommand\marktopleft[1]{%
    \tikz[overlay,remember picture]
        \node (marker-#1-a) at (0,1.5ex) {};%
}
\newcommand\markbottomright[1]{%
    \tikz[overlay,remember picture]
        \node (marker-#1-b) at (7ex,0) {};%
    \tikz[overlay,remember picture,thick,dashed,inner sep=3pt]
        \node[draw=black,rounded corners=0pt,fill=red,opacity=.2,fit=(marker-#1-a.center) (marker-#1-b.center)] {};%
}


% ----------------------------------------------------------------------------------------
%	TITLE PAGE
% ----------------------------------------------------------------------------------------

\title[]{Macro II} % The short title appears at the bottom of every slide, the full
% title is only on the title page

\author{Professor Griffy} % Your name
\institute[University at Albany, SUNY] % Your institution as it will appear on the bottom of
% every slide, may be shorthand to save space
{
UAlbany  \ % Your institution for the title page
}
\date{Spring 2023} % Date, can be changed to a custom date

\begin{document}

\begin{frame}
  \titlepage % Print the title page as the first slide
\end{frame}



%----------------------------------------------------------------------------------------
%	PRESENTATION SLIDES
%----------------------------------------------------------------------------------------

% ------------------------------------------------
\section{Introduction} % Sections can be created in order to organize your presentation into discrete blocks, all sections and subsections are automatically printed in the table of contents as an overview of the talk
% ------------------------------------------------

\begin{frame}
  \frametitle{Announcements}
  \begin{itemize}
  \item Exams are in the process of being graded.
  \item I heard nothing about the baseball extra credit!
  \item Homework 5 due next Thursday, homework 6 due May 4th.
  \item Today: Start heterogeneous agent model.s
  \item First: Huggett and Aiyagari.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Thinking about Uncertainty in Macroeconomic Models}
  \begin{itemize}
  \item Typical assumptions in macroeconomics are a convex combination of
    \begin{enumerate}
    \item certainty equivalence:
    \begin{align}
      u'(\bar{c}_{i,t}) &= \beta E[(1 + \underbrace{r_{t + 1}}_{GE})\underbrace{u'(\bar{c}_{i,t+1})}_{Closer\;to\;Linear}]
    \end{align}
  \item linearized decision rules:
    \begin{align}
      \sum_{i = 1}^{N}&((1 + r_{t + 1})a_{i,t + 1} + w_{i,t + 1} - c_{i,t + 1} - a_{i,t + 2}) = 0\\
      \sum_{i = 1}^{N}&((1 + r_{t + 1})\beta_{a}\hat{S}_{i,t + 1} + \beta_{w}(\hat{S}_{i,t + 1}) - \beta_{c}\hat{S}_{i,t + 1} - \beta_{a}\hat{S}_{i,t + 2}) = 0
    \end{align}
  \end{enumerate}
\item Trick in Krusell-Smith: assume that workers make a linear prediction about prices in the future.
\item i.e., workers use OLS to predict future prices.
\end{itemize}
\end{frame}

% ------------------------------------------------

\section{Idiosyncratic Uncertainty in a Production Economy} % Sections can be created in order to organize your presentation into discrete blocks, all sections and subsections are automatically printed in the table of contents as an overview of the talk

% ------------------------------------------------

\begin{frame}
  \frametitle{Heterogeneous Agent Models}
  \begin{itemize}
  \item Workers change their behavior in response to uncertainty.
  \item First wave of heterogeneous agent models: how do aggregates change when {\it individual idiosyncratic} uncertainty is uninsurable.
  \item In other words: when agents must accumulate {\it precautionary savings} to insure against income shocks.
  \item Key ``first wave'' papers (no particular order):
    \begin{itemize}
    \item Huggett (1993): Incomplete markets exchange economy with GE interest rate.
    \item Imrohoroglu (1989): Individual and aggregate uncertainty with fixed interest rate.
    \item Aiyagari (1994): Incomplete markets production economy with GE interest rate.
    \item Bewley (1986): Individual uncertainty with fixed interest rate.
    \end{itemize}
  \item Krusell and Smith (1998): individual and aggregate uncertainty with GE interest rate.
  \item Do this using an approximation to the aggregate evolution of capital.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Heterogeneous Agent Models}
  \begin{itemize}
  \item We can write a generic worker's problem as
    \begin{align}
      \max_{\{c_{t},i_{t},l_{t}\}_{t=0}^{\infty}}& E \sum_{t = 0}^{\infty}\beta^{t}u(c_{t})\\
      \text{s.t.  } c_{t} + i_{t} &\leq r_{t}a_{t} + w_{t}l_{t}\\
      a_{t + 1} &= (1 - \delta)a_{t} + i_{t}\\
      a_{t + 1} &\geq \underline{a}_{t} \\
      w_{t} &\sim F\\
      c_{t}\geq 0&, l_{t}\geq 0, a_{0}\text{ given}
    \end{align}
  \item How we deal with prices $r_{t}, w_{t}$ and choices $c_{t}, i_{t}, l_{t}$ is central to equilibrium.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Recursive Formulation}
  \begin{itemize}
  \item Can be written as
    \begin{align}
      V(a)&= u(c) + \beta E[V(a')]\\
      \text{s.t.  } c + i &\leq ra + wl\\
      a' &= (1 - \delta)a + i\\
      a' &\geq \underline{a} \\
      w &\sim F\\
      c\geq 0&, l\geq 0, a_{0}\text{ given}
    \end{align}
  \item Under fairly general conditions, this inherits same properties as non-stochastic version.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Huggett (1993)}
  \begin{itemize}
  \item Endowment economy, no aggregate risk.
  \item Setup:
    \begin{itemize}
    \item Discrete time;
    \item Continuum of heterogeneous agents;
    \item Idiosyncratic endowment risk (labor income stochastic).
    \end{itemize}
  \item Single bond, $a$, can be borrowed or saved.
  \item Borrowling limit, $\underline{a}\leq 0 \leq a_{it}$
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Idiosyncratic Markov Income Uncertainty}
  \begin{itemize}
  \item Suppose $wl = e$, $F[e'] = \pi(e'|e)$
  \item Two states: $e_{l}, e_{h}$
  \item Can be written as
    \begin{align}
      V(a,e)&= u(c) + \beta\sum_{e'}\pi(e'|e)V(a',e')\\
      \text{s.t.  } c + a' &\leq (1 + r)a + e\\
      a' &\geq \underline{a} \\
      c\geq 0&, a_{0}\text{ given}
    \end{align}
  \item Agents want to build precautionary savings again idiosyncratic risk.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Equilibrium}
  \begin{itemize}
  \item Define a distribution of agents over assets $as$ and endowments $e$, $\psi$.
  \item Stationary equilibrium: aggregate state ($\psi$) is unchanging.
  \item Agents move around distribution, but LLN $\rightarrow$ $\psi' = \psi$
  \item Define $\psi(B)$ such that given transition function $P$:
    \begin{align}
      \psi(B) &= \int_{S}P(x, B)d\psi
    \end{align}
  \item $P(x, B)$ the probability that an agent with state $x$ will have state $B\in\beta_{S}$ next period.
  \item $B$ is a subset of the state space.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Stationary Equilibrium}
  \begin{itemize}
  \item Roughly summarizing Huggett, 1993:
    A stationary equilibrium for this economy is a tuple ($c, a', r, \psi$) that satisfy
    \begin{enumerate}
    \item $c$ and $a'$ solve the workers problem taking prices as given.
    \item Markets clear:
      \begin{enumerate}
      \item consumption = production: $\int c(x)d\psi = \int ed\psi$
      \item no net savings: $\int a(x)d\psi = 0$
      \end{enumerate}
    \item $\psi$ is stationary:
      \begin{align}
      \psi(B) &= \int_{S}P(x, B)d\psi
      \end{align}
      for all $B\in\beta_{S}$
    \end{enumerate}
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Aiyagari (1994)}
  \begin{itemize}
  \item Production economy, no aggregate risk.
  \item Firms employ capital, households save using capital (really assets loaned/borrowed from firm).
  \item Setup:
    \begin{itemize}
    \item Discrete time;
    \item Continuum of heterogeneous agents;
    \item Idiosyncratic hours shocks (labor supply stochastic).
    \end{itemize}
  \item Capital, $k$, can be borrowed or saved.
  \item Borrowling limit, $\underline{k}\leq 0 \leq k_{it}$
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Heterogeneous Agent Production Economy}
  \begin{itemize}
  \item In a production economy, the agent's problem is given by
    \begin{align}
      V(k,\epsilon;\psi)&= u(c) + \beta E[V(k'\epsilon';\psi')]\\
      \text{s.t.  } c + k' &\leq (1 + r(K,L) - \delta)k + w(K,L)\epsilon\\
      k'&\geq \underline{k}\\
      \epsilon&\sim\text{ Markov} P(\epsilon'|\epsilon)\\
      \psi' &= \Psi(\psi)\\
      c\geq 0&, k\geq 0, k_{0}\text{ given}
    \end{align}
  \item $\epsilon$ is a markov process that yields hours worked.
  \item $\Psi$ is an unspecified evolution of the aggregate state $(k,\epsilon)$.
  \item Prices are determined from the firm's problem
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Prices - The Firm's Problem}
  \begin{itemize}
  \item How we handle prices determines the difficulty of this problem.
  \item In this economy, a single firm produces using labor (hours) and capital.
    \begin{align}
      \Pi&= \max_{K,L} F(K,L) - wL - rK
    \end{align}
  \item This yields standard competitive prices for the rental rates.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Information}
  \begin{itemize}
  \item What information do workers need in order to be able to solve this problem?
  \item Current period:
    \begin{itemize}
    \item interest rate, $r(K,L)$. This is known from being told the aggregates at the beginning of the period.
    \item wage rate, $w(K,L)$. This is known from being told the aggregates at the beginning of the period.
    \end{itemize}
  \item Future:
    \begin{itemize}
    \item interest rate and wage rate next period.
    \item These depend on capital and labor next period.
    \item Thus, workers need to predict capital and labor in future.
    \end{itemize}
  \item Rep. Agent model: just need to know their own decision rule.
  \item Here: need to know distribution across workers, and their decision rules.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Stationary Recursive Competitive Equilibrium}
  \begin{itemize}
  \item A stationary RCE is given by pricing functions $r, w$, a worker value function $V(k,\epsilon;\psi)$, worker decision rules $k', c$, a type-distribution $\psi(k,\epsilon)$, and aggregates $K$ and $L$ that satisfy
    \begin{enumerate}
    \item $k'$ and $c$ are the optimal solutions to the worker's problem given prices.
    \item Prices are formed competitively from the firm's problem.
    \item Consistency between aggregate evolution and individual decision rules: $\psi$ is the stationary distribution implied by worker decision rules.
    \item Aggregates are consistent with individual policy rules: $K = \int k d\psi$, $L = \int \epsilon d\psi$
    \end{enumerate}
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Return to Capital}
  \begin{itemize}
  \item How does return to capital vary by
\begin{itemize}
  \item serial corr. ($\rho$) in labor income (think AR1 process)
  \item and CRRA ($\mu$)?
\end{itemize}
  \end{itemize}
\centering\includegraphics[width=0.7\textwidth]{./AiyagariNetReturnCapital.png}
\begin{itemize}
\item Higher $\rho$ or $\mu$, more saving, lower return.
\end{itemize}
\end{frame}

% ------------------------------------------------

% \begin{frame}
%   \frametitle{A Solution Technique: The Shooting Algorithm}
%   \begin{itemize}
%   \item If you think this could be tricky to solve... you're right!
%   \item What must the equilibrium prices satisfy?
%     \begin{align}
%       r &= F_{K}(K_{D},L)\\
%       K_{D}(r) &= K_{S}(r)
%     \end{align}
%   \item Fixing $K_{D}$ or $r$ yields the other variable.
%   \item Thus, one approach is to ``guess'' the equilibrium and iterate until we guess correctly.
%   \end{itemize}
% \end{frame}

% % ------------------------------------------------

% \begin{frame}
%   \frametitle{A Solution Technique: The Shooting Algorithm}
%   \begin{itemize}
%   \item Guess $r$. Yields $K_{D}$ and $w$ from $r = F_{K}(K_{D},L)$ and $w = F_{L}$.
%   \item Now, given this price, calculate the {\it individual} savings rule.
%   \item Simulate the economy far enough into future to reach a steady-state distribution of capital.
%   \item Check and see if $K_{D} = K_{S}$.
%   \item If not, adjust guess of interest rate according to following:
%     \begin{align}
%       r' &= r + \lambda (K_{D} - K_{S})
%     \end{align}
%   \item where $\lambda < 1$
%   \end{itemize}
% \end{frame}

% % ------------------------------------------------

% \begin{frame}
%   \frametitle{Another Solution technique: Root-Finding and Excess Demand}
%   \begin{itemize}
%   \item Functionally, this is the same as what we just did.
%   \item Suppose we solve household decision rules $k, \epslion$ and $r$.
%   \item Then, the excess demand function is
%     \begin{align}
%       \Delta(r) &= K_{D}(r) - K_{S}(r)
%     \end{align}
%   \item Where we have solved $K_{D}$ for many values of $r$ and have an expression for $K_{S}(r)$ (static firm optimization).
%   \item Do one-dimensional root finding, i.e., find $r^{*}$ such that
%     \begin{align}
%       0 = \Delta(r^{*}) &= K_{D}(r^{*}) - K_{S}(r^{*})
%     \end{align}
%   \end{itemize}
% \end{frame}

% ------------------------------------------------

\section{Individual and Aggregate Uncertainty} % Sections can be created in order to organize your presentation into discrete blocks, all sections and subsections are automatically printed in the table of contents as an overview of the talk

% ------------------------------------------------

\begin{frame}
  \frametitle{Krussell-Smith (1998)}
  \begin{itemize}
  \item In the previous model, we relied on the aggregate {\it certainty} of $\psi(k, \epsilon)$ for a solution by appealing to the law of large numbers.
  \item i.e., individuals move around the distribution, but those shocks offset and in the aggregate the distribution is unchanged.
  \item But what happens if there is aggregate {\it uncertainty}?
  \item Now the distribution changes in the equilibrium, and we need a way to incorporate this into worker decision rules.
  \item Krussell-Smith: Aiyagari + aggregate shocks.
  \item Some details:
    \begin{itemize}
    \item Idiosyncratic labor shock \{0,1\} markov.
    \item Aggregate shocks.
    \item Idiosyncratic shock prob. changes with agg. shocks.
    \end{itemize}
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Aggregate Uncertainty}
  \begin{itemize}
  \item In a production economy, the agent's problem is given by
    \begin{align}
      V(k,\epsilon,z;\psi)&= u(c) + \beta E[V(k'\epsilon',z';\psi')]\\
      \text{s.t.  } c + k' &\leq (1 + r(z,K,L) - \delta)k + w(z,K,L)\epsilon\\
      k'&\geq \underline{k}\\
      z' &= \text{ Markov} P(z'|z)\\
      \epsilon&\sim\text{ Markov} P(\epsilon'|\epsilon,z')\\
      \psi' &= \Psi(\psi,z,z')\\
      c\geq 0&, k\geq 0, k_{0}\text{ given}, z_{0}\text{ given}
    \end{align}
  \item $\epsilon$ is a markov process for employment $\epsilon\in\{0, 1\}$
  \item $\Psi$ is an unspecified evolution of the aggregate state.
  \item $z$ {\it also} evolves as a markov process.
  \item Prices are determined from the firm's problem.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Prices - The Firm's Problem}
  \begin{itemize}
  \item How we handle prices determines the difficulty of this problem.
  \item In this economy, a single firm produces using labor (hours) and capital.
    \begin{align}
      \Pi&= \max_{K,L} zF(K,L) - wL - rK
    \end{align}
  \item This yields standard competitive prices for the rental rates.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Laws of Motion}
  \begin{itemize}
  \item The future aggregate state enters the probability of employment.
  \item This means that it impacts {\bf all} of the laws of motion:
    \begin{align}
      z' &= \text{ Markov} P(z'|z)\\
      \epsilon&\sim\text{ Markov} P(\epsilon'|\epsilon,z')\\
      k' &\leq (1 + r(z,K,L) - \delta)k + w(z,K,L)\epsilon - c\\
      \psi' &= \Psi(\psi,z,z')
    \end{align}
  \item Because shocks to $z$ change employment status and prices.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Recursive Competitive Equilibrium}
  \begin{itemize}
  \item An  RCE is given by pricing functions $r, w$, a worker value function $V(k,\epsilon,z;\psi)$, worker decision rules $k', c$, a type-distribution $\psi(k,\epsilon)$, and aggregates $K$ and $L$ that satisfy
    \begin{enumerate}
    \item $k'$ and $c$ are the optimal solutions to the worker's problem given prices.
    \item Prices are formed competitively from the firm's problem.
    \item Consistency between aggregate evolution and individual decision rules: $\psi$ is the distribution implied by worker decision rules given the aggregate state.
    \item Aggregates are consistent with individual policy rules: $K = \int k d\psi$, $L = \int \epsilon d\psi$
    \end{enumerate}
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Type Distribution}
  \begin{itemize}
  \item The type distribution is a problem.
  \item Each policy function and transition depends on the type distribution.
  \item But the type distribution is time-varying in response to aggregate shocks.
  \item Alternative: use a smaller number of moments that can be calculated quickly to characterize the type distribution.
  \item Like a ``sufficient statistic'' for the type distribution.
  \item Discuss the solution to this next time.
  \end{itemize}
\end{frame}

% ------------------------------------------------

\begin{frame}
  \frametitle{Business Cycle Effects}
  \begin{itemize}
  \item This model is built to handle stochastic shocks.
  \item How do heterogeneous agents respond over a business cycle?
  \end{itemize}
\centering\includegraphics[width=0.7\textwidth]{./KSTimeSeries.png}
\end{frame}

% ------------------------------------------------

\section{Conclusion}
% ------------------------------------------------


\begin{frame}
  \frametitle{Conclusion}
  \begin{itemize}
  \item Next time: Solving heterogeneous agent models.
  \end{itemize}
\end{frame}


\end{document}
