{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Weekly exercise 16: Accuracy vs runtime trade-off in Deaton model.\n", "\n", "In this exercise you will compare the accuracy of several solution methods for the stochastic consumption-savings model.\n", "\n", "## Task 1\n", "\n", "Start by copying the code of `deaton` class from the video notebook 40." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ " # paste the deaton class code here\n", " # alternatively (and this is a better option) create file deaton.py in the same directory, paste the code there, and include it using \"import * from deaton.py\" command" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 2\n", "\n", "Make sure the code from the lecture runs and produces the same output" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "m = deaton(ngrid=100,nchgrid=250,sigma=.5,nquad=10, bellman_type='continuous')\n", "print(m)\n", "v,c = m.solve_plot(solver='timeiter')\n", "m.accuracy(verbose=True)\n", "sims = m.simulator(init_wealth=m.Mbar*np.arange(15)/15,T=25,seed=2020)\n", "\n", "v,c = m.solve_plot(solver='vfi')\n", "m.accuracy(verbose=True)\n", "sims = m.simulator(init_wealth=m.Mbar*np.arange(15)/15,T=25,seed=2020)\n", "\n", "m.bellman_type='discretized'\n", "v,c = m.solve_plot(solver='vfi')\n", "m.accuracy(verbose=True)\n", "sims = m.simulator(init_wealth=m.Mbar*np.arange(15)/15,T=25,seed=2020)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 3\n", "\n", "Consider the three solution methods above:\n", "\n", "- VFI with discretized choices \n", "- VFI with continuous choices \n", "- Time iterations \n", "\n", "\n", "Choose parametrization for the test model, compute the accuracy measure for each method.\n", "\n", "Then, by changing various (technical) parameters of the model, for each of the three methods, choose one parameter that influences the accuracy of that method the most.\n", "\n", "Finally, make a plot to visualize the trade-off between accuracy and run time. It should have run time on vertical axis and accuracy measure on the horizontal axis. Three curves\n", "should correspond to the three solution methods, and should be composed on the points obtained for different settings identified as important factors influencing the accuracy for each method.\n", "\n", "Make the plot look good and be easy to read." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "# Write your code here" ] } ], "metadata": { "date": 1627475014.616064, "filename": "exercise15.rst", "kernelspec": { "display_name": "Python", "language": "python3", "name": "python3" }, "title": "Weekly exercise 16: Accuracy vs runtime trade-off in Deaton model." }, "nbformat": 4, "nbformat_minor": 4 }