%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 2026} % 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 Today: Solving heterogeneous agent models.
  \item Idea:
    \begin{itemize}
    \item Solving these models is non-trivial.
    \item Must consider the state of every agent in economy.
    \end{itemize}
  \item Homework: start from the code on the cluster.
  \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 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{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{Calibration}
  \begin{itemize}
  \item Functions:
    \begin{itemize}
    \item Utility: $u(c) = \frac{c^{1 - \sigma}}{1 - \sigma}$
    \item Production: $F(K,L) = K^{\alpha}L^{1 - \alpha}$
    \end{itemize}
  \item Borrowing constraint: $\underline{k} = 0$
  \item $\alpha = 0.36$.
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{Solving the Model: Market Clearing}
  \begin{itemize}
  \item In equilibrium
    \begin{align}
      K &= \sum_{k}\sum_{\epsilon}k_{s}(k,\epsilon)\psi(k,\epsilon)
    \end{align}
  \item where $k_{s}$ is the supply of savings.
  \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 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{A Solution Technique: The Shooting Algorithm}
  \begin{itemize}
  \item Adjusting interest rates:
    \begin{align}
      r' &= r + \lambda (K_{D} - K_{S})
    \end{align}
  \item If $K_{S} > K_{D}$: too much savings.
  \item Interest rate must fall to be in equilibrium.
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{First iteration}
  \begin{itemize}
  \item Initial guess:
    \begin{itemize}
    \item $r_{0} = 0.03093$
    \end{itemize}
  \item Three aggregates:
    \begin{enumerate}
    \item $K = 8.8342$
    \item $L = 0.8582$
    \item $\rightarrow\;r = F_{K}=0.0204$
    \end{enumerate}
  \item $r - r_{0} < errtol$? $0.0309 - 0.0204$ too large.
  \item Algorithm: fzero $\rightarrow$ pick local $r_{1}$ and try again.
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{Second iteration}
  \begin{itemize}
  \item Initial guess:
    \begin{itemize}
    \item $r_{0} = 0.0308$
    \end{itemize}
  \item Three aggregates:
    \begin{enumerate}
    \item $K = 1.4531$
    \item $L = 0.9351$
    \item $\rightarrow\;r = F_{K}=0.1985$
    \end{enumerate}
  \item $r - r_{0} < errtol$? $0.0309 - 0.1935$ too large.
  \item Very sensitive to $r_{0}$!
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{Converged Wealth Dist.}
  \begin{itemize}
  \item Final wealth distribution after convergence:
  \end{itemize}
\centering\includegraphics[width=0.7\textwidth]{./AiyagariWealthDist.png}
\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{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{Aggregate Uncertainty}
\centering\includegraphics[width=0.7\textwidth]{./ThatWasEasy.jpg}
  \begin{itemize}
  \item What about aggregate uncertainty? The distribution is no longer stationary, hence no longer the equilibrium.
  \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.
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{Krusell and Smith (1998)}
  \begin{itemize}
  \item Specify moments from the type distribution $\gamma$ that approximate the type distribution.
  \item Then: $\gamma' = \Gamma(\gamma,z,z')$.
  \item Household predicts prices using $\Gamma$ instead of $\Psi$
  \item As long as this law of motion is reasonably accurate, this approximation will work.
  \item Krusell and Smith:
    \begin{itemize}
    \item Pick first $j$ moments of distribution over $k,\epsilon$
    \item i.e., mean, standard deviation,...
    \item Use this as the law of motion.
    \end{itemize}
  \item Use means: $ln(K') &= \phi_{0}^{z} + \phi_{1}^{z}ln(K)$
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{Approximate problem}
  \begin{itemize}
  \item In a production economy, the agent's problem is given by
    \begin{align}
      V(k,\epsilon;z,K)&= u(c) + \beta E[V(k',\epsilon';z',K')]\\
      \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')\\
      ln(K') &= \phi_{0}^{z} + \phi_{1}^{z}ln(K)\\
      c\geq 0&, k\geq 0, k_{0}\text{ given}, z_{0}\text{ given}
    \end{align}
  \item LLN $\rightarrow$ N known given $z$.
  \item Now: need aggregate capital and $\phi_{0}^{z},\;\phi_{1}^{z}$.
  \item Note: $\phi_{0}^{z},\;\phi_{1}^{z}$ {\it for each z}
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{KS Solution Technique}
  \begin{itemize}
  \item Algorithm:
    \begin{enumerate}
    \item Specify an initial forecasting function for $K$: $ln(K') &= \phi_{0}^{z} + \phi_{1}^{z}ln(K)$. Pick initial values for $\phi_{0}^{z},\phi_{1}^{z}$
    \item Tell household that the evolution of the aggregate state is given by $ln(K') &= \phi_{0}^{z} + \phi_{1}^{z}ln(K)$. i.e., replace the previous constraint.
    \item Use value function iteration on this problem to solve for optimal policy rules.
    \item Simulate model forward to obtain $K,z$ series. Drop first X number of observations.
    \item Use OLS on $K, z$ series to see if forecasting was correct $|[\phi_{0}^{z},\phi_{1}^{z}]' - \phi_{0}^{z'},\phi_{1'}^{z}]| < errtol$
    \item If not, update $\phi_{0}^{z}$, $\phi_{1}^{z}$ between initial and estimates.
    \end{enumerate}
  \item Another way to think about this: You estimated the slope and intercept of $K'$ on some series $\{K_{j},z_{j}\}_{j=1}^{j=t}$ and you are assessing its out of sample fit on $\{K_{j},z_{j}\}_{j=t+1}^{T}$
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{KS Solution Technique}
  \begin{itemize}
  \item Why does mean work?
  \item Linearity:
  \end{itemize}
\centering\includegraphics[width=0.7\textwidth]{./KSDecisionRule.png}
\end{frame}

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

\begin{frame}
  \frametitle{What do they find?}
  \begin{itemize}
  \item With $\beta$ heterogeneity, can hit wealth dist.
  \end{itemize}
\centering\includegraphics[width=0.7\textwidth]{./KSWealthDist.png}
\begin{itemize}
\item What is heterogeneity in $\beta$ a reduced-form for?
\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}

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

\begin{frame}
  \frametitle{That was easy}
\centering\includegraphics[width=0.7\textwidth]{./ThatWasEasy.jpg}
\end{frame}

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

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


\begin{frame}
  \frametitle{Conclusion}
  \begin{itemize}
  \item Today: solving heterogeneous agent models.
  \item Code to do this on the cluster.
  \item Start labor market frictions.
  \end{itemize}
\end{frame}


\end{document}
