├── .gitignore ├── LICENSE ├── README.md ├── homework ├── homework1.pdf ├── homework1.tex ├── homework2.pdf ├── homework2.tex ├── homework3.pdf ├── homework3.tex ├── homework4.pdf ├── homework4.tex ├── homework5.pdf └── homework5.tex ├── homework_coding ├── homework_coding_week1.pdf ├── homework_coding_week3.pdf ├── homework_coding_week4.pdf ├── homework_coding_week5.pdf ├── honework_coding_week2.pdf └── solutions │ ├── homework_coding_week1_sol.pdf │ ├── homework_coding_week2_sol.pdf │ ├── homework_coding_week3_sol.pdf │ └── homework_coding_week4_sol.pdf ├── homework_solutions ├── Homework_Solutions_1.pdf ├── Homework_Solutions_2.pdf ├── Homework_Solutions_3.pdf ├── Homework_Solutions_4.pdf └── Homework_Solutions_5.pdf ├── lectures ├── Brownian1.png ├── Brownian2.png ├── Brownian3.png ├── Brownian4.png ├── Brownian5.png ├── Brownian6.png ├── Brownian7.png ├── figures │ ├── HACT_MPC.png │ ├── HACT_accuracy_consumption.png │ ├── HACT_accuracy_error1000.png │ ├── HACT_accuracy_error30.png │ ├── HACT_consumption.png │ ├── HACT_diffusion_distribution.png │ ├── HACT_diffusion_savings.png │ ├── HACT_distribution.png │ ├── HACT_distribution2.png │ ├── HACT_example1.png │ ├── HACT_example2.png │ ├── HACT_existence.png │ ├── HACT_savings.png │ ├── HACT_savings2.png │ ├── HACT_spyA.png │ ├── HACT_transition.png │ ├── candlerpic.eps │ ├── density_initial.eps │ ├── density_steadystate.eps │ ├── ikc1.png │ ├── ikc2.png │ ├── inequality_consumption_0.png │ ├── inequality_consumption_1.png │ ├── inequality_consumption_2.png │ ├── inequality_consumption_3.png │ ├── inequality_earnings_1.png │ ├── inequality_earnings_2.png │ ├── inequality_earnings_3.png │ ├── inequality_earnings_4.png │ ├── inequality_earnings_5.png │ ├── inequality_earnings_6.png │ ├── inequality_earnings_7.png │ ├── inequality_government_1.png │ ├── inequality_government_2.png │ ├── inequality_government_3.png │ ├── inequality_government_4.png │ ├── inequality_household_1.png │ ├── inequality_household_2.png │ ├── inequality_household_3.png │ ├── inequality_polarization_1.png │ ├── inequality_polarization_2.png │ ├── inequality_polarization_3.png │ ├── inequality_wage_1.png │ ├── inequality_wage_10.png │ ├── inequality_wage_11.png │ ├── inequality_wage_12.png │ ├── inequality_wage_2.png │ ├── inequality_wage_3.png │ ├── inequality_wage_4.png │ ├── inequality_wage_5.png │ ├── inequality_wealth_1.png │ ├── inequality_wealth_2.png │ ├── inequality_wealth_3.png │ ├── liquidity_constraint.png │ ├── precautionary.png │ ├── skiba.png │ ├── skiba1978.png │ ├── skiba_savings.png │ ├── skiba_spyA.png │ ├── skiba_value.png │ └── spyA.png ├── lecture1.pdf ├── lecture1.tex ├── lecture10.pdf ├── lecture10.tex ├── lecture11.pdf ├── lecture11.tex ├── lecture2.pdf ├── lecture2.tex ├── lecture3.pdf ├── lecture3.tex ├── lecture5.pdf ├── lecture5.tex ├── lecture7.pdf ├── lecture7.tex ├── lecture9.pdf └── lecture9.tex ├── sections ├── .gitkeep ├── Section 1.pdf ├── Section 2.pdf ├── Section 3.pdf ├── Section_4.pdf ├── Section_5.pdf ├── Syllabus.pdf └── codes │ ├── .gitkeep │ ├── week1 │ ├── .gitkeep │ ├── capital_accumulation.m │ └── define_parameters.m │ ├── week2 │ ├── ramsey │ │ ├── define_parameters.m │ │ ├── forward_simulate.m │ │ ├── ramsey.m │ │ └── terminal_condition.m │ └── ramsey_HJB │ │ ├── HJB_ramsey_implicit_demo.m │ │ └── define_parameters.m │ ├── week3 │ ├── HJB_ramsey_implicit_mixed.m │ ├── HJB_ramsey_implicit_upwind.m │ └── define_parameters.m │ ├── week4 │ ├── Asset Supply │ │ ├── Huggett_assetsupply.m │ │ └── define_parameters_assetsupply.m │ ├── GE │ │ ├── Huggett_GE.m │ │ └── define_parameters_GE.m │ ├── HJB │ │ ├── HJB_Huggett.m │ │ └── define_parameters.m │ └── KF │ │ ├── Huggett_PE.m │ │ └── define_parameters.m │ └── week5 │ ├── Andreas's Repository │ ├── GE │ │ ├── HJB.m │ │ ├── KF.m │ │ ├── define_parameters.m │ │ ├── main_GE.m │ │ └── stationary.m │ └── PE │ │ ├── define_parameters.m │ │ └── main_PE.m │ └── Transition Dynamics │ ├── Huggett_transition.m │ ├── Huggett_transition_demo.m │ ├── define_parameters_initial.m │ ├── define_parameters_terminal.m │ └── huggett_GE.m └── syllabus └── syllabus2024.docx /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # MATLAB 4 | *.asv 5 | *.mat 6 | 7 | ## Core latex/pdflatex auxiliary files: 8 | *.aux 9 | *.lof 10 | *.log 11 | *.lot 12 | *.fls 13 | *.out 14 | *.toc 15 | *.fmt 16 | *.fot 17 | *.cb 18 | *.cb2 19 | .*.lb 20 | *.swp 21 | 22 | ## Intermediate documents: 23 | *.dvi 24 | *.xdv 25 | *-converted-to.* 26 | # *.ps 27 | # *.eps 28 | # *.pdf 29 | 30 | ## Generated if empty string is given at "Please type another file name for output:" 31 | .pdf 32 | 33 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 34 | *.bbl 35 | *.bcf 36 | *.blg 37 | *-blx.aux 38 | *-blx.bib 39 | *.run.xml 40 | 41 | ## Build tool auxiliary files: 42 | *.fdb_latexmk 43 | *.synctex 44 | *.synctex(busy) 45 | *.synctex.gz 46 | *.synctex.gz(busy) 47 | *.pdfsync 48 | 49 | ## Build tool directories for auxiliary files 50 | # latexrun 51 | latex.out/ 52 | 53 | ## Auxiliary and intermediate files from other packages: 54 | # algorithms 55 | *.alg 56 | *.loa 57 | 58 | # achemso 59 | acs-*.bib 60 | 61 | # amsthm 62 | *.thm 63 | 64 | # beamer 65 | *.nav 66 | *.pre 67 | *.snm 68 | *.vrb 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 schaab-teaching 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DynamicProgramming2024 -------------------------------------------------------------------------------- /homework/homework1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework/homework1.pdf -------------------------------------------------------------------------------- /homework/homework1.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{extarticle} 2 | \usepackage{fullpage,amsmath,amsfonts,microtype,nicefrac,amssymb, amsthm} 3 | \usepackage[left=1in, bottom=1in, top=1in, right = 1in]{geometry} 4 | \usepackage{textcomp} 5 | \usepackage{mathpazo} 6 | \usepackage{mathrsfs} 7 | \usepackage[T1]{fontenc} 8 | \usepackage[utf8]{inputenc} 9 | \usepackage[english]{babel} 10 | \usepackage{graphicx} 11 | 12 | \usepackage{microtype} 13 | 14 | \usepackage{bm} 15 | \usepackage{dsfont} 16 | \usepackage{enumerate} 17 | \usepackage{ragged2e} 18 | 19 | \setlength{\parindent}{24pt} 20 | \setlength{\jot}{8pt} 21 | 22 | 23 | \usepackage[shortlabels]{enumitem} 24 | 25 | 26 | %% FOOTNOTES 27 | \usepackage[bottom]{footmisc} 28 | \usepackage{footnotebackref} 29 | 30 | 31 | %% FIGURE ENVIRONMENT 32 | %\graphicspath{{}} 33 | \usepackage[margin=15pt, font=small, labelfont={bf}, labelsep=period]{caption} 34 | \usepackage{subcaption} 35 | \captionsetup[figure]{name={Figure}, position=above} 36 | \usepackage{float} 37 | \usepackage{epstopdf} 38 | 39 | 40 | %% NEW COMMANDS 41 | \renewcommand{\baselinestretch}{1.25} 42 | \renewcommand{\qedsymbol}{$\blacksquare$} 43 | \newcommand{\R}{\mathbb{R}} 44 | \newcommand{\indep}{\mathrel{\text{\scalebox{1.07}{$\perp\mkern-10mu\perp$}}}} 45 | \renewcommand{\b}{\begin} 46 | \newcommand{\e}{\end} 47 | 48 | %% NEWTHEOREM 49 | \theoremstyle{plain} 50 | \newtheorem{thm}{Theorem} 51 | \newtheorem{lem}[thm]{Lemma} 52 | \newtheorem{prop}[thm]{Proposition} 53 | 54 | \theoremstyle{definition} 55 | \newtheorem{defn}[thm]{Definition} 56 | \newtheorem{ex}[thm]{Example} 57 | \newtheorem{remark}[thm]{Remark} 58 | \newtheorem{cor}[thm]{Corollary} 59 | 60 | %% LINKS and COLORS 61 | \usepackage[dvipsnames]{xcolor} 62 | \usepackage{hyperref} 63 | \definecolor{myred}{RGB}{163, 32, 45} 64 | \hypersetup{ 65 | %backref=true, 66 | %pagebackref=true, 67 | colorlinks=true, 68 | urlcolor=myred, 69 | citecolor=myred, 70 | linktoc=all, 71 | linkcolor=myred, 72 | } 73 | 74 | %% TABLE OF CONTENTS 75 | \addto\captionsenglish{ 76 | \renewcommand{\contentsname} 77 | {}% This removes the heading over the table of contents. 78 | } 79 | 80 | 81 | 82 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 84 | %%%%%%%%%%%%%%%%%%%%%% END PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%% 85 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87 | 88 | \title{202A: Dynamic Programming and Applications\\[5pt] {\Large \textbf{Homework \#1}}} 89 | 90 | \author{Andreas Schaab\footnote{ 91 | UC Berkeley. Email: schaab@berkeley.edu.\\ 92 | This course builds on the excellent teaching material developed, in particular, by David Laibson and Benjamin Moll. I would also like to thank Gabriel Chodorow-Reich, Pablo Kurlat, J\'on Steinsson, and Gianluca Violante, as well as QuantEcon, on whose teaching material I have drawn. 93 | }} 94 | 95 | \date{} 96 | 97 | 98 | \begin{document} 99 | 100 | \maketitle 101 | 102 | 103 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 104 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 105 | \section*{Problem 1: Discrete Time Markov Chains} 106 | 107 | Time is discrete, with $t \in \{0, 1, ...\}$. Consider the stochastic process $\{ y_t \}$ which follows a Markov chain. Let $y_t$ denote the employment / earnings state of an individual in periods $t$. Consider the state space $y_t \in Y = \{ y^U, y^E \}$, where $y^U$ corresponds to unemployment and $y^E$ corresponds to employment. Let $\bm y$ denote the column vector $(y^U, y^E)'$ representing this state space (this is the grid you would construct on a computer). Suppose the employment dynamics of the individual are characterized by the invariant transition matrix 108 | \begin{equation*} 109 | P = \begin{pmatrix} \alpha & 1 - \alpha \\ 1 - \beta & \beta \end{pmatrix}. 110 | \end{equation*} 111 | We interpret a time period as a quarter. 112 | 113 | \vspace{5mm} 114 | \noindent 115 | \begin{enumerate}[(a)] 116 | \item Give economic interpretations of $\alpha = P_{11}$ and $\beta = P_{22}$ 117 | 118 | \item Why do the rows of $P$ sum to $1$? 119 | 120 | \item Is there an absorbing state in this model? 121 | 122 | \item Compute the probability of being unemployed two quarters after being employed. 123 | 124 | \item Denote the \textit{marginal (probability) distribution} of $y_t$ at time $t$ by $\psi_t$. $\psi_t(y^L)$ is the probability that process $y_t$ is in state $y^L$ at time $t$. It is easiest to think of $\psi_t$ as a time-varying row vector. Use the law of total probability to decompose $y_{t+1} = y^L$, accounting for all the possible ways in which state $y^L$ can be reached at time $t+1$. 125 | 126 | \item Show that the resulting equation can be written as the vector-matrix product 127 | \begin{equation*} 128 | \psi_{t+1} = \psi_t P. 129 | \end{equation*} 130 | Therefore: The evolution of the marginal distribution of a Markov chain is obtained by post-multiplying by the transition matrix. 131 | 132 | \item Show that 133 | \begin{equation*} 134 | X_0 \sim \psi_0 \implies X_t \sim \psi_0 P^t, 135 | \end{equation*} 136 | where $\sim$ reads ``is distributed according to''. 137 | 138 | \item We call $\psi^*$ a \textit{stationary distribution} of the Markov chain if it satisfies 139 | \begin{equation*} 140 | \psi^* = \psi^* P. 141 | \end{equation*} 142 | Compute the probability of being unemployed $n$ quarters after being employed. Take $n \to \infty$ and find the stationary distribution of this Markov chain. Find the stationary distribution by alternatively plugging into the above equation for $\psi^*$. 143 | 144 | \item Suppose $y_0 = y^H$. Solve for $\mathbb E_0 (y_t)$. Use the law of total / iterated expectation to relate expectation to probabilities. Then use the formulas for marginal (probability) distributions derived above. 145 | \end{enumerate} 146 | 147 | 148 | 149 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 150 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 151 | \vspace{5mm} 152 | \section*{Problem 2: Proof of the Contraction Mapping Theorem} 153 | 154 | In class, we defined the Bellman operator $B$, which operates on functions $w$, and is defined by 155 | \begin{equation*} 156 | (Bw)(x) \equiv \max_{x' \in \Gamma(x)} \bigg\{ F(x, x') + \beta w(x') \bigg\} 157 | \end{equation*} 158 | for all $x \in \mathcal X$ in the state space, where $\Gamma(x)$ is some constraint set---in our case, this was the budget constraint. The definition is expressed pointwise, but it applies to all possible values in the state space. We call $B$ an operator because it maps a function $w$ to a new function $Bw$. So both $w$ and $Bw$ map $\mathcal X$ into $\mathbb R$. Operator $B$ maps \textit{functions} and is therefore called a functional operator. In class, we showed that the solution of the Bellman equation---the value function---is a fixed point of the Bellman operator. 159 | 160 | What does it mean to \textit{iterate} $B^n w$? 161 | \begin{align*} 162 | (Bw) (x) &= \max_{x' \in \Gamma(x)} \bigg\{ F(x, x') + \beta w(x') \bigg\} \\ 163 | (B(Bw)) (x) &= \max_{x' \in \Gamma(x)} \bigg\{ F(x, x') + \beta (Bw)(x') \bigg\} \\ 164 | (B(B^2w)) (x) &= \max_{x' \in \Gamma(x)} \bigg\{ F(x, x') + \beta (B^2w)(x') \bigg\} \\ 165 | \vdots & \vdots \\ 166 | (B(B^nw)) (x) &= \max_{x' \in \Gamma(x)} \bigg\{ F(x, x') + \beta (B^nw)(x') \bigg\}. 167 | \end{align*} 168 | What does it mean for functions to converge to a limiting function? Let $v_0$ be some guess for the value function, then convergence would mean 169 | \begin{equation*} 170 | \lim_{n \to \infty} B^n v_0 = v. 171 | \end{equation*} 172 | And why might $B^n w$ converge as $n \to \infty$? The answer is that $B$ is a \textit{contraction mapping}. 173 | 174 | 175 | \vspace{5mm} 176 | \begin{defn} 177 | 178 | Let $(S, d)$ be a metric space and $B: S \to S$ be a function that maps $S$ into intself. $B$ is a contraction mapping if for some $\beta \in (0, 1)$, $d(Bf, Bg) \leq \beta d(f, g)$, for any two functions $f$ and $g$.\footnote{ 179 | A metric $d$ is a way of representing the distance between two functions, or two members of (metric) space $S$. One example: the supremum pointwise gap. 180 | } 181 | 182 | \end{defn} 183 | 184 | 185 | \vspace{5mm} 186 | \noindent 187 | Intuitively, $B$ is a contraction mapping if applying the operator $B$ to any two functions $f$ and $g$ (that are not the same) moves them strictly closer together. $Bf$ and $Bg$ are strictly closer together than $f$ and $g$. We can now state the contraction mapping theorem. 188 | 189 | 190 | \vspace{5mm} 191 | \begin{thm} 192 | 193 | If $(S, d)$ is a complete metric space and $B: S \to S$ is a contraction mapping, then: 194 | \begin{enumerate}[(i)] 195 | \item $B$ has exactly one fixed point $v \in S$ 196 | \item For any $v_0 \in S$, $\lim_{n \to \infty} B^n v_0 = v$ 197 | \item $B^n v_0$ has an exponential convergence rate at least as great as $- \ln(\beta)$ 198 | \end{enumerate} 199 | 200 | \end{thm} 201 | 202 | 203 | \vspace{5mm} 204 | \noindent 205 | In this problem, we will illustrate and prove the contraction mapping theorem. 206 | 207 | \begin{enumerate}[(a)] 208 | \item Consider the contraction mapping $(Bw)(x) \equiv h(x) + \alpha w(x)$ with $\alpha \in (0, 1)$. Iteratively apply the operator $B$ and show that 209 | \begin{equation*} 210 | \lim_{n \to \infty} (B^n f)(x) = \frac{h(x)}{1-\alpha} 211 | \end{equation*} 212 | Argue that this shows that the fixed point of this operator $B$ is consequently the function $v(x) = \frac{1}{1-\alpha} h(x)$. Show that $(Bv)(x) = v(x)$. 213 | 214 | \item \textbf{Optional:} Now we will prove the contraction mapping theorem in 3 steps (we will not prove the convergence rate). Show that $\{ B^n f_0\}_{n=0}^\infty$ is a Cauchy sequence. (Cauchy sequence definition: Fix any $\epsilon > 0$. Then there exists $N$ such that $d(B^m f_0, B^n f_0) \leq \epsilon$ for all $m, n \leq N$.) 215 | 216 | \item \textbf{Optional:} Show that the limit point $v$ is a fixed point of $B$. 217 | 218 | \item \textbf{Optional:} Show that only one fixed point exists. 219 | 220 | \end{enumerate} 221 | 222 | 223 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 224 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 225 | \vspace{5mm} 226 | \section*{Problem 3: Blackwell's Sufficiency Conditions} 227 | 228 | We now show that there are in fact sufficient conditions for an operator to be contraction mapping. 229 | 230 | \begin{thm}[Blackwell's Sufficient Conditions] 231 | 232 | Let $X \subset \mathbb R^l$ and let $C(X)$ be a space of bounded functions $f:X \to \mathbb R$, with the sup-metric. Let $B : C(X) \to C(X)$ be an operator satisfying two conditions: 233 | \begin{enumerate}[1.] 234 | \item monotonicity: if $f,g\in C(X)$ and $f(x)\leq g(x)$ $\forall x\in X$,% 235 | \newline 236 | then $(Bf)(x)\leq (Bg)(x),$ $\forall x\in X$\newline 237 | 238 | \item discounting: there exists some $\delta \in (0,1)$ such that 239 | \[ 240 | \lbrack B(f+a)](x)\leq (Bf)(x)+\delta a\text{ \ }\forall \text{ }f\in C(X),\ 241 | a\geq 0,\ x\in X. 242 | \]% 243 | \end{enumerate} 244 | 245 | \noindent 246 | Then, $B$ is a contraction with modulus $\delta$. 247 | 248 | \end{thm} 249 | 250 | \noindent 251 | Note that $a$ is a constant and $(f+a)$ is the function generated by adding $a$ to the function $f$. Blackwell's conditions are sufficient but not necessary for $B$ to be a contraction. 252 | 253 | \vspace{5mm} 254 | \noindent 255 | In this problem, we will prove these sufficient conditions. 256 | \begin{enumerate}[(a)] 257 | \item Let $d$ be the sup-metric and show that, for any $f, g \in C(X)$, we have $f(x) \leq g(x) + d(f, g)$ for all $x$ 258 | 259 | \item Use monotonicity and discounting to show that, for any $f, g \in C(X)$, we have $(Bf)(x) \leq (Bg)(x) + \delta d(f, g)$ and $(Bg)(x) \leq (Bf)(x) + \delta d(f, g)$. 260 | 261 | \item Combine these to show that $d(Bf, Bg) \leq \delta d(f, g)$. 262 | \end{enumerate} 263 | 264 | 265 | 266 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 267 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 268 | \vspace{5mm} 269 | \section*{Problem 4: Example of Blackwell's Conditions} 270 | 271 | We will now work out a simple example to illustrate these sufficient conditions. In particular, consider the Bellman operator in a consumption problem with stochastic asset returns, stochastic labor income, and a liquidity constraint: 272 | \begin{equation*} 273 | (Bf)(x)=\sup_{c\in \lbrack 0,x]}\left\{ u(c)+\delta \mathbb Ef(\tilde{R}_{+1}(x-c)+ 274 | \tilde{y}_{+1})\right\} \text{ \ }\forall x\text{\ } 275 | \end{equation*} 276 | Notionally, $\tilde R$ and $\tilde y$ just underscore that these are random variables. The $_{+1}$ subscript underscores that these random variables are realized next period (in class, we used $'$ for this). The liquidity constraint is encoded in $c \in [0, x]$. (Why?) 277 | 278 | 279 | \vspace{5mm} 280 | \noindent 281 | \begin{enumerate}[(a)] 282 | \item Interpret each term in the definition of this Bellman operator. 283 | 284 | \item Explicitly write out the budget constraint that is used here. 285 | 286 | \item Check the first of Blackwell's conditions: monotonicity. 287 | 288 | \item Check the second of Blackwell's conditions: discounting. 289 | \end{enumerate} 290 | 291 | 292 | 293 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 294 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 295 | \vspace{5mm} 296 | \section*{Problem 5: Neoclassical Growth Model with Log Utility} 297 | 298 | Recall the neoclassical growth model we discussed in class. Assuming log utility, full depreciation, and a decreasing-returns production function, preferences can be written as 299 | \begin{equation*} 300 | V(k_0) = \max_{ \{ k_{t+1} \}_{t=0}^\infty} \sum_{t=0}^\infty \beta^t \log (k_t^\alpha - k_{t+1}) 301 | \end{equation*} 302 | where $0 < \alpha < 1$, subject to the constraint 303 | \begin{equation*} 304 | k_{t+1} \in [0, k_t^\alpha] \equiv \Gamma(k_t). 305 | \end{equation*} 306 | Think of $k_t^\alpha$ as the resources you have available, and so the most you would be allowed to save is $k_t^\alpha$. We represent this constraint by the \textit{feasibility set} $\Gamma(k_t)$. (This is the more general notation you will find in Stokey-Lucas, for example.) 307 | 308 | Consider the associated Bellman equation 309 | \begin{equation*} 310 | V(k) = \max_{k' \in \Gamma(k)} \bigg\{ \ln (k^\alpha - k') + \beta V(k') \bigg\}. 311 | \end{equation*} 312 | 313 | \begin{enumerate}[(a)] 314 | \item Try to solve the Bellman equation by \textit{guessing} a solution. Specifically, start by guessing that the form of the solution is 315 | \begin{equation*} 316 | V(k) = \psi + \phi \log k. 317 | \end{equation*} 318 | We will solve for the coefficients $\psi$ and $\phi$, and show that $V(k)$ solves the functional equation. Rewrite the functional equation substituting in $V(k) = \psi + \phi \log k$. Use the Envelope Theorem (ET) and the First Order Condition (FOC) to show 319 | \begin{equation*} 320 | \phi = \frac{\alpha}{1 - \alpha \beta}. 321 | \end{equation*} 322 | Now use the FOC to show 323 | \begin{equation*} 324 | k'(k) = \alpha \beta k^\alpha. 325 | \end{equation*} 326 | Finally, show that the functional equation is satisfied at all feasible values of $k_0$ if 327 | \begin{equation*} 328 | \psi =\frac{1}{1-\beta }\bigg[ \log (1-\alpha \beta)+\frac{\alpha \beta}{1-\alpha \beta}\log (\alpha \beta )\bigg] . 329 | \end{equation*} 330 | You have now solved the functional equation by using the guess and verify method. 331 | 332 | 333 | \item We have derived the policy function 334 | \begin{equation*} 335 | k'(k) = g(k) = \alpha \beta k^\alpha. 336 | \end{equation*} 337 | Derive the optimal sequence of state variables $\{k_t^*\}_{t=0}^\infty$ which would be generated by this policy function. Show that 338 | \begin{equation*} 339 | V(k_0) = \sum_{t=0}^\infty \beta^t \log \bigg( (k_t^*)^\alpha - k_{t+1}^* \bigg), 340 | \end{equation*} 341 | thereby confirming that this policy function is optimal. 342 | 343 | 344 | \item Consider the Bellman (functional) operator $B$ defined by 345 | \begin{equation*} 346 | (B f)(k) = \sup_{k' \in \Gamma(k)} \Big\{ \log (k^\alpha - k') + \beta f(k') \Big\}. 347 | \end{equation*} 348 | Let $\hat V(k) = \frac{\alpha \log k}{1 - \alpha \beta}$. Show that 349 | \begin{equation*} 350 | (B^n \hat V)(k) = \frac{1-\beta^n}{1-\beta} \bigg[\log (1-\alpha \beta) + \frac{\alpha \beta}{1 - \alpha \beta} \log (\alpha \beta) \bigg] + \frac{\alpha \log k}{1 - \alpha \beta}. 351 | \end{equation*} 352 | To prove this you'll need to show that $k' = \alpha \beta k^\alpha$, and substitute this expression into the functional operator. Let, 353 | \begin{equation*} 354 | \lim_{n \rightarrow \infty} (B^n \hat V)(k) = V(k) 355 | \end{equation*} 356 | Confirm that $V(k)$ is the same solution to the the functional equation that you derived in part (a). You have now solved the functional equation by iterating the operator $T$ on a starting guess. 357 | 358 | \end{enumerate} 359 | 360 | 361 | 362 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 363 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 364 | \vspace{10mm} 365 | \section*{Problem 6: A Model with Equity} 366 | 367 | \vspace{5mm} 368 | \noindent 369 | Assume that a consumer with only equity wealth must choose period by period consumption in a discrete-time dynamic optimization problem. Specifically, consider the sequence problem 370 | \begin{equation*} 371 | V(x_0) = \max_{ \{ c_t \}_{t=0}^\infty } \mathbb E_0 \sum_{t=0}^\infty e^{- \rho t} u(c_t) 372 | \end{equation*} 373 | subject to the constraints 374 | \begin{equation*} 375 | x_{t+1} = e^{r + \sigma u_t - \frac{\sigma^2}{2}} (x_t - c_t) 376 | \end{equation*} 377 | where $u_t$ is iid and $u_t \sim \mathcal N(0, 1)$. There is a feasibility constraint $c_t \in [0, x_t]$. And we assume an endowment $x_0 > 0$. Here, $x_t$ represents equity wealth at period $t$ and $c_t$ is consumption in period $t$. The consumer has discount rate $\rho$. The consumer can only invest in a risky asset with expected return $e^r = \mathbb E e^{r + \sigma u_t - \frac{\sigma^2}{2}}$. And we assume CRRA preferences with $u(c) = \frac{1}{1-\gamma} c^{1-\gamma}$, with $\gamma \in [0, \infty]$. We call this \textit{constant} relative risk aversion because the relative risk aversion coefficient 378 | \begin{equation*} 379 | - \frac{c u''(c)}{u'(c)} = \gamma 380 | \end{equation*} 381 | is constant. Notice that CRRA consumption preferences are \textit{homothetic}, and this is what allows us to analytically solve this problem. 382 | 383 | The associated Bellman equation is 384 | \begin{equation*} 385 | V(x) = \max_{x' \in [0, x]} \bigg\{ u(x - x') + \mathbb E e^{- \rho} V \bigg( e^{r + \sigma u - \frac{\sigma^2}{2}} x' \bigg) \bigg\}. 386 | \end{equation*} 387 | 388 | 389 | \begin{enumerate}[(a)] 390 | \item Explain all terms in this Bellman equation. Why is $u$ not a state variable, i.e., why don't we have $V(x, u)$? Make sure that this equation makes sense to you. 391 | 392 | 393 | \item Now guess that the value function takes the special form 394 | \begin{equation*} 395 | V(x) = \phi \frac{x^{1-\gamma}}{1-\gamma} . 396 | \end{equation*} 397 | Note the close similarity between this functional form and the functional form of the utility function. Assuming that the value function guess is correct, use the Envelope Theorem to derive the consumption function: 398 | \begin{equation*} 399 | c=\phi^{-\frac{1}{\gamma}} x . 400 | \end{equation*} 401 | Now verify that the Bellman Equation is satisfied for a particular value of $\phi$. Do not solve for $\phi$ (it's a very nasty expression). Instead, show that 402 | \begin{equation*} 403 | \log (1 - \phi^{-\frac{1}{\gamma}}) = \frac{1}{\gamma} \Big[ (1-\gamma) r - \rho \Big] + \frac{1}{2}(\gamma-1) \sigma^2. 404 | \end{equation*} 405 | 406 | 407 | \item Now consider the $\log$ of the ratio of $c_{t+1}$ and $c_t$. Show that 408 | \begin{equation*} 409 | \mathbb E \log \bigg(\frac{c_{t+1}}{c_t}\bigg) = \frac{1}{\gamma}(r-\rho) + \frac{\gamma}{2} \sigma^2 - \sigma^2. 410 | \end{equation*} 411 | 412 | 413 | \item Interpret the previous equation for the certainty case $\sigma = 0$. Note that $\log (\frac{c_{t+1}}{c_t}) = \log c_{t+1} - \log c_t$ is the growth rate of consumption. Explain why $\log c_{t+1} - \log c_t$ increases in $r$ and decreases in $\rho$. Why does the coefficient of relative risk aversion $\gamma$ appear in the denominator of the expression? Why does the coefficient of relative risk aversion regulate the consumer's willingness to substitute consumption between periods? 414 | 415 | \end{enumerate} 416 | 417 | \end{document} 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | -------------------------------------------------------------------------------- /homework/homework2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework/homework2.pdf -------------------------------------------------------------------------------- /homework/homework2.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{extarticle} 2 | \usepackage{fullpage,amsmath,amsfonts,microtype,nicefrac,amssymb, amsthm} 3 | \usepackage[left=1in, bottom=1in, top=1in, right = 1in]{geometry} 4 | \usepackage{textcomp} 5 | \usepackage{mathpazo} 6 | \usepackage{mathrsfs} 7 | \usepackage[T1]{fontenc} 8 | \usepackage[utf8]{inputenc} 9 | \usepackage[english]{babel} 10 | \usepackage{graphicx} 11 | 12 | \usepackage{microtype} 13 | 14 | \usepackage{bm} 15 | \usepackage{dsfont} 16 | \usepackage{enumerate} 17 | \usepackage{ragged2e} 18 | 19 | \setlength{\parindent}{24pt} 20 | \setlength{\jot}{8pt} 21 | 22 | 23 | \usepackage[shortlabels]{enumitem} 24 | 25 | 26 | %% FOOTNOTES 27 | \usepackage[bottom]{footmisc} 28 | \usepackage{footnotebackref} 29 | 30 | 31 | %% FIGURE ENVIRONMENT 32 | %\graphicspath{{}} 33 | \usepackage[margin=15pt, font=small, labelfont={bf}, labelsep=period]{caption} 34 | \usepackage{subcaption} 35 | \captionsetup[figure]{name={Figure}, position=above} 36 | \usepackage{float} 37 | \usepackage{epstopdf} 38 | 39 | 40 | %% NEW COMMANDS 41 | \renewcommand{\baselinestretch}{1.25} 42 | \renewcommand{\qedsymbol}{$\blacksquare$} 43 | \newcommand{\R}{\mathbb{R}} 44 | \newcommand{\indep}{\mathrel{\text{\scalebox{1.07}{$\perp\mkern-10mu\perp$}}}} 45 | \renewcommand{\b}{\begin} 46 | \newcommand{\e}{\end} 47 | 48 | %% NEWTHEOREM 49 | \theoremstyle{plain} 50 | \newtheorem{thm}{Theorem} 51 | \newtheorem{lem}[thm]{Lemma} 52 | \newtheorem{prop}[thm]{Proposition} 53 | 54 | \theoremstyle{definition} 55 | \newtheorem{defn}[thm]{Definition} 56 | \newtheorem{ex}[thm]{Example} 57 | \newtheorem{remark}[thm]{Remark} 58 | \newtheorem{cor}[thm]{Corollary} 59 | 60 | %% LINKS and COLORS 61 | \usepackage[dvipsnames]{xcolor} 62 | \usepackage{hyperref} 63 | \definecolor{myred}{RGB}{163, 32, 45} 64 | \hypersetup{ 65 | %backref=true, 66 | %pagebackref=true, 67 | colorlinks=true, 68 | urlcolor=myred, 69 | citecolor=myred, 70 | linktoc=all, 71 | linkcolor=myred, 72 | } 73 | 74 | %% TABLE OF CONTENTS 75 | \addto\captionsenglish{ 76 | \renewcommand{\contentsname} 77 | {}% This removes the heading over the table of contents. 78 | } 79 | 80 | 81 | 82 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 84 | %%%%%%%%%%%%%%%%%%%%%% END PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%% 85 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87 | 88 | \title{202A: Dynamic Programming and Applications\\[5pt] {\Large \textbf{Homework \#2}}} 89 | 90 | \author{Andreas Schaab\footnote{ 91 | UC Berkeley. Email: schaab@berkeley.edu.\\ 92 | This course builds on the excellent teaching material developed, in particular, by David Laibson and Benjamin Moll. I would also like to thank Gabriel Chodorow-Reich, Pablo Kurlat, J\'on Steinsson, and Gianluca Violante, as well as QuantEcon, on whose teaching material I have drawn. 93 | }} 94 | 95 | \date{} 96 | 97 | 98 | \begin{document} 99 | 100 | \maketitle 101 | 102 | 103 | 104 | 105 | 106 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 107 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 108 | \vspace{5mm} 109 | \section*{Problem 1: Optimal Stopping} 110 | 111 | Consider the optimal stopping application from class: Each period $t = 0, 1, \ldots$ the consumer draws a job offer from a uniform distribution with support in the unit interval: $x \sim \text{unif}[0, 1]$. The consumer can either accept the offer and realize net present value $x$, or the consumer can wait another period and draw again. Once you accept an offer the game ends. Waiting to accept an offer is costly because the value of the remaining offers declines at rate $\rho = - \log(\beta)$ between periods. The Bellman equation for this problem is: 112 | \begin{equation*} 113 | V(x) = \max \bigg\{ x, \; \beta \mathbb E V(x') \bigg\} 114 | \end{equation*} 115 | where $x'$ is your next draw, which is a random variable. 116 | 117 | 118 | \vspace{2mm} 119 | \begin{enumerate}[(a)] 120 | \item Explain the intuition behind this Bellman equation. Explain every term. 121 | 122 | \item Briefly describe one decision problem you have faced in your own life that could be modeled using the above Bellman equation. 123 | 124 | \item Consider the associated functional operator: 125 | \begin{equation*} 126 | (Bw)(x) = \max \bigg\{ x, \; \beta \mathbb E w(x') \bigg\} 127 | \end{equation*} 128 | for all $x$. Using Blackwell's conditions, show that this Bellman operator is a contraction mapping. 129 | 130 | \item What does the contraction mapping property imply about $\lim_{n \to \infty} B^n w$, where $w$ is \textit{any} arbitrary function? 131 | 132 | \item Suppose we make a (bad?) guess $w(x) = 1$ for all $x$. Analytically iterate on $B^n w$ and show that 133 | \begin{equation*} 134 | \lim_{n \to \infty} (B^n w) (x) = V(x) = \begin{cases} 135 | x^* & \text { if } x \leq x^* \\ 136 | x & \text { if } x > x^* 137 | \end{cases} 138 | \end{equation*} 139 | where 140 | \begin{equation*} 141 | x^* = e^\rho \bigg( 1 - \Big[ 1 - e^{- 2 \rho} \Big]^\frac{1}{2} \bigg). 142 | \end{equation*} 143 | \end{enumerate} 144 | 145 | 146 | 147 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 148 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 149 | \vspace{5mm} 150 | \section*{Problem 2: Optimal Project Completion} 151 | 152 | Every period you draw a cost $c$ distributed uniformly between $0$ and $1$ for completing a project. If you undertake the project, you pay $c$, and complete the project with probability $1-p$. Each period in which the project remains uncompleted, you pay a late fee of $l$. The game continues until you complete the project. 153 | 154 | 155 | \vspace{2mm} 156 | \begin{enumerate}[(a)] 157 | \item Write down the Bellman Equation assuming no discounting. Why is it ok to assume no discounting in this problem? 158 | 159 | \item Derive the optimal threshold: $c^* = \sqrt{2l}$. Explain intuitively, why this threshold does not depend on the probability of failing to complete the project, $p$. 160 | 161 | \item How would these results change if we added discounting to the framework? Redo steps a and b, assuming that the agent discounts the future with discount factor $0 < \beta < 1$ and assuming that $p = 0$. Show that the optimal threshold is given by 162 | \begin{equation*} 163 | c^* = \frac{1}{\beta} \bigg( \beta - 1 + \sqrt{ (1-\beta)^2 + 2 \beta^2 l } \bigg) 164 | \end{equation*} 165 | 166 | \item When $0 < \beta < 1$, is the optimal value of $c^*$ still independent of the value of $p$? If not, how does $c^*$ qualitatively vary with $p$? Provide an intuitive argument. 167 | 168 | \item Take the perspective of an agent who has not yet observed the current period's draw of $c$. Prove that the expected delay until completion is given by: 169 | \begin{equation*} 170 | \frac{1}{c^*(1-p)} - 1 171 | \end{equation*} 172 | 173 | \end{enumerate} 174 | 175 | 176 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 177 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 178 | \newpage 179 | \section*{Problem 3: Consumption-Savings with Deterministic Income} 180 | 181 | Consider an economy populated by a continuum of infinitely lived households. There is no uncertainty in this economy for now. Households' preferences are given by 182 | \begin{equation*} 183 | \max \int_0^\infty e^{-\rho t} u(c_t) dt. 184 | \end{equation*} 185 | That is, households discount future consumption $c_t$ at a rate $\rho$. Oftentimes, we will use constant relative risk aversion (CRRA) preferences, given by 186 | \begin{equation*} 187 | u(c_t) = \frac{c_t^{1-\gamma}}{1-\gamma}. 188 | \end{equation*} 189 | A special form of these preferences are log preferences, 190 | \begin{equation*} 191 | u(c_t) = \log(c_t). 192 | \end{equation*} 193 | 194 | 195 | The household's flow budget constraint in this economy is given by 196 | \begin{equation*} 197 | \frac{d}{dt}(P_t a_t) = i_t (P_t a_t) - P_t c_t + P_t y_t, 198 | \end{equation*} 199 | where $P_t$ is the nominal price level, $c_t$ is real consumption expenditures, $a_t$ is the real wealth of the household and $\{y_t\}$ is an \textbf{exogenous} stream of income whose future path the household knows at any time point with certainty (because there is no uncertainty or risk for now). 200 | 201 | 202 | \vspace{5mm} 203 | \begin{enumerate} 204 | \item [(a)] Derive the budget constraint for real wealth, i.e., $\frac{d}{dt} a_t = \dot a_t$. Define the real interest rate as $r_t = i_t - \pi_t$, where $\pi_t \equiv \frac{\dot P_t}{P_t}$ is price inflation. 205 | 206 | \item [(b)] Derive the lifetime budget constraint 207 | 208 | \item [(c)] In class, we have so far always worked with the flow budget constraint as our constraint. And then we used either calculus of variations or optimal control theory. Alterantively, we can use the lifetime budget constraint as our constraint in this setting. (Why? When would you not be able to work with a lifetime budget constraint?) Set up the optimization problem with the lifetime budget constraint (i.e., write down the Lagrangian and introduce a multiplier) and take the first-order conditions. Solve for a consumption Euler equation. 209 | 210 | \item [(d)] Consider the two functional forms given earlier for utility, $u(c_t)$. Plug them into the Euler equation and solve for the term $\frac{u'(c_t)}{ u''(c_t) c_t}$. 211 | \end{enumerate} 212 | 213 | 214 | \vspace{6mm} 215 | \noindent 216 | We will now derive the simple Euler equation using two different approaches. The first approach will be using optimal control theory. In Problem 2, we will then use dynamic programming and confirm that the two approaches are equivalent. 217 | 218 | \vspace{5mm} 219 | \begin{enumerate} 220 | \item [(e)] Write down the optimal control problem. Identify the state, control variables and multipliers. 221 | 222 | \item [(f)] Write down the (current-value) Hamiltonian. 223 | 224 | \item [(g)] Find the FOCs. Rearrange and again find the consumption Euler equation. Confirm that it's the same equation we derived above. 225 | \end{enumerate} 226 | 227 | 228 | 229 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 230 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 231 | \vspace{5mm} 232 | \section*{Problem 4: Consumption-Savings using Dynamic Programming} 233 | 234 | We concluded Problem 1 by deriving the household's consumption Euler equation using optimal control theory. We will now do the same using dynamic programming. 235 | 236 | 237 | Consider again the preferences of our household, given by 238 | \begin{equation*} 239 | V_0 = \max_{\{c_t\}_{t>0}} \int_0^\infty e^{-\rho t} u(c_t) dt, 240 | \end{equation*} 241 | as well as the flow budget constraint 242 | \begin{equation*} 243 | \dot a_t = r_t a_t + y_t - c_t, 244 | \end{equation*} 245 | where the household takes the (deterministic) paths of real interest rates $\{r_t\}$ and income $\{y_t\}$ as given. 246 | 247 | 248 | We will now derive a recursive representation of the household's value function, and use the resulting Hamilton-Jacobi-Bellman (HJB) equation to derive the consumption Euler equation. 249 | 250 | 251 | \vspace{2mm} 252 | \begin{enumerate}[(a)] 253 | \item We will derive a recursive representation for the household value function $V_t(a) = V(t, a)$. Why does the value function take this form in this context? I.e., why does $V$ depend explicitly on calendar time, and why are we working with a representation of the problem where $a$ is the only state variable? 254 | 255 | \item In class, we derived the HJB heuristically, starting with a discrete time Bellman equation and taking the continuous time limit. We will now derive the HJB equation from the sequence problem. Recall in Lecture 1 we derived the Bellman equation from the sequence problem in discrete time. Please follow the same general proof strategy and derive the HJB in continuous time. You should arrive at the following HJB equation: 256 | \begin{equation*} 257 | \rho V_t(a) = \partial_t V_t(a) + \max_c \bigg\{ u(c) + \Big[ r_t a + y_t - c \Big] \partial_a V_t(a) \bigg\} 258 | \end{equation*} 259 | where $\partial_x$ denotes the partial derivative with respect to $x$. 260 | 261 | \item Why is there a $\partial_t V_t(a)$ term? 262 | 263 | \item Write down the FOC for consumption and interpret every term. Define and discuss the consumption policy function. 264 | 265 | \item Plug the consumption policy function back into the HJB. Discuss why this is now a non-linear partial differential equation. 266 | 267 | \item Take the envelope condition by differentiating the HJB with respect to $a$. 268 | 269 | \item Use the chain rule to characterize $\frac{d}{dt} V(t, a_t)$, taking into account explicitly that $a_t$ is also a function of time. 270 | 271 | \item You will now arrive at the consumption Euler equation by combining 3 equations: the characterization of $\frac{d}{dt} V_t(a_t)$ from the previous part, the FOC, and the envelope condition. 272 | 273 | \end{enumerate} 274 | 275 | 276 | 277 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 278 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 279 | \vspace{5mm} 280 | \section*{Problem 5: Oil Extraction} 281 | 282 | Time is continuous and indexed by $t \in [0, \infty)$. At time $t=0$, there is a finite amount of oil $x_0$. Denote by $c_t$ the rate of oil consumption at date $t$. Oil is non-renewable, so the remaining amount of oil at date $t$ is 283 | \begin{equation*} 284 | x_t = x_0 - \int_0^t c_s ds. 285 | \end{equation*} 286 | A social planner (the government) wants to set the rate of oil consumption to maximize utility of the representative household given by 287 | \begin{equation*} 288 | \int_0^\infty e^{- \rho t} u(c_t) dt, 289 | \end{equation*} 290 | with $u(c) = \log(c)$. 291 | 292 | \vspace{2mm} 293 | \begin{enumerate}[(a)] 294 | \item Explain the expression for the remaining amount of oil: $x_t = x_0 - \int_0^t c_s ds$ 295 | 296 | \item Set up the (present-value) Hamiltonian for this problem. List all state variables, control variables, and multipliers 297 | 298 | \item Write down the first-order necessary conditions. Solve for the optimal policy $c_t$ 299 | 300 | \item Write down the HJB equation for this problem 301 | 302 | \item Guess and verify that the value function is $V(x) = a + b \log(x)$. Solve for $a$ and $b$ 303 | \end{enumerate} 304 | 305 | 306 | 307 | 308 | \end{document} 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | -------------------------------------------------------------------------------- /homework/homework3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework/homework3.pdf -------------------------------------------------------------------------------- /homework/homework3.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{extarticle} 2 | \usepackage{fullpage,amsmath,amsfonts,microtype,nicefrac,amssymb, amsthm} 3 | \usepackage[left=1in, bottom=1in, top=1in, right = 1in]{geometry} 4 | \usepackage{textcomp} 5 | \usepackage{mathpazo} 6 | \usepackage{mathrsfs} 7 | \usepackage[T1]{fontenc} 8 | \usepackage[utf8]{inputenc} 9 | \usepackage[english]{babel} 10 | \usepackage{graphicx} 11 | 12 | \usepackage{microtype} 13 | 14 | \usepackage{bm} 15 | \usepackage{dsfont} 16 | \usepackage{enumerate} 17 | \usepackage{ragged2e} 18 | 19 | \setlength{\parindent}{24pt} 20 | \setlength{\jot}{8pt} 21 | 22 | 23 | \usepackage[shortlabels]{enumitem} 24 | 25 | 26 | %% FOOTNOTES 27 | \usepackage[bottom]{footmisc} 28 | \usepackage{footnotebackref} 29 | 30 | 31 | %% FIGURE ENVIRONMENT 32 | %\graphicspath{{}} 33 | \usepackage[margin=15pt, font=small, labelfont={bf}, labelsep=period]{caption} 34 | \usepackage{subcaption} 35 | \captionsetup[figure]{name={Figure}, position=above} 36 | \usepackage{float} 37 | \usepackage{epstopdf} 38 | 39 | 40 | %% NEW COMMANDS 41 | \renewcommand{\baselinestretch}{1.25} 42 | \renewcommand{\qedsymbol}{$\blacksquare$} 43 | \newcommand{\R}{\mathbb{R}} 44 | \newcommand{\indep}{\mathrel{\text{\scalebox{1.07}{$\perp\mkern-10mu\perp$}}}} 45 | \renewcommand{\b}{\begin} 46 | \newcommand{\e}{\end} 47 | 48 | %% NEWTHEOREM 49 | \theoremstyle{plain} 50 | \newtheorem{thm}{Theorem} 51 | \newtheorem{lem}[thm]{Lemma} 52 | \newtheorem{prop}[thm]{Proposition} 53 | 54 | \theoremstyle{definition} 55 | \newtheorem{defn}[thm]{Definition} 56 | \newtheorem{ex}[thm]{Example} 57 | \newtheorem{remark}[thm]{Remark} 58 | \newtheorem{cor}[thm]{Corollary} 59 | 60 | %% LINKS and COLORS 61 | \usepackage[dvipsnames]{xcolor} 62 | \usepackage{hyperref} 63 | \definecolor{myred}{RGB}{163, 32, 45} 64 | \hypersetup{ 65 | %backref=true, 66 | %pagebackref=true, 67 | colorlinks=true, 68 | urlcolor=myred, 69 | citecolor=myred, 70 | linktoc=all, 71 | linkcolor=myred, 72 | } 73 | 74 | %% TABLE OF CONTENTS 75 | \addto\captionsenglish{ 76 | \renewcommand{\contentsname} 77 | {}% This removes the heading over the table of contents. 78 | } 79 | 80 | 81 | 82 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 84 | %%%%%%%%%%%%%%%%%%%%%% END PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%% 85 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87 | 88 | \title{202A: Dynamic Programming and Applications\\[5pt] {\Large \textbf{Homework \#3}}} 89 | 90 | \author{Andreas Schaab} 91 | 92 | \date{} 93 | 94 | 95 | \begin{document} 96 | 97 | \maketitle 98 | 99 | 100 | 101 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 102 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 103 | \section*{Problem 1: Brownian Motion} 104 | 105 | This problem collects several exercises on Brownian motion and stochastic calculus. We denote standard Brownian motion by $B_t$. 106 | 107 | \begin{enumerate}[(a)] 108 | 109 | \item Show that $\mathbb Cov(B_s, B_t) = \min\{s, t\}$ for two times $0 \leq s < t$. Use the following tricks: Use the covariance formula $\mathbb Cov(A, B) = \mathbb E (AB) - \mathbb E(A) \mathbb E(B)$. Use $B_t \sim \mathcal N(0, t)$ as well as $B_t - B_s \sim \mathcal N(0, t-s)$. And use $B_t = B_s + (B_t - B_s)$. 110 | 111 | 112 | \item Let $X_t = B_t^2$. What is $\mathbb E X_t$? What is $\mathbb Cov (X_t, X_s)$? 113 | 114 | 115 | \item Let $X_t = B_{t+s} - B_s$ for some fixed $s > 0$. Let $Y_t = \frac{1}{\sqrt \lambda} B_{\lambda t}$. Show that both $X_t$ and $Y_t$ are standard Brownian motion; that is, show the following 5 properties: 116 | \begin{enumerate}[(i)] 117 | \item $X_0 = Y_0 = 0$ 118 | \item $X_t, Y_t \sim \mathcal N(0, t)$ 119 | \item Stationarity 120 | \item Independent increments 121 | \item Continuous 122 | \end{enumerate} 123 | 124 | 125 | \item Geometric Brownian motion evolves as: $dX_t = \mu X_t dt + \sigma X_t dB_t$ given an initial value $X_0$. Show that $X_t = X_0 e^{\mu t - \frac{\sigma^2}{2} t + \sigma B_t}$. Also show that $\mathbb E = X_0 e^{\mu t}$. 126 | 127 | \item The Ornstein-Uhlenbeck (OU) process is like a continuous-time variant of the AR(1) process. It evolves as $dX_t = - \mu X_t dt + \sigma dB_t$ for drift parameter $\mu$, diffusion parameter $\sigma$, and some $X$. Show that it solves $X_t = X_0 e^{- \mu t} + \sigma \int_0^t e^{-\mu(t - s)} dB_s$. 128 | 129 | \item Let $X_t = \int_0^t B_s ds$ and $Y_t = \int_0^t B_s^2 ds$. Compute $\mathbb E(X_t)$ and $\mathbb E(Y_t)$, as well as $\mathbb Var(X_t)$ and $\mathbb Var(Y_t)$. 130 | \end{enumerate} 131 | 132 | 133 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 134 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 135 | \vspace{5mm} 136 | \section*{Problem 2: Poisson Process} 137 | 138 | \begin{enumerate}[(a)] 139 | \item Consider a two-state Markov chain in continuous time denoted $Y_t$, which can take on values in $\{Y^1, Y^2\}$. The transition rate is given by $\lambda$ regardless of the current state. Suppose we are in state $1$ at $t = 0$. Compute the expected time until the process switches to state $2$. 140 | 141 | \item Now suppose that the transition rates differ depending on which state we are in. That is, if we're in state $1$ we transition to rate $2$ at rate $\lambda_1$, and vice versa at rate $\lambda_2$. Show that the fraction of time the process spends in states $1$ and $2$ converges in the long run to $\frac{\lambda_2}{\lambda_1 + \lambda_2}$ and $\frac{\lambda_1}{\lambda_1 + \lambda_2}$. 142 | 143 | \item What is $\mathbb E (Y_t \mid Y_0 = Y^1)$? 144 | 145 | \end{enumerate} 146 | 147 | 148 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 149 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 150 | \vspace{5mm} 151 | \section*{Problem 3: Ito's Lemma} 152 | 153 | \begin{enumerate}[(a)] 154 | \item Let $dX_t = - \alpha X_t dt + \sigma dB_t$, and $f(t, X_t) = e^{\alpha t} X_t$. Show that $df = \sigma e^{\alpha t} d B$. 155 | 156 | \item Consider the capital accumulation equation $dK_t = (\iota - \delta) K_t dt + \sigma K_t dB_t$, where $\iota$ is the investment rate. Suppose our value function is $V(K_t)$. Use Ito's lemma to solve for $dV_t$. 157 | 158 | \item Suppose $X_t = f(t, B_t)$ for some function $f$. In this problem, we will solve for $f$. The only information we have is that 159 | \begin{equation*} 160 | dX_t = X_t dB_t. 161 | \end{equation*} 162 | Use Ito's lemma to derive two conditions on the partial derivatives of $f(\cdot)$. (That is, group the $dt$ and $dB$ terms and reason via coefficient-matching.) Show that the function $f(t, x) = e^{x - \frac{1}{2}t}$ satisfies these conditions. 163 | \end{enumerate} 164 | 165 | 166 | 167 | 168 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 169 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 170 | \vspace{5mm} 171 | \section*{Problem 4: Generator} 172 | 173 | We defined the generator of a stochastic process in class. The generator is extremely useful when we want to quickly write down the HJB associated with a dynamic optimization problem. 174 | 175 | \vspace{4mm} 176 | \begin{enumerate}[(a)] 177 | \item Consider the wealth and income processes 178 | \begin{align*} 179 | da_t &= (ra_t + y_t - c_t)dt + \sigma dB_t \\ 180 | dy_t &= \theta (\bar y - y_t) dt + \nu dW_t 181 | \end{align*} 182 | where $B_t$ and $W_t$ are independent standard Brownian motion. Write down the generator $\mathcal A$ for the two-dimensional process 183 | \begin{equation*} 184 | \begin{pmatrix} 185 | d a_t \\ 186 | d y_t 187 | \end{pmatrix} 188 | \end{equation*} 189 | That is, what is $\mathcal A V$ for a given (smooth) function $V(a_t, y_t)$? 190 | 191 | \item Consider the capital accumulation process 192 | \begin{align*} 193 | dk_t &= (\iota - \delta) k_t dt. 194 | \end{align*} 195 | Also suppose that firm technology $A_t$ follows a two-state Markov chain (Poisson process) with transition rates $\lambda$. That is, $A_t$ can take on values in $\{A^1, A^2\}$. Suppose that the enterprise value of the firm is given by some function $V(k_t, A_t)$. Characterize the generator of the process 196 | \begin{equation*} 197 | \begin{pmatrix} 198 | d k_t \\ 199 | d A_t 200 | \end{pmatrix} 201 | \end{equation*} 202 | That is, what is $\mathcal A V$ for a given (smooth) function $V(k_t, A_t)$? (Recall that $\mathcal A V = \mathbb E[d V]$, so the expression you just solved for tells us how the firm's enterprise value evolves in expectation.) 203 | 204 | \end{enumerate} 205 | 206 | 207 | 208 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 209 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 210 | \vspace{5mm} 211 | \section*{Problem 5: Consumption with Income Uncertainty} 212 | 213 | Consider a household whose lifetime utility is given by 214 | \begin{equation*} 215 | V_0 = \max_{ \{c_t\} } \, \mathbb E_0 \int_0^\infty e^{- \rho t} u(c_t) dt. 216 | \end{equation*} 217 | The household makes consumption-savings decisions facing the budget constraint 218 | \begin{equation*} 219 | da_t = (r a_t + y_t - c_t)dt. 220 | \end{equation*} 221 | Here, $y_t$ is the household's income process. We cannot perfectly forecast our future income, so we will assume that $y_t$ is a stochastic process. Below, you will be asked to write down the HJB associated with this problem for the two canonical models of income uncertainty. 222 | 223 | \vspace{4mm} 224 | \begin{enumerate}[(a)] 225 | \item Suppose that income follows the diffusion (Ornstein-Uhlenbeck / AR1) process 226 | \begin{equation*} 227 | dy_t = \theta(\bar y - y_t) dt + \sigma dB_t. 228 | \end{equation*} 229 | Write down the HJB for this problem that characterizes the household value function $V(a, y)$. 230 | 231 | \item Now suppose that income follows a two-state Markov chain (Poisson process). Income can be high or low, $\in \{y^L, y^H\}$. The transition rate from high to low is $\lambda^H$ and the transition rate from low to high is $\lambda^L$. Write down the HJB for this problem that characterizes the household value function $V(a, y)$. 232 | 233 | \item Suppose that the interest rate is not constant but varies over time. We know with certainty, however, how the interest rate evolves. So $\{r_t\}$ is a deterministic sequence that is exogenously given to us. (In other words, we are characterizing the household problem in partial equilibrium; the household takes the interest rate as given.) Write down the HJB for this problem that characterizes the household value function $V(t, a, y)$. Why is this value function no longer stationary? 234 | 235 | \end{enumerate} 236 | 237 | 238 | 239 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 240 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 241 | % \vspace{5mm} 242 | % \section*{Problem 6: Job Market Paper} 243 | % 244 | % Imagine you were a graduate student in economics, and you are currently searching for and working on what will hopefully become your job market paper. You have to go on the job market at date $T$ (it is currently date $t = 0$). Your objective is to maximize 245 | % \begin{equation*} 246 | % V_0 = \max \, \mathbb E_0 \bigg[ - \int_0^T v(\ell_t) dt + x_T \bigg]. 247 | % \end{equation*} 248 | % Here, $\ell_t$ is your rate of work (think: total hours you work in a day), and $v(\cdot)$ encodes the disutility you get from working. You can spend your working time on one of two activities: either you search for a new project to work on ($s_t$) or you continue working on your current project ($w_t$), facing the budget constraint 249 | % \begin{equation*} 250 | % \ell_t = s_t + w_t. 251 | % \end{equation*} 252 | % 253 | % 254 | % \vspace{4mm} 255 | % \begin{enumerate}[(a)] 256 | % \item Suppose that income follows the diffusion (Ornstein-Uhlenbeck / AR1) process 257 | % 258 | % \end{enumerate} 259 | 260 | 261 | 262 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 263 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 264 | \vspace{5mm} 265 | \section*{Problem 6: Consumption and Portfolio Choice} 266 | 267 | Consider a household that can trade two assets. The first asset is a stock. Stocks trade at price $Q_t$ and they pay the holder dividends at rate $D_t$. That is, when you hold the stock, your ``return'' comprises both the dividend payouts and the change in price until you sell the stock, which may be positive or negative. Formally, the rate of return on the stock is 268 | \begin{equation*} 269 | dR = \frac{D dt + dQ}{Q}, 270 | \end{equation*} 271 | where $\frac{D}{Q}$ is the dividend-price ratio and $\frac{dQ}{Q}$ is capital gains (change in price). We will now assume that the return process takes the form 272 | \begin{equation*} 273 | d R = \mu dt + \sigma dB. 274 | \end{equation*} 275 | for some $\mu$ and $\sigma$, where $B$ is standard Brownian motion. 276 | 277 | 278 | The second asset the household can trade is a bond, which trades at price $P$. And we assume that the bond price evolves simply according to 279 | \begin{equation*} 280 | \frac{dP}{P} = r dt, 281 | \end{equation*} 282 | which is the same as saying that holding the bond earns a riskfree rate of return $r dt$. Crucially, the household can both buy and sell these assets. Assume there are no borrowing (or short-sale) constraints. 283 | 284 | The household's lifetime value is given by 285 | \begin{equation*} 286 | V_0 = \max \mathbb E_0 \int_0^\infty e^{- \rho t} u(c_t) dt. 287 | \end{equation*} 288 | Let's denote by $b_t$ and $k_t$ the household's bond and stock holdings. Then the household budget constraint is 289 | \begin{equation*} 290 | Q dk + P db + c dt = D k dt. 291 | \end{equation*} 292 | Why does the budget constraint take this form? On the RHS, households earn dividends at rate $D$ for each unit of stock they hold. On the LHS, households can spend on consumption, or they can choose to purchase stocks or bonds. If $dk > 0$, the household purchases new stocks at price $Q$ on top of the current stock holdings. If $dk < 0$, the household sells stocks. 293 | 294 | 295 | We now define \textit{net worth} $n$ and the \textit{risky portfolio share} $\theta$ implicity via 296 | \begin{align*} 297 | \theta n &= Q k \\ 298 | (1-\theta) n &= Pb 299 | \end{align*} 300 | In other words, $n$ is a notion of total wealth of the household. And we say that the household invests fraction $\theta$ of total wealth in stocks, and fraction $1-\theta$ in bonds. 301 | 302 | 303 | \vspace{5mm} 304 | \begin{enumerate}[(a)] 305 | \item Derive the law of motion for household net worth and show that it satisfies: 306 | \begin{equation*} 307 | dn = \bigg[ r n + \theta n \Big( \mu - r \Big) - c \bigg] dt + \theta n \sigma dB 308 | \end{equation*} 309 | 310 | \item Derive the recursive representation of the households optimization problem. That is, write down the HJB equation that characterizes the household value function $V(n)$. Why was it useful to rewrite the household problem in terms of net worth (rather than stock and bond holdings)? Why is this value function stationary? 311 | 312 | \item Derive the first-order conditions for $c$ and the portfolio share $\theta$. 313 | 314 | \item \textit{Optional and more difficult}: Derive the Euler equation for marginal utility and show that it satisfies 315 | \begin{equation*} 316 | \frac{du_c}{u_c} = (\rho - r) dt - \frac{\mu - r}{\sigma} dB. 317 | \end{equation*} 318 | Show that with CRRA utility, this implies a consumption Euler equation 319 | \begin{equation*} 320 | \frac{dc}{c} = \frac{r - \rho}{\gamma} dt + \frac{1+\gamma}{2} \bigg( \frac{\mu - r}{\gamma \sigma} \bigg)^2 dt + \frac{\mu - r}{\gamma \sigma} dB. 321 | \end{equation*} 322 | 323 | 324 | \item Guess and verify that 325 | \begin{equation*} 326 | V(n) = \frac{1}{1-\gamma} \kappa^{-\gamma} n^{1-\gamma} 327 | \end{equation*} 328 | where $\kappa = \frac{1}{\gamma} \Big[ \rho - (1-\gamma)r - \frac{1-\gamma}{2\gamma} \Big( \frac{\mu-r}{\sigma} \Big)^2 \Big]$. 329 | 330 | 331 | \item Given the solution for $V(n)$, use the FOCs to also solve for $c(n)$ and $\theta(n)$. You have now solved the household portfolio choice problem in closed form!! 332 | 333 | 334 | \item What does this model tell us? Consider the interesting special case of log utility with $\gamma = 1$. Show that consumption collapses to $c = \rho n$. This implies that you want to consume a constant fraction $\rho$ of lifetime net worth. But how much should you invest in the stock market according to this model? Take the formula for $\theta$ and plug in log utility. Let's assume an equity premium of $6\%$, so $\mu-r = 0.0.06$. And let's assume volatility of stock returns of $16\%$, so $\sigma = 0.16$. Solve for the numeric value of $\theta$, i.e., the fraction of your total wealth that this model tells you to invest in the stock market. Is this high or low? What if ``total wealth'' also includes a notion of your human capital? 335 | 336 | \end{enumerate} 337 | 338 | \end{document} 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | -------------------------------------------------------------------------------- /homework/homework4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework/homework4.pdf -------------------------------------------------------------------------------- /homework/homework5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework/homework5.pdf -------------------------------------------------------------------------------- /homework/homework5.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{extarticle} 2 | \usepackage{fullpage,amsmath,amsfonts,microtype,nicefrac,amssymb, amsthm} 3 | \usepackage[left=1in, bottom=1in, top=1in, right = 1in]{geometry} 4 | \usepackage{textcomp} 5 | \usepackage{mathpazo} 6 | \usepackage{mathrsfs} 7 | \usepackage[T1]{fontenc} 8 | \usepackage[utf8]{inputenc} 9 | \usepackage[english]{babel} 10 | \usepackage{graphicx} 11 | 12 | \usepackage{microtype} 13 | 14 | \usepackage{bm} 15 | \usepackage{dsfont} 16 | \usepackage{enumerate} 17 | \usepackage{ragged2e} 18 | 19 | \setlength{\parindent}{24pt} 20 | \setlength{\jot}{8pt} 21 | 22 | 23 | \usepackage[shortlabels]{enumitem} 24 | 25 | 26 | %% FOOTNOTES 27 | \usepackage[bottom]{footmisc} 28 | \usepackage{footnotebackref} 29 | 30 | 31 | %% FIGURE ENVIRONMENT 32 | %\graphicspath{{}} 33 | \usepackage[margin=15pt, font=small, labelfont={bf}, labelsep=period]{caption} 34 | \usepackage{subcaption} 35 | \captionsetup[figure]{name={Figure}, position=above} 36 | \usepackage{float} 37 | \usepackage{epstopdf} 38 | 39 | 40 | %% NEW COMMANDS 41 | \renewcommand{\baselinestretch}{1.25} 42 | \renewcommand{\qedsymbol}{$\blacksquare$} 43 | \newcommand{\R}{\mathbb{R}} 44 | \newcommand{\indep}{\mathrel{\text{\scalebox{1.07}{$\perp\mkern-10mu\perp$}}}} 45 | \renewcommand{\b}{\begin} 46 | \newcommand{\e}{\end} 47 | 48 | %% NEWTHEOREM 49 | \theoremstyle{plain} 50 | \newtheorem{thm}{Theorem} 51 | \newtheorem{lem}[thm]{Lemma} 52 | \newtheorem{prop}[thm]{Proposition} 53 | 54 | \theoremstyle{definition} 55 | \newtheorem{defn}[thm]{Definition} 56 | \newtheorem{ex}[thm]{Example} 57 | \newtheorem{remark}[thm]{Remark} 58 | \newtheorem{cor}[thm]{Corollary} 59 | 60 | %% LINKS and COLORS 61 | \usepackage[dvipsnames]{xcolor} 62 | \usepackage{hyperref} 63 | \definecolor{myred}{RGB}{163, 32, 45} 64 | \hypersetup{ 65 | %backref=true, 66 | %pagebackref=true, 67 | colorlinks=true, 68 | urlcolor=myred, 69 | citecolor=myred, 70 | linktoc=all, 71 | linkcolor=myred, 72 | } 73 | 74 | %% TABLE OF CONTENTS 75 | \addto\captionsenglish{ 76 | \renewcommand{\contentsname} 77 | {}% This removes the heading over the table of contents. 78 | } 79 | 80 | 81 | 82 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 84 | %%%%%%%%%%%%%%%%%%%%%% END PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%% 85 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87 | 88 | \title{202A: Dynamic Programming and Applications\\[5pt] {\Large \textbf{Homework \#5}}} 89 | 90 | \author{Andreas Schaab\footnote{ 91 | UC Berkeley. Email: schaab@berkeley.edu.\\ 92 | This course builds on the excellent teaching material developed, in particular, by David Laibson and Benjamin Moll. I would also like to thank Gabriel Chodorow-Reich, Pablo Kurlat, J\'on Steinsson, and Gianluca Violante, as well as QuantEcon, on whose teaching material I have drawn. 93 | }} 94 | 95 | \date{} 96 | 97 | 98 | \begin{document} 99 | 100 | \maketitle 101 | 102 | The theoretical part of this Homework is very short. In Problem 1, you will set up the model of Aiyagari (1994) in continuous time and define its competitive equilibrium. In the numerical part of the Homework, you will then write code to solve this model numerically. 103 | 104 | 105 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 106 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 107 | \section*{Problem 1: Aiyagari (1994)} 108 | 109 | Time is continuous, $t \in [0, \infty)$, and there is no aggregate uncertainty. We allow for one-time, unanticipated (``MIT'') shocks to TFP (agents have perfect foresight with respect to this aggregate shock). Concretely, we denote by $A_t$ the TFP of the economy at date $t$, and $\{A_t\}$ is an exogenously given but deterministic sequence. 110 | 111 | 112 | \paragraph{Households.} 113 | The economy is populated by a continuum of measure one of households. Consider a household $i \in [0, 1]$. Household $i$'s preferences are encoded in her lifetime utility 114 | \begin{equation*} 115 | V_{i, 0} = \max_{ \{c_{i, t}\}_{t \geq 0} } \; \mathbb E_0 \int_0^\infty e^{- \rho t} u(c_{i, t}) dt. 116 | \end{equation*} 117 | 118 | 119 | The economy features a single asset---capital. Households are the owners of capital and rent it to firms. Denote the stock of capital owned by household $i$ at date $t$ by $k_{i, t}$. The household faces the budget constraints 120 | \begin{align*} 121 | c_{i, t} + i_{i, t} &= z_{i, t} w_t + r_t^k k_{i, t} \\ 122 | \dot k_{i, t} &= i_{i, t} - \delta k_{i, t} . 123 | \end{align*} 124 | The first line of the budget constraint says that household expenditures---consumption and investment---must equal her income. Income comprises labor income and income from renting capital to firms at rate $r_t^k$. We assume that households supply one unit of labor inelastically, earning wage rate $w_t$. But households also face idiosyncratic earnings risk: $z_{i, t}$ denotes the household's idiosyncratic labor productivity, and the wage $w_t$ is paid on efficiency units of work, rather than hours of work. We assume that $z_{i, t}$ follows a two-state Markov chain, with individual labor productivity taking on values in $\in \{z^L, z^H\}$. You may interpret $z^L$ as unemployment and $z^H$ as employment. Households transition between these dates at transition rates $\lambda$ (symmetric for simplicity). 125 | 126 | 127 | The second line summarizes the household's capital accumulation technology. Putting these two equations together, the household's stock of capital evolves simply as 128 | \begin{equation*} 129 | \dot k_{i, t} = r_t k_{i, t} + z_{i, t} w_t - c_{i, t}, 130 | \end{equation*} 131 | where we denote by $r_t$ the effective real rate of return on owning capital. Finally, we assume that households also face a short-sale constraint on capital 132 | \begin{equation*} 133 | k_{i, t} \geq 0. 134 | \end{equation*} 135 | 136 | 137 | \begin{enumerate} 138 | \item [(a)] Write down household $i$'s problem in sequence form. 139 | 140 | \item [(b)] Next, we characterize a recursive representation for the household problem. In terms of which state variables will we be able to derive a recursive representation? Write down the HJB for this problem. Is the HJB stationary---why or why not? Why are we now dropping the $i$ subscript when writing down this recursive representation of the household problem? 141 | 142 | \item [(c)] Where in the HJB does the short-sale constraint show up? Write down the explicit condition for this. 143 | 144 | \item [(d)] Take the first-order condition. 145 | \end{enumerate} 146 | 147 | 148 | \paragraph{Aggregation.} 149 | We denote by $g_t(k, z)$ the joint density of households over capital and individual labor productivities at date $t$. 150 | 151 | \begin{enumerate} 152 | \item [(e)] Write down the Kolmogorov forward equation for $g_t(k, z)$. 153 | \end{enumerate} 154 | 155 | 156 | \paragraph{Firms.} 157 | There is a representative firm that operates the production technology 158 | \begin{equation*} 159 | Y_t = A_t K_t^\alpha L_t^{1-\alpha}, 160 | \end{equation*} 161 | where the deterministic sequence $\{A_t\}$ denotes TFP. The firm maximizes profit $Y_t - w_t L_t - r_t^k K_t$. We use capital letters here to signify that $K_t$ and $L_t$ denote aggregate capital and labor. 162 | 163 | 164 | \begin{enumerate} 165 | \item [(f)] Write down the firm problem and take first-order conditions. This should yield two conditions for factor prices $w_t$ and $r_t^k$. Why are the implied profits zero? 166 | \end{enumerate} 167 | 168 | 169 | \paragraph{Markets and equilibrium.} 170 | 171 | 172 | \begin{enumerate} 173 | \item [(g)] Which markets have to clear in equilibrium? Write down each market clearing condition. 174 | 175 | \item [(h)] Define (recursive) competitive equilibrium. 176 | 177 | \item [(i)] Explicitly write down the system of equations that competitive equilibrium characterizes. Convince yourself that you have account for $\{c_t(k, z), V_t(k, z), g_t(k, z), Y_t, L_t, K_t\}_{t \geq 0}$ and $\{r_t, r_t^k, w_t\}_{t \geq 0}$. 178 | 179 | \item [(j)] Define stationary competitive equilibrium. Dropping time subscripts to denote allocation and prices in steady state, make sure you have accounted for $\{c(k, z), V(k, z), g(k, z), Y, L, K\}$ and $\{r, r^k, w\}$. 180 | \end{enumerate} 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | \end{document} 196 | -------------------------------------------------------------------------------- /homework_coding/homework_coding_week1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/homework_coding_week1.pdf -------------------------------------------------------------------------------- /homework_coding/homework_coding_week3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/homework_coding_week3.pdf -------------------------------------------------------------------------------- /homework_coding/homework_coding_week4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/homework_coding_week4.pdf -------------------------------------------------------------------------------- /homework_coding/homework_coding_week5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/homework_coding_week5.pdf -------------------------------------------------------------------------------- /homework_coding/honework_coding_week2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/honework_coding_week2.pdf -------------------------------------------------------------------------------- /homework_coding/solutions/homework_coding_week1_sol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/solutions/homework_coding_week1_sol.pdf -------------------------------------------------------------------------------- /homework_coding/solutions/homework_coding_week2_sol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/solutions/homework_coding_week2_sol.pdf -------------------------------------------------------------------------------- /homework_coding/solutions/homework_coding_week3_sol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/solutions/homework_coding_week3_sol.pdf -------------------------------------------------------------------------------- /homework_coding/solutions/homework_coding_week4_sol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_coding/solutions/homework_coding_week4_sol.pdf -------------------------------------------------------------------------------- /homework_solutions/Homework_Solutions_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_solutions/Homework_Solutions_1.pdf -------------------------------------------------------------------------------- /homework_solutions/Homework_Solutions_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_solutions/Homework_Solutions_2.pdf -------------------------------------------------------------------------------- /homework_solutions/Homework_Solutions_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_solutions/Homework_Solutions_3.pdf -------------------------------------------------------------------------------- /homework_solutions/Homework_Solutions_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_solutions/Homework_Solutions_4.pdf -------------------------------------------------------------------------------- /homework_solutions/Homework_Solutions_5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/homework_solutions/Homework_Solutions_5.pdf -------------------------------------------------------------------------------- /lectures/Brownian1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/Brownian1.png -------------------------------------------------------------------------------- /lectures/Brownian2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/Brownian2.png -------------------------------------------------------------------------------- /lectures/Brownian3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/Brownian3.png -------------------------------------------------------------------------------- /lectures/Brownian4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/Brownian4.png -------------------------------------------------------------------------------- /lectures/Brownian5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/Brownian5.png -------------------------------------------------------------------------------- /lectures/Brownian6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/Brownian6.png -------------------------------------------------------------------------------- /lectures/Brownian7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/Brownian7.png -------------------------------------------------------------------------------- /lectures/figures/HACT_MPC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_MPC.png -------------------------------------------------------------------------------- /lectures/figures/HACT_accuracy_consumption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_accuracy_consumption.png -------------------------------------------------------------------------------- /lectures/figures/HACT_accuracy_error1000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_accuracy_error1000.png -------------------------------------------------------------------------------- /lectures/figures/HACT_accuracy_error30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_accuracy_error30.png -------------------------------------------------------------------------------- /lectures/figures/HACT_consumption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_consumption.png -------------------------------------------------------------------------------- /lectures/figures/HACT_diffusion_distribution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_diffusion_distribution.png -------------------------------------------------------------------------------- /lectures/figures/HACT_diffusion_savings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_diffusion_savings.png -------------------------------------------------------------------------------- /lectures/figures/HACT_distribution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_distribution.png -------------------------------------------------------------------------------- /lectures/figures/HACT_distribution2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_distribution2.png -------------------------------------------------------------------------------- /lectures/figures/HACT_example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_example1.png -------------------------------------------------------------------------------- /lectures/figures/HACT_example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_example2.png -------------------------------------------------------------------------------- /lectures/figures/HACT_existence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_existence.png -------------------------------------------------------------------------------- /lectures/figures/HACT_savings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_savings.png -------------------------------------------------------------------------------- /lectures/figures/HACT_savings2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_savings2.png -------------------------------------------------------------------------------- /lectures/figures/HACT_spyA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_spyA.png -------------------------------------------------------------------------------- /lectures/figures/HACT_transition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/HACT_transition.png -------------------------------------------------------------------------------- /lectures/figures/ikc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/ikc1.png -------------------------------------------------------------------------------- /lectures/figures/ikc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/ikc2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_consumption_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_consumption_0.png -------------------------------------------------------------------------------- /lectures/figures/inequality_consumption_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_consumption_1.png -------------------------------------------------------------------------------- /lectures/figures/inequality_consumption_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_consumption_2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_consumption_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_consumption_3.png -------------------------------------------------------------------------------- /lectures/figures/inequality_earnings_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_earnings_1.png -------------------------------------------------------------------------------- /lectures/figures/inequality_earnings_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_earnings_2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_earnings_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_earnings_3.png -------------------------------------------------------------------------------- /lectures/figures/inequality_earnings_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_earnings_4.png -------------------------------------------------------------------------------- /lectures/figures/inequality_earnings_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_earnings_5.png -------------------------------------------------------------------------------- /lectures/figures/inequality_earnings_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_earnings_6.png -------------------------------------------------------------------------------- /lectures/figures/inequality_earnings_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_earnings_7.png -------------------------------------------------------------------------------- /lectures/figures/inequality_government_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_government_1.png -------------------------------------------------------------------------------- /lectures/figures/inequality_government_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_government_2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_government_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_government_3.png -------------------------------------------------------------------------------- /lectures/figures/inequality_government_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_government_4.png -------------------------------------------------------------------------------- /lectures/figures/inequality_household_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_household_1.png -------------------------------------------------------------------------------- /lectures/figures/inequality_household_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_household_2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_household_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_household_3.png -------------------------------------------------------------------------------- /lectures/figures/inequality_polarization_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_polarization_1.png -------------------------------------------------------------------------------- /lectures/figures/inequality_polarization_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_polarization_2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_polarization_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_polarization_3.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_1.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_10.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_11.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_12.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_3.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_4.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wage_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wage_5.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wealth_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wealth_1.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wealth_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wealth_2.png -------------------------------------------------------------------------------- /lectures/figures/inequality_wealth_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/inequality_wealth_3.png -------------------------------------------------------------------------------- /lectures/figures/liquidity_constraint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/liquidity_constraint.png -------------------------------------------------------------------------------- /lectures/figures/precautionary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/precautionary.png -------------------------------------------------------------------------------- /lectures/figures/skiba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/skiba.png -------------------------------------------------------------------------------- /lectures/figures/skiba1978.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/skiba1978.png -------------------------------------------------------------------------------- /lectures/figures/skiba_savings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/skiba_savings.png -------------------------------------------------------------------------------- /lectures/figures/skiba_spyA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/skiba_spyA.png -------------------------------------------------------------------------------- /lectures/figures/skiba_value.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/skiba_value.png -------------------------------------------------------------------------------- /lectures/figures/spyA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/figures/spyA.png -------------------------------------------------------------------------------- /lectures/lecture1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture1.pdf -------------------------------------------------------------------------------- /lectures/lecture10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture10.pdf -------------------------------------------------------------------------------- /lectures/lecture11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture11.pdf -------------------------------------------------------------------------------- /lectures/lecture2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture2.pdf -------------------------------------------------------------------------------- /lectures/lecture3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture3.pdf -------------------------------------------------------------------------------- /lectures/lecture5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture5.pdf -------------------------------------------------------------------------------- /lectures/lecture7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture7.pdf -------------------------------------------------------------------------------- /lectures/lecture9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/lectures/lecture9.pdf -------------------------------------------------------------------------------- /sections/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /sections/Section 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/sections/Section 1.pdf -------------------------------------------------------------------------------- /sections/Section 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/sections/Section 2.pdf -------------------------------------------------------------------------------- /sections/Section 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/sections/Section 3.pdf -------------------------------------------------------------------------------- /sections/Section_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/sections/Section_4.pdf -------------------------------------------------------------------------------- /sections/Section_5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/sections/Section_5.pdf -------------------------------------------------------------------------------- /sections/Syllabus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schaab-teaching/DynamicProgramming2024/481cfd8d139e31f496842efe7df60fa3664d10f4/sections/Syllabus.pdf -------------------------------------------------------------------------------- /sections/codes/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /sections/codes/week1/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /sections/codes/week1/capital_accumulation.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % MATLAB Script: capital_accumulation.m 3 | % 4 | % Author: Kiyea Jin 5 | % Date: October 14, 2024 6 | % 7 | % Description: 8 | % This script solves the continuous-time capital accumulation equation: 9 | % dK/dt = I - delta * K 10 | % where {I} represents a constant, exogenously given investment, and 11 | % an initial condition for capital K0 is provided. 12 | % 13 | % The solutions are obtained using: 14 | % 1. The integrating factor method for the analytical solution. 15 | % 2. The finite difference method for the numerical solution. 16 | % 17 | % The script also: 18 | % 3. Plots both the analytical and numerical solutions for comparison. 19 | % 4. Explores how the numerical solution varies with grid fineness. 20 | % 21 | % Parameters: 22 | % - Depreciation rate (delta): 0.05 23 | % - Constant investment (I): 0 or 5 24 | % - Initial boundary condition: K0 = 10 25 | % 26 | % Code Structure: 27 | % 1. DEFINE PARAMETERS 28 | % 2. INITIALIZE GRID POINTS 29 | % 3. ANALYTICAL SOLUTION: INTEGRATING FACTOR METHOD 30 | % 4. NUMERICAL SOLUTION: FINITE DIFFERENCE METHOD 31 | % 5. PLOT 32 | % (6. SOLVE USING ODE45) 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | 35 | clear all; 36 | close all; 37 | clc; 38 | 39 | %% 1. DEFINE PARAMETERS 40 | 41 | p = define_parameters(); 42 | 43 | %% 2. INITIALIZE GRID POINTS 44 | 45 | t = linspace(p.tmin, p.tmax, p.I)'; 46 | dt = (p.tmax-p.tmin)/(p.I-1); 47 | 48 | % Define investment series 49 | I = p.Inv*ones(p.I,1); 50 | 51 | %% 3. ANALYTICAL SOLUTION: INTEGRATING FACTOR METHOD 52 | 53 | % 3-1. Pre-allocate arrays for solutions 54 | K_analytical = zeros(p.I,1); 55 | 56 | % 3-2. Analytical solution: K(t) = I(t)/delta*(1-exp^{-delta*t})+exp^{-delta*t}*K(0) 57 | for i=1:p.I 58 | 59 | K_analytical(i) = (I(i)/p.delta) * (1 - exp(-p.delta*t(i))) + exp(-p.delta*t(i)) * p.K0; 60 | 61 | end 62 | 63 | %% 4. NUMERICAL SOLUTION: FINITE DIFFERENCE METHOD 64 | 65 | % 4-1. Pre-allocate arrays for solutions 66 | K_numerical = zeros(p.I,1); 67 | K_numerical(1) = p.K0; 68 | 69 | % 4-2. Numerical solution: (K(t+dt)-K(t))/dt = I(t) - delta*K(t) 70 | 71 | for i=1:p.I-1 72 | 73 | K_numerical(i+1) = K_numerical(i) + dt * (I(i) - p.delta*K_numerical(i)); 74 | 75 | end 76 | 77 | %% 5. PLOT 78 | 79 | % Compute the difference between two solutions 80 | error = K_analytical - K_numerical; 81 | 82 | % Plot both solutions for comparison 83 | figure; 84 | plot(t, K_analytical, 'r-', 'LineWidth', 2); hold on; 85 | plot(t, K_numerical, 'bo--', 'LineWidth', 1.5); 86 | xlabel('Time', 'FontSize', 11); 87 | ylabel('Capital (K)', 'FontSize', 11); 88 | legend('Analytical Solution', 'Numerical Solution (FDM)', 'FontSize', 12); 89 | title('Comparison of Analytical and Numerical Solutions', 'FontSize', 15); 90 | grid on; 91 | 92 | %% (6. SOLVE USING ODE45) 93 | % ode45 Solve non-stiff differential equations, medium order method. 94 | % [TOUT,YOUT] = ode45(ODEFUN,TSPAN,Y0) integrates the system of 95 | % differential equations y' = f(t,y) from time TSPAN(1) to TSPAN(end) 96 | % with initial conditions Y0. Each row in the solution array YOUT 97 | % corresponds to a time in the column vector TOUT. 98 | 99 | % Define the ODE as a function handle 100 | ODE_capital = @(t, K) p.Inv - p.delta * K; 101 | 102 | K_numerical2 = zeros(p.I,1); 103 | 104 | % Call ode45 to solve the ODE 105 | [t, K_numerical2] = ode45(ODE_capital, t, p.K0); 106 | 107 | % Plot both solutions for comparison 108 | figure; 109 | plot(t, K_numerical, 'bo--', 'LineWidth', 2); hold on; 110 | plot(t, K_numerical2, 'go--', 'LineWidth', 1.5); 111 | xlabel('Time', 'FontSize', 11); 112 | ylabel('Capital (K)', 'FontSize', 11); 113 | legend('FD Scheme', 'ODE45', 'FontSize', 12); 114 | title('Comparison of FD Scheme and ODE45', 'FontSize', 15); 115 | grid on; 116 | -------------------------------------------------------------------------------- /sections/codes/week1/define_parameters.m: -------------------------------------------------------------------------------- 1 | function p = define_parameters() 2 | 3 | % This function defines the parameters needed for the capital_accumulation.m script 4 | 5 | %% Economic Parameters 6 | 7 | % Depreciation rate 8 | p.delta = 0.05; 9 | 10 | % Exogenous constant investment 11 | p.Inv = 5; 12 | 13 | %% Boundary Conditions 14 | 15 | % Initial capital 16 | p.K0 = 10; 17 | 18 | %% Grid Paramters 19 | 20 | % The minimum time value in the time domain (start of the simulation) 21 | p.tmin = 0; 22 | 23 | % The maximum time value in the time domain (end of the simulation) 24 | p.tmax = 300; 25 | 26 | % The number of time steps 27 | p.I = 100; 28 | 29 | end -------------------------------------------------------------------------------- /sections/codes/week2/ramsey/define_parameters.m: -------------------------------------------------------------------------------- 1 | function p = define_parameters() 2 | 3 | % This function defines the parameters needed for the ramsey.m script 4 | 5 | %% Economic Parameters 6 | 7 | % Discount rate 8 | p.rho = 0.03; 9 | 10 | % Inverse of IES 11 | p.theta = 1; 12 | 13 | % Technology growth rate 14 | p.g = 0.02; 15 | 16 | % Population growth rate 17 | p.n = 0.02; 18 | 19 | % Capital share 20 | p.alpha = 1/3; 21 | 22 | % TFP 23 | p.A = 1; 24 | 25 | %% Economic Functions 26 | 27 | % Production function 28 | p.f = @(k) p.A * k.^p.alpha; 29 | 30 | % MPK 31 | p.f_prime = @(k) p.alpha * p.A * k.^(p.alpha - 1); 32 | 33 | %% Boundary Conditions 34 | 35 | % Initial capital 36 | p.k0 = 10; 37 | 38 | %% Grid Paramters 39 | 40 | p.tmin = 0; 41 | p.tmax = 100; 42 | 43 | % The number of time steps 44 | p.I = 300; 45 | 46 | %% Newton Method Tuning Parameters 47 | 48 | % Tolerance for Newton's method 49 | p.tol = 1e-6; 50 | 51 | % Maximum iterations for Newton's method 52 | % p.maxit = 1000; 53 | 54 | end -------------------------------------------------------------------------------- /sections/codes/week2/ramsey/forward_simulate.m: -------------------------------------------------------------------------------- 1 | function [k, c] = forward_simulate(c0, k0, f, f_prime, rho, theta, g, n, dt, I) 2 | 3 | % This function solves the two differential equations using forward simulation. 4 | 5 | % Pre-allocate arrays for solution 6 | 7 | k = zeros(I, 1); 8 | c = zeros(I, 1); 9 | k(1) = k0; 10 | c(1) = c0; 11 | 12 | for i = 1:I-1 13 | 14 | % Euler equation for consumption growth: (c(i+1)-c(i))/dt = c(i)*(f'(k(i)-rho-theta*g)/theta 15 | c(i+1) = c(i) + dt * (f_prime(k(i)) - rho - theta * g) / theta * c(i); 16 | 17 | % Capital accumulation equation:(k(i+1)-k(i))/dt = f(k(i))-c(i)-(n+g)k(i) 18 | k(i+1) = k(i) + dt * (f(k(i)) - c(i) - (n + g) * k(i)); 19 | end 20 | 21 | end -------------------------------------------------------------------------------- /sections/codes/week2/ramsey/ramsey.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % MATLAB Script: ramsey.m 3 | % 4 | % Author: Kiyea Jin 5 | % Date: October 15, 2024 6 | % 7 | % Description: 8 | % This script solves the Ramsey-Cass-Koopmans model 9 | % using FD scheme with shooting algorithm. 10 | % 11 | % The model consists of two equations: 12 | % (dc/dt)/c = (f'(k) - rho - theta*g)/theta 13 | % dk/dt = f(k) - c - (n+g)k 14 | % where an initial condition for capital K0 is provided, 15 | % and intertemporal budget constraint with equality is imposed as a terminal condition. 16 | % 17 | % Parameters: 18 | % - Discount rate (rho): 0.03 19 | % - Inverse of IES (theta): 1 20 | % - Technology growth rate (g): 0.02 21 | % - Population growth rate (n): 0.02 22 | % - Capital share (alpha): 1/3 23 | % - TFP (A): 1 24 | % - Initial boundary condition: K0 = 10 25 | % 26 | % Code Structure: 27 | % 1. DEFINE PARAMETERS 28 | % 2. INITIALIZE GRID POINTS 29 | % 3. STEADY STATES 30 | % 4. SHOOTING ALGORITHM 31 | % 5. PLOT 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 | 34 | clear all; 35 | close all; 36 | clc; 37 | 38 | %% 1. DEFINE PARAMETERS 39 | 40 | p = define_parameters(); 41 | 42 | %% 2. INITIALIZE GRID POINTS 43 | 44 | t = linspace(p.tmin, p.tmax, p.I)'; 45 | dt = (p.tmax-p.tmin)/(p.I-1); 46 | 47 | %% 3. STEADY STATES 48 | % kss = ((rho + theta*g)/(alpha*A))^(1/(alpha-1)) 49 | % css = Ak^alpha - (n+g)*kss 50 | 51 | kss = ((p.rho + p.theta * p.g) / (p.alpha * p.A))^(1 / (p.alpha - 1)); 52 | css = p.f(kss) - (p.n+p.g) * kss; 53 | 54 | %% 4. SHOOTING ALGORITHM 55 | 56 | % 4-1. Find the initial value of consumption that satisfies terminal boundary condition 57 | 58 | tic; 59 | % Objective function that calculates the difference between terminal capital k(T) and steady-state kss 60 | % Note: k(T)-kss is a function of c0 61 | diff = @(c0) terminal_condition(c0, p.k0, kss, p.f, p.f_prime, p.rho, p.theta, p.g, p.n, dt, p.I); 62 | 63 | % Guess an initial value of consumption 64 | c0_guess = 1; 65 | 66 | % Use fsolve to find the initial consumption c0 that makes k(T) = k_ss 67 | % Note: X = fsolve(FUN, X0, options) starts at the matrix X0 and tries to solve the equations in FUN. 68 | % Set OPTIONS = optimoptions('fsolve','Algorithm','trust-region'), and then pass OPTIONS to fsolve. 69 | options = optimoptions('fsolve', 'TolFun', p.tol, 'Display', 'iter'); 70 | c0 = fsolve(diff, c0_guess, options); 71 | 72 | % 4-2. Forward simulate with the updated initial consumption 73 | 74 | [k, c] = forward_simulate(c0, p.k0, p.f, p.f_prime, p.rho, p.theta, p.g, p.n, dt, p.I); 75 | toc; 76 | 77 | %% 5. PLOT 78 | 79 | % 5-1. Evolution of capital and consumption 80 | 81 | figure; 82 | subplot(2,1,1); 83 | plot(t, k, 'r-', 'LineWidth', 2); 84 | xlabel('Time'); ylabel('Capital k(t)'); 85 | title('Capital Accumulation over Time'); 86 | 87 | subplot(2,1,2); 88 | plot(t, c, 'b-', 'LineWidth', 2); 89 | xlabel('Time'); ylabel('Consumption c(t)'); 90 | title('Consumption Growth over Time'); 91 | 92 | %% 5-2. Phase diagram 93 | 94 | % Saddle path 95 | figure; 96 | p1 = plot(k, c, 'linewidth', 2); 97 | set(gca, 'FontSize', 18) 98 | xlabel('Capital, k','FontSize', 18) 99 | ylabel('Consumption, c','FontSize',18) 100 | 101 | % dk/dt = 0 102 | k_null_c = p.f(k) - (p.n+p.g)*k; 103 | hold on 104 | p2 = plot(k, k_null_c, 'linewidth', 2); 105 | yy = get(gca, 'yLim'); 106 | 107 | % dc/dt = 0 108 | p3 = plot([kss kss], yy, 'linewidth', 2); 109 | 110 | legend1 = legend([p1,p2,p3], 'Saddle path', '\Delta k=0', '\Delta c=0'); 111 | set(legend1, 'Location', 'best', 'FontSize', 18) 112 | hold off -------------------------------------------------------------------------------- /sections/codes/week2/ramsey/terminal_condition.m: -------------------------------------------------------------------------------- 1 | function difference = terminal_condition(c0, k0, kss, f, f_prime, rho, theta, g, n, dt, I) 2 | 3 | % This function calculates the difference between terminal capital k(T) and 4 | % steady-state kss. 5 | 6 | [k, ~] = forward_simulate(c0, k0, f, f_prime, rho, theta, g, n, dt, I); 7 | k_T = k(end); % Terminal capital k(T) 8 | 9 | % The difference between terminal k(T) and steady-state k_ss 10 | difference = k_T - kss; 11 | end -------------------------------------------------------------------------------- /sections/codes/week2/ramsey_HJB/HJB_ramsey_implicit_demo.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % MATLAB Code: HJB_ramsey_implicit 3 | % 4 | % Author: Kiyea Jin 5 | % Date: Oct 27, 2024 6 | % 7 | % Description: 8 | % This MATLAB script implements implicit method to solve the HJB equation 9 | % of the deterministic Ramsey Growth Model using mixed method. Boundary 10 | % conditions are not yet considered in this script. 11 | % 12 | % Reference: 13 | % HJB_NGM_implicit.m by Benjamin Moll 14 | % ramsey_implicit.m by Pontus Rendahl 15 | % 16 | % Notes: 17 | % - CRRA utility function: U(c) = (c^(1-gamma))/(1-gamma) 18 | % - Production function: f(k) = A*k^alpha 19 | % - Relative risk aversion coefficient (gamma): 2 20 | % - Discount rate (rho): 0.03 21 | % - Depreciation rate (delta): 0.025 22 | % - Elasticity of output with respect to capital (alpha): 1/3 23 | % - Total fator productivity (A): 1 24 | % - Delta = 1000 (Can be arbitrarily large in implicit method) 25 | % 26 | % Code Structure: 27 | % 1. DEFINE PARAMETERS 28 | % 2. INITIALIZE GRID POINTS 29 | % 3. PRE-ITERATION INITIALIZATION 30 | % 4. VALUE FUNCTION ITERATION 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | 33 | clear all; 34 | close all; 35 | clc; 36 | 37 | %% 1. DEFINE PARAMETERS 38 | 39 | p = define_parameters_demo(); 40 | 41 | %% 2. INITIALIZE GRID POINTS 42 | 43 | % Steady-state level of capital: f'(kss)=rho+delta 44 | kss = ((p.rho+p.delta)/(p.A*p.alpha))^(1/(p.alpha-1)); 45 | 46 | % log(k_min) = log(kss)-p.klim 47 | k_min = kss*exp(-p.klim); 48 | k_max = kss*exp(p.klim); 49 | 50 | k = linspace(k_min, k_max, p.I)'; 51 | dk = (k_max-k_min)/(p.I-1); 52 | 53 | %% 3. PRE-ITERATION INITIALIZATION 54 | 55 | % 3-1. Construct the differential operator D such that DV=dV 56 | 57 | D = zeros(p.I, p.I); 58 | 59 | % Forward differencing for i=1 60 | D(1,1) = -1/dk; D(1,2) = 1/dk; 61 | 62 | % Backward differencing for i=I 63 | D(end,end-1) = -1/dk; D(end,end) = 1/dk; 64 | 65 | % Central differencing for i=2,...,I-1 66 | for i = 2:p.I-1 67 | D(i,i-1) = -0.5/dk; D(i,i+1) = 0.5/dk; 68 | end 69 | 70 | % 3-2. Guess an initial value of the value function 71 | 72 | v0 = p.u(p.f(k) - p.delta*k)/p.rho; 73 | V = v0; 74 | 75 | % 3-3. Guess an initial value of the consumption 76 | % Notes: This script does not consider the boundary conditions, so we'll 77 | % impose an initial value of consumption 78 | 79 | c0 = p.f(k); 80 | c = c0; 81 | 82 | %% 4. VALUE FUNCTION ITERATION 83 | 84 | tic; 85 | 86 | for n = 1:p.maxit 87 | 88 | % 4-3. Compute the optimal savings 89 | s = p.f(k) - p.delta*k - c; 90 | 91 | % 4-4. Update the value function: V^(n+1) = [(rho+1/Delta)*I - SD]^(-1)[u(c) + 1/Delta*V^n] 92 | 93 | % B = [(rho+1/Delta)*I - SD] 94 | S = diag(s); 95 | B = (p.rho + 1/p.Delta)*eye(p.I) - S*D; 96 | 97 | % b = [u(c) + 1/Delta*V^n] 98 | b = p.u(c) + 1/p.Delta*V; 99 | 100 | % V^(n+1) = B^(-1)*b 101 | V_update = B\b; 102 | 103 | % Update the value function 104 | V_change = V_update - V; 105 | V = V_update; 106 | 107 | % 4-1. Compute the derivative of the value function 108 | dV = D*V; 109 | 110 | % 4-2. Compute the optimal consumption 111 | c = p.inv_mu(dV); 112 | 113 | % 4-5. Check convergence 114 | 115 | dist(n) = max(abs(V_change)); 116 | 117 | if dist(n)