%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 2022} % 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{Introduction}
  \begin{itemize}
  \item Today: reintroduce stochastic neoclassical growth model.
  \item Jumping off point for most modern macro models.
  \item Introduce solution techniques.
  \item Homework (really will be) on my website.
  \end{itemize}
\end{frame}

% ------------------------------------------------
\section{Neoclassical Growth Model}
% ------------------------------------------------
\begin{frame}
  \frametitle{Model environment}
  \begin{itemize}
  \item Every macro presentation should have an environment slide.
  \item This details the following:
    \begin{enumerate}
    \item preferences
    \item technology
    \item markets
    \end{enumerate}
  \item Then jump into individual problem.
  \item We will go through each of these.
  \end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Consumer's Problem}
\begin{itemize}
\item consumers in this economy maximize the expected value given by
\begin{align*}
\mathbb{E} \left[ \sum_{t=0}^\infty \beta^t u(c_t) \right]
\end{align*}
\item $u$ is a bounded, continuous and strictly increasing utility function.
\item $\beta \in (0,1)$ is a discount factor.
\item subject to
  \begin{align*}
y_t \geq c_t + [ \ \underbrace{k_{t+1} - (1- \delta ) k_t}_{= i_t} \ ]
  \end{align*}
\end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Resource Constraints}
  \begin{align*}
y_t &\geq c_t + i_{t}\\
    k_{t+1} &= (1- \delta ) k_t + i_{t}
  \end{align*}
				\begin{itemize}
					\item An agent owns an amount $y_t \in \mathbb{R}_+ := [0, \infty) $ of consumption good at time $t$.
					\item Output can either be consumed or invested.
					\item When the good is invested, it is transformed one-for-one into capital.
				\end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Technology}
        \begin{align*}
          y_{t+1} = f(\gamma_{t+1},k_{t+1})\;,\;\gamma_{t+1} \sim \Phi
        \end{align*}
				\begin{itemize}
					\item $f:\mathbb{R}_+^{2} \rightarrow \mathbb{R}_+$ is the production function which is increasing and continuous in $k$ and $\gamma$.
					\item Production is stochastic, in that it depends on a shock $\gamma_{t+1}$ realized at the end of the current period $t$.
                                        \item Calibration
                                          \begin{align*}
                                            \gamma_{t+1} &= e^{\sigma\epsilon_{t+1}}, \epsilon_{t+1} \overset{i.i.d.}{\sim} \mathcal{N}(0,1),\;\sigma>0\\
                                            f(k_{t+1},\gamma_{t+1}) &= \gamma_{t+1} k_{t+1}^{\alpha}\\
                                            \delta &= 1
                                          \end{align*}
				\end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Optimization}
        \begin{align*}
          \max_{\{c_t, \ k_{t+1} \}_{t=0}^\infty } \ &\mathbb{E} \left[ \sum_{t=0}^\infty \beta^t u(c_t) \right] \\
          s.t. \; & y_t \geq c_t + k_{t+1} \; \forall t \tag{Resource Constraint}\\
                                                     & y_{t+1} = f(k_{t+1},\gamma_{t+1}),\;\gamma_{t+1} \overset{i.i.d.}{\sim} \Phi  \; \forall t \tag{Technology} \\
                                                     & c_t \geq 0\;k_{t+1} \geq 0  \; \forall t \tag{Non-negativity Constraint} \\
                                                     & y_0 = \bar y_0 \;given
        \end{align*}
\end{frame}

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

\begin{frame}
	\frametitle{Sequential Problem (SP)}
		\begin{align*}
                  \max_{\{c_t\}_{t=0}^\infty } \ &\mathbb{E} \left[ \sum_{t=0}^\infty \beta^t u(c_t) \right] \\
                  s.t. \; y_{t+1} &= f(k_{t + 1},\gamma_{t+1}),\;\gamma_{t+1} \overset{i.i.d.}{\sim} \Phi  \; \forall t\\
                  y_t &\geq c_t + k_{t+1}\forall\;t\\
                  y_0 &= \bar y_0 \; \mbox{given}
		\end{align*}
		\vspace{-5mm}
		\begin{itemize}
                \item Resource constraint holds with equality b/c $u'>0$.
                \item $y_t$ summarizes state of world at the start of each period.
                \item $c_t$ is chosen by the agent each period after observing the state.
		\end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Functional Equation (FE)}
		(SP) is an infinite-dimensional optimization problem. Instead, find a time-invariant solution to functional equation:

		\begin{align*}
                  v^*(y) &= \max_{c \in [0,y]} \left\{ u(c) + \beta \int v^* \Big(f(k',\gamma) \Big) \phi(d \gamma) \right\}\\
                  y &= c + k'\\
                  y' &= f(k',\gamma)
		\end{align*}
		\vfill

		Solution $v^*$, evaluated at $y = \bar y_0$, gives the value of the maximum in (SP).
\end{frame}

% ------------------------------------------------
\section{Steady State}
% ------------------------------------------------

\begin{frame}
  \frametitle{Steady State}
  \begin{itemize}
  \item Hard to characterize dynamics/solve model (find $c(t), k(t)\forall\;t$)
  \item Instead, characterize steady-state.
  \item $c = c' = c^{*}$, $k = k' = k^{*}$.
  \item pick $u(c) = ln(c)$, $f(k,\gamma)= e^{\sigma\epsilon}k^{\alpha}$ and $\epsilon\sim N(0,1),\sigma = 1$.
  \item then
    \begin{align*}
      \frac{1}{c} = \beta\mathbb{E}[(\alpha e^{\epsilon'}k'^{\alpha-1})\frac{1}{c'}]
    \end{align*}
  \item In steady state:
    \begin{align*}
      \frac{1}{c^{*}} = \beta(\alpha \bar{\gamma}k^{*\alpha-1})\frac{1}{c^{*}}
    \end{align*}
  \item We will solve for the \textit{stochastic steady state}.
  \item i.e., the steady-state if the aggregate shock were at its mean.
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{Steady State}
  \begin{itemize}
  \item This leaves us with capital:
    \begin{align*}
      1 &= \beta(\alpha \bar{\gamma}k^{*\alpha-1})\\
      k^{*} &= (\frac{1}{\bar{\gamma}\alpha\beta})^{\frac{1}{\alpha - 1}}\\
      k^{*} &= (\bar{\gamma}\alpha\beta)^{\frac{1}{1 - \alpha}}
    \end{align*}
  \item Now consumption from the budget constraint:
    \begin{align*}
      c^{*} + k^{*} &= \bar{\gamma}k^{*\alpha}\\
      c^{*} &= \bar{\gamma}k^{*\alpha} - k^{*}\\
      c^{*} &= \bar{\gamma}(\bar{\gamma}\alpha\beta)^{\frac{\alpha}{1 - \alpha}} - (\bar{\gamma}\alpha\beta)^{\frac{1}{1 - \alpha}}
    \end{align*}
  \end{itemize}
\end{frame}

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

\begin{frame}
  \frametitle{Dynamics}
\begin{itemize}
\item Dynamics:
  \begin{align*}
    c' &= \beta(\alpha \bar{\gamma}k^{'\alpha-1})c\\
    k' &= \bar{\gamma}k^{\alpha} - c
  \end{align*}
\item We have two dynamic variables: $c$ and $k$.
\item The behavior of this system will depend on their dynamics.
\item At steady-state:
  \begin{align*}
    1 = \frac{c'}{c} &= \beta(\alpha \bar{\gamma}k^{\alpha-1})\\
    1 = \frac{k'}{k} &= \bar{\gamma}k^{\alpha-1} - \frac{c}{k}
  \end{align*}
\item If both hold, we are in steady-state, if not, dynamics can vary.
\end{itemize}

\end{frame}

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

\begin{frame}
  \frametitle{Dynamics}
\begin{itemize}
\item Dynamics:
  \begin{align*}
    c' &= \beta(\alpha \bar{\gamma}k^{\alpha-1})c\\
    k' &= \bar{\gamma}k^{\alpha} - c
  \end{align*}
\item Small $c$: second equation dictates that capital increases.
\item Small $k$: first equation dictates that consumption increases.
\item Reverse is true.
\end{itemize}

\end{frame}

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

\begin{frame}
  \frametitle{Phase Diagram}
\begin{itemize}
\item Dynamics:
  \begin{align*}
    c' &= \beta(\alpha \bar{\gamma}k^{'\alpha-1})c\\
    k' &= \bar{\gamma}k^{\alpha} - c
  \end{align*}
\item From Eric Sim's notes:
\end{itemize}
\centering\includegraphics[width=\textwidth]{PhaseDiagram.png}

\end{frame}

% --------------------------------------------------------------
\section{Solving for dynamics}
% ------------------------------------------------
\begin{frame}
	\frametitle{Solving for dynamics}
        \begin{itemize}
        \item Recall contraction mapping
        \item If $T$ is a contraction mapping with modulus $\beta$, then
		\begin{enumerate}
			\item there exists a unique fixed point $v^*$, and
                          \begin{align*}
                            v^{*} &= Tv^{*}\\
                            v^*(y) &= \max_{c \in [0,y]} \left\{ u(c) + \beta \int v^* \Big(f(k',\gamma) \Big) \phi(d \gamma) \right\}\\
                            y &= c + k'\\
                            y' &= f(k',\gamma)
                          \end{align*}
			\item for any $v_0$ and any $n \in \mathbb{N}$,
				\[ \rho(T^n v_0 , v^*) \leq \beta^n \rho(v_0, v^*) \]
		\end{enumerate}
              \item Yields an is a policy function $\sigma^{*}(y) = argmax\{v(y)\}$
              \item We can apply this in two ways: analytically or computationally.
              \end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Computation}
	How can we implement Bellman operator on our computer?

		\[ Tw(y) := \underbrace{\max_{c \in [0,y]} \Bigg\{ u(c) + \beta \underbrace{\int \underbrace{w \Big(f(k',\gamma) \Big)}_{\text{1. Approximation}} \phi(d \gamma)}_{\text{2. Integration}} \Bigg\}}_{\text{3. Optimization}} \]
where $w$ is a function that approximates $v$.
\end{frame}

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

\begin{frame}
	\frametitle{Approximation}
		\begin{itemize}
			\item Approximate an analytically intractable real-valued function $f$ with a computationally tractable function $\widehat{f}$
                        \item given limited information about $f$.
			\item Divide the {\bf approximation domain} of the function into {\bf finite number of sub-intervals} and approximate the original function in each of the intervals.
				\begin{itemize}
					\item The points on the domain which separate the intervals are called grid points.
					\item We use the value of the function at each grid point to approximate the original function.
				\end{itemize}
                              \item Another way to think about it: sampling from domain of the function at $n$ nodes. As $n\rightarrow\infty, \widehat{f}\rightarrow f$
		\end{itemize}

\end{frame}

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

\begin{frame}
	\frametitle{Approximation II}
	In order to figure out Bellman operator, we need to approximate an analytically intractable real-valued function $w$.
		\[ Tw(y) := \max_{c \in [0,y]} \left\{ u(c) + \beta \int w \Big(f(k',\gamma) \Big) \phi(d \gamma) \right\} \]
                \begin{itemize}
              \item Interpolation
		\begin{enumerate}
			\item Determine an approximation domain of $w$.
			\item Pick $n$ (often evenly spaced) nodes, produces $n - 1$ intervals.
			\item Approximate the original function $w$ in each of the resulting intervals using a polynomial.
		\end{enumerate}
              \item Grid search
                \begin{enumerate}
			\item Determine an approximation domain of $w$.
			\item Pick $n$ nodes, produces $n - 1$ intervals.
                        \item Evaluate function at each node and pick maximum.
                \end{enumerate}
              \end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Integration}
	In order to figure out Bellman operator, we need to evaluate continuation value.
	\[ Tw(y) := \max_{c \in [0,y]} \left\{ u(c) + \beta \int w \Big(f(k',\gamma) \Big) \phi(d \gamma) \right\} \]
	\vfill
        \begin{itemize}
        \item One approach: Monte Carlo integration:
	Given a random sample of size $n$, $\{\gamma_i\}_{i=1}^n$
		\[ \frac{1}{n} \sum_{i=1}^n \frac{ w \Big(f(k',\gamma_i) \Big) \cancel{\phi(\gamma_i)} }{ \cancel{\phi(\gamma_i)}} \; \overset{p}{\longrightarrow} \; \int w \Big(f(k',\gamma) \Big) \phi(\gamma) d \gamma \]
              \item Better approach: Gaussian Quadrature (for normally distributed shocks and from related families)
              \end{itemize}
\end{frame}

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

\begin{frame}
	\frametitle{Optimization}
	\begin{itemize}
		\item Find the minimum of some real-valued function of several real variables on a domain that has been specified.
			\begin{itemize}
				\item Derivative methods:  Newton's method, etc.
                                \item Derivative free: Golden section search, Grid search: pick maximizing node.
			\end{itemize}
		\item Finding the global minimum can be challenging.
			\begin{itemize}
				\item The function can have many local minima.
				\item Curse of dimensionality \& curvature of problem (when problems approach boundaries).
			\end{itemize}
	\end{itemize}

\end{frame}

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

\begin{frame}
  \frametitle{Conclusion}
  \begin{itemize}
  \item Alternative: guess and verify (method of undetermined coefficients).
  \item We will cover this next time.
  \item Midterm next Wednesday!
  \item Check website for homework (totally, I promise).
  \end{itemize}
\end{frame}


\end{document}
