---
title: "Macroeconomics:Day 9"
author: "Kenji Sato"
date: "January 11, 2017"
output: slidy_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(grid)
library(ggthemes)
```

## Optimal Growth


$$
\begin{aligned}
  & \max \int_0^\infty e^{-\rho t} u(c(t)) dt \\
  &\text{subject to } \\
  &\qquad c(t) = f(k(t)) - \delta k(t) - \dot k(t) \ge 0, \\
  &\qquad k(t) \ge 0, \\
  &\qquad k(0): \text{given}.
\end{aligned}
$$


## Euler Equation

As you will see later, the full dynamics of $c(\cdot)$ and $k(\cdot)$ is governed by 

$$
\begin{aligned}
  \dot k (t) &= f(k(t)) - \delta k(t) - c(t) \\ 
  \dot c (t) &= \frac{u'(c(t))[f'(k(t)) - \delta - \rho]}{- u''(c(t))}
              = \frac{u'(c(t))(r(t) - \rho)}{- u''(c(t))},
\end{aligned}
$$

where $r(t) = f'(k(t)) - \delta$ is net rate of return on capital.

When the rental rate (instantaneous reward of owning capital) is greater than the
discount rate (instantaneous cost of not consuming), the representative agent decides to 
spend this profits to increase consumption somewhat.


## Transversality condition

It is known that, under a mild set of conditions (See [Kamihigashi 2001, _Econometrica_](http://onlinelibrary.wiley.com/doi/10.1111/1468-0262.00227/full)),  transversality condition (not die before the present value of capital is zero)

$$
  \lim_{t\to\infty}-e^{-\rho t}u'(c(t))k(t)=0
$$

is necessary for optimality; i.e., among infinitely many paths that satisfy the 
above mentioned system of differential equations, those that satisfy the transversality 
condition are optimal.

In our case, we can specify only one solution. 



## Transversality and steady state

$e^{-\rho t}u'(c(t)) k(t)$ is the **present** value of period-$t$ capital. The present value of 
positive amount of capital in the infinite future should be zero. If it's positive, $u'(c(t))k(t)$ 
grows indefinitely and the representative agent cannot maximize his utility.

A candidate of the solution is the path that converges to a constant; i.e., 

$$
  (k(t), c(t)) \to (k^*, c^*)
$$
Since $e^{-\rho t} \to 0$ and $u'(c(t))k(t) \to u'(c^*) k^*$, we have the transversality condition.


## Conditions for the steady state


$$
\begin{aligned}
  c &= f(k) - \delta k \\
  k &= (f')^{-1} (\delta + \rho).
\end{aligned}
$$

**Exercise: ** Show that the steady state $(k^*, c^*)$ satisfies the above system of equations. [Hint: What was the definition of _steady state_?]



## $\dot k \gtreqqless 0$

$$
\begin{aligned}
\dot k > 0 
  &\Leftrightarrow
    f(k) - \delta k - c > 0 \\
  &\Leftrightarrow
    c < f(k) - \delta k
\end{aligned}
$$

$$
\begin{aligned}
\dot k < 0 
  &\Leftrightarrow
    f(k) - \delta k - c < 0 \\
  &\Leftrightarrow
    c > f(k) - \delta k
\end{aligned}
$$

## $\dot k \gtreqqless 0$

```{r, fig.align='center', echo=FALSE}
k = seq(0.01, 8.0, by=0.2)
c = seq(0.01, 4.0, by=0.1)
d = 0.05
alpha = 0.3
delta = 0.05
theta = 5
rho = alpha * delta * theta - delta
tbl = tibble(k=seq(0, 60, by=0.01)) %>% 
  mutate(kdot_is_0 = k ^ alpha - delta * k)

ggplot(tbl) + geom_line(aes(x=k, y=kdot_is_0)) + 
  labs(x='k', y='c') + ylim(0, 3.0) + theme_gdocs() + 
  annotate("text", x=20, y=0.5, label="dk/dt > 0", size=6) +
  annotate("text", x=20, y=2.0, label="dk/dt < 0", size=6)
```


## $\dot c \gtreqqless 0$

$$
\begin{aligned}
\dot c > 0 
  &\Leftrightarrow
    f'(k) - \delta - \rho > 0\\
  &\Leftrightarrow
    k < (f')^{-1}(\delta + \rho)
\end{aligned}
$$

$$
\begin{aligned}
\dot c < 0 
  &\Leftrightarrow
    f'(k) - \delta - \rho > 0\\
  &\Leftrightarrow
    k > (f')^{-1}(\delta + \rho)
\end{aligned}
$$


## $\dot c \gtreqqless 0$

```{r, fig.align='center', echo=FALSE}
modified_golden_rule = (alpha / (delta + rho))^(1/(1-alpha))
ggplot(tbl) + geom_vline(xintercept=modified_golden_rule ) + 
  labs(x='k', y='c') + ylim(0, 3.0) + xlim(0, 16) + theme_gdocs() + 
  annotate("text", x=3, y=1.5, label="dc/dt > 0", size=6) +
  annotate("text", x=10, y=1.5, label="dc/dt < 0", size=6)
```

## Phase Diagram

```{r, fig.align='center', echo=FALSE, warning=FALSE}
ggplot(tbl) + geom_line(aes(x=k, y=kdot_is_0)) + 
  geom_vline(xintercept=modified_golden_rule ) + 
  labs(x='k', y='c') + ylim(0, 3.0) + xlim(0, 30) + theme_gdocs() + 
  geom_segment(aes(x=5.5, xend=5.5, y=2, yend=2.5), color="blue", 
               arrow=arrow(length=unit(0.03, "npc"))) + 
  geom_segment(aes(x=3, xend=3, y=0.5, yend=1.0), color="blue", 
               arrow=arrow(length=unit(0.03, "npc"))) + 
  geom_segment(aes(x=20, xend=20, y=2.5, yend=2), color="blue", 
               arrow=arrow(length=unit(0.03, "npc"))) + 
  geom_segment(aes(x=17.5, xend=17.5, y=1.0, yend=0.5), color="blue", 
               arrow=arrow(length=unit(0.03, "npc"))) +
  geom_segment(aes(x=3, xend=5.5, y=0.5, yend=0.5), color="blue", 
               arrow=arrow(length=unit(0.03, "npc"))) + 
  geom_segment(aes(x=5.5, xend=3, y=2.0, yend=2.0), color="blue", 
               arrow=arrow(length=unit(0.03, "npc"))) + 
  geom_segment(aes(x=20, xend=17.5, y=2.5, yend=2.5), color="blue", 
               arrow=arrow(length=unit(0.03, "npc"))) + 
  geom_segment(aes(x=17.5, xend=20, y=1.0, yend=1.0), color="blue", 
               arrow=arrow(length=unit(0.03, "npc")))
```




## Hamiltonian Method: The target problem

The most frequently used method for continuous-time problems is the Hamiltonian method. Consider the following problem	(somewhat more abstract than the optimal growth)

$$
\begin{aligned}
&\max\int_{0}^{\infty}F(k,c,t)dt \\
&\text{subject to} \\
&\qquad\dot{k}=G(k,c,t), \\
&\qquad k(0):\ \text{given,}
\end{aligned}
$$

## Hamilotonian Method: Hamiltonian

The Hamiltonian (or more precisely, present-value Hamiltonian) is the following function. 

$$
\mathcal{H}(k, c, \lambda, t) =F(k,c,t)+\lambda G(k,c,t),
$$

where $\lambda = \lambda(t)$ is a multiplier. 


## Hamiltonian Method: Canonical Equations

The solution of the problem must satisfy (necessary condition),
$\frac{\partial\mathcal{H}}{\partial c}	=0$,

$$
\begin{aligned}
  \frac{\partial\mathcal{H}}{\partial c}	&= 0 \\
  \dot{\lambda}	&=-\frac{\partial\mathcal{H}}{\partial k},\\
  \dot{k}	&= \frac{\partial\mathcal{H}}{\partial\lambda}.
\end{aligned}
$$

We do not see the proof here. See Acemoglu (2009) if you are interested.

These conditions plus the transversality conditions give you the optimal path.


## Hamiltonian Method: Interpretations (or how to memorize)

$$
\begin{aligned}
  \frac{\partial\mathcal{H}}{\partial c}	&= 0, \\
  \dot{\lambda}	&=-\frac{\partial\mathcal{H}}{\partial k},\\
  \dot{k}	&= \frac{\partial\mathcal{H}}{\partial\lambda}.
\end{aligned}
$$

1. Roughly speaking, the Hamilotonian represents the Total Utility remaining at $t$.
1. **The first equation** states that the control is chosend to maximize the total utility.
1. $\lambda(t)$ represents the present price of capital at $t$ and **the second equation**
   states that the instantaneous increment of price is characterized by the marginal value
   (marginal product measure in the unit of present utlity price)
1. **The third equation** is exactly the resource constraint.


## Exercise

Dynamic optimization problems: 
$$
\begin{array}{l}
&\max\int_{0}^{\infty}F(k,c,t)dt \\
&\text{subject to} \\
&\qquad\dot{k}=G(k,c,t), \\
&\qquad k(0):\ \text{given,}
\end{array}
\quad\leftrightarrow\quad
\begin{array}{l}
  & \max \int_0^\infty e^{-\rho t} u(c) dt \\
  &\text{subject to } \\
  &\qquad c = f(k) - \delta k - \dot k, \\
  &\qquad k(0): \text{given}.
\end{array}
$$
Define the Hamiltonian
$$
\mathcal{H} =F(k,c,t)+\lambda G(k,c,t),
\quad\longleftrightarrow\quad ???
$$

Obtain the first-order conditions:
$$
\begin{array}{rl}
  \frac{\partial\mathcal{H}}{\partial c}	&= 0 \\
  \dot{\lambda}	&=-\frac{\partial\mathcal{H}}{\partial k},\\
  \dot{k}	&= \frac{\partial\mathcal{H}}{\partial\lambda}.
\end{array}
\quad\longleftrightarrow\quad
\begin{array}{rl}
  \dot k (t) &= f(k) - \delta k - c \\ 
  \dot c (t) &= \frac{u'(c)[f'(k) - \delta - \rho]}{- u''(c)},
\end{array}
$$
You have 15 minutes and prove the first-order dynamical system of the optimal growth model. 

