In this lab assignment you will analyze a very simple Precautionary Savings problem
# Import relevant modules
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
Write out the individual's inter-temporal budget constraint.
Write out the Euler Equation.
If $x = 0$, what is $c_1$?
If u(c) is a quadratic utility function, how does consumption in the first period respond to setting $x\neq 0$. Explain your answer.
Now consider the utility function:
\begin{equation} u(c) = 1-e^{-\theta c} \end{equation}Using the code for the utility function provided below as a blueprint, define another Python function that returns the marginal utility of consumption.
def cara_utility(c):
"""Constant absolute risk aversion utility function."""
utility = 1 - np.exp(-theta * c)
return utility
def cara_marginal_utility(c):
"""Derivative of the constant absolute risk aversion utility function."""
marginal_utility = # INSERT YOUR CODE HERE!
return marginal_utility
Find $u'''(c)$, and the Coefficients of Relative and Absolute Risk Aversion (possibly as functions of c). What type of function is this?
The code in the cell below plots $u'(c)$ for multiple values of $\theta$. Using the diagram (and perhaps your answer from part f) explain the relationship between $\theta$ and the level of precautionary savings.
plt.figure(figsize=(8,6))
# grid for plotting
plot_grid = np.linspace(0, 0.5, 1000)
for theta in np.logspace(-1, 1, 5):
plt.plot(plot_grid, cara_marginal_utility(plot_grid), label=r'$\theta=%g$' %theta)
plt.xlabel('Consumption, $c$', fontsize=15, family='serif')
plt.ylabel("$u'(c)$", rotation='horizontal', fontsize=15)
plt.title(r'Marginal utility of consumption for various $\theta$', fontsize=20, family='serif')
plt.legend(loc='best', frameon=False)
plt.show()
For the case where $x\neq 0$, find $c_1$.
Now define $D$ as precautionary savings. i.e. Amount of savings made with risky income minus the level of savings made without risk. Analyse how $D$ responds to a change in $\theta , A$ or $x$, where a rise in $x$ is equivalent to an increase in the variance of income.
Hint: You could possibly create a function in your ipython notebook called D(A, x)
, graph this, and anaylse for different values of the inputs/parameters, keeping the other fixed.
# Insert optional code here!
def crra_utility(c):
"""Constant absolute risk aversion utility function."""
utility = # INSERT YOUR CODE HERE!
return utility
def crra_marginal_utility(c):
"""Derivative of the constant absolute risk aversion utility function."""
marginal_utility = # INSERT YOUR CODE HERE!
return marginal_utility
# INSERT YOUR CODE FOR PLOTTING MARGINAL UTILITY FOR VARIOUS THETA HERE!
Compare your results to part(i) of question 1 to your equivalent results for the new utility function.