% --------------------------------------------------------------
%                         Preamble
% --------------------------------------------------------------

\documentclass[11pt]{article}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{cancel}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{enumitem}

% \lstset{language=Python,
%         basicstyle=\ttfamily\small,
%         keywordstyle=\color{keywords},
%         commentstyle=\color{green},
%         stringstyle=\color{red},
%         showstringspaces=false,
%         identifierstyle=\color{black},
%         procnamekeys={def,class}}


\newcommand{\E}{\mathbb{E}}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
\newcommand{\argmax}{\operatornamewithlimits{argmax}}

\begin{document}

% --------------------------------------------------------------
%                         Start here
% --------------------------------------------------------------

{\noindent Instructor: \textit{Benjamin Griffy}\\ Due: \textit{Feb., 6th 2025}\\ AECO 701}

\begin{center} \Large Problem Set 1 \end{center} \vspace{1em}

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

\noindent \textbf{Problem 1: Getting Intuition for Grid Search}
Consider the following stylized consumption-savings model. Agents live for two periods. During period 1, they earn income $m$, and must choose to allocate their resources between consumption today $c_{1}$ and savings, $a$. During period 2, they earn interest on their savings and consume all of their budget, $c_{2} = (1 + r)a$. After period 2, they exit the model. Their dynamic problem is given by the following:

\begin{align}
  \max_{c_{1},c_{2},a}\; &u(c_{1}) + \beta u(c_{2})\\
  \text{s.t. }\;& c_{1} + a \leq m\\
  &c_{2} \leq (1 + r)a
\end{align}


\begin{enumerate}[label=\textbf{\alph*})]
\item Characterize the optimal policies ($c_{1}, c_{2}, a$) analytically (by hand) for any $\beta$, $r$, $u(c)$.\newline

\textcolor{blue}{
\noindent Write the constrained optimization as
\begin{align*}
  \mathbb{L} &= u(c_{1}) + \beta u(c_{2}) + \lambda_{1}[m - a - c_{1}] + \lambda_{2}[(1 + r)a - c_{2}]
\end{align*}
The first order conditions are
\begin{align*}
  FOC[c_{1}] = u'(c_{1}) - \lambda_{1} = 0
\end{align*}
\begin{align*}
  FOC[c_{2}] = \beta u'(c_{2}) - \lambda_{2} = 0
\end{align*}
\begin{align*}
  FOC[a] = -\lambda_{1} + (1 + r)\lambda_{2} = 0
\end{align*}
Combining these expressions yield the Euler equation:
\begin{align*}
  u'(c_{1}) &= \beta(1 + r)u'(c_{2})
\end{align*}
}

\item Assume that utility is power utility, $u(c) = \frac{c^{1 - \sigma}}{1 - \sigma}$, with $\sigma = 2$, and that $r = 0.04$ and $\beta = \frac{1}{1 + r}$. Set up an income grid from 1 to 10 with 10 grid points (like we did in class). Set up an asset grid with 10 points and solve for the optimal consumption decisions in periods 1 and 2.

\textcolor{blue}{
\noindent See the code.
}

\item Plot the period 1 and 2 consumption decisions as well as the savings (the residual of income minus period 1 consumption) decisions.

\textcolor{blue}{
\noindent See the code for how to plot.
}

\begin{figure}[h]\centering
  \begin{subfigure}
    \centering
    \includegraphics[width=0.33\textwidth]{./Savings.png}
  \end{subfigure}
  \begin{subfigure}
    \centering
    \includegraphics[width=0.33\textwidth]{./Consumption1.png}
  \end{subfigure}
  \begin{subfigure}
    \centering
    \includegraphics[width=0.33\textwidth]{./Consumption2.png}
  \end{subfigure}
\end{figure}

\item Now, using the analytical solutions that you found from part (a), find the ``true'' consumption and savings decisions. Use the parameter assumptions and values in part (b), and then plug in the income grid specified in part (b). This is the exact solution of the model. Compare the values that you find here to the approximate solution you found in part (c) by plotting your exact solution and the approximate solution on the same graph for consumption (periods 1 and 2) and savings.

\textcolor{blue}{
\noindent First, solve the two-period model. Start with the Euler Equation:
\begin{align*}
  u'(c_{1}) &= \beta(1 + r)u'(c_{2})\\
  c_{1}^{-\sigma} &= \beta(1 + r)c_{2}^{-\sigma}\\
  c_{1}^{-\sigma} &= c_{2}^{-\sigma}\\
  \rightarrow c_{1} &= c_{2}
\end{align*}
Construct the lifetime budget:
\begin{align*}
  c_{1} + \frac{c_{2}}{1 + r} &= m
\end{align*}
Thus, we get
\begin{align*}
  c_{1} = c_{2} &= \frac{1 + r}{2 + r}m\\
  a & \frac{m}{2 + r}
\end{align*}
Now, plotting this and comparing it to the approximate solutions:
\begin{figure}[h]\centering
  \begin{subfigure}
    \centering
    \includegraphics[width=0.33\textwidth]{./SavingsComp.png}
  \end{subfigure}
  \begin{subfigure}
    \centering
    \includegraphics[width=0.33\textwidth]{./Consumption1Comp.png}
  \end{subfigure}
  \begin{subfigure}
    \centering
    \includegraphics[width=0.33\textwidth]{./Consumption2Comp.png}
  \end{subfigure}
\end{figure}
}

\item Why are the results different when you get an exact solution versus an approximate solution? What would improve the accuracy of the approximate solution?

\textcolor{blue}{
\noindent They are close, but the exact solution is slightly more accurate. The reason is that the coarseness of the grid prevents achieving the optimal decisions.
}

\end{enumerate}
% \newpage

% \lstinputlisting[language=Python]{PS1_Solution.py}
% --------------------------------------------------------------
%                         End here
% --------------------------------------------------------------

\end{document}
