.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/asset_pricing/consumption/plot_01_lucas_tree.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_asset_pricing_consumption_plot_01_lucas_tree.py: Lucas's tree ============ Robert Lucas (1978) priced assets in the simplest economy that has them: a representative agent with power utility owns a tree whose fruit is the only consumption good. Prices must make the agent content to hold the tree and eat its dividend, which gives the Euler equation .. math:: P_t = E_t\left[\beta \left(\frac{C_{t+1}}{C_t}\right)^{-\gamma} (P_{t+1} + D_{t+1})\right], \qquad C = D. With i.i.d. lognormal growth the price-dividend ratio is constant, so the price inherits the dividend's random walk. The riskless rate and the equity premium follow from just :math:`\beta`, :math:`\gamma` and the mean and volatility of consumption growth. .. GENERATED FROM PYTHON SOURCE LINES 21-41 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.asset_pricing import LucasTree tree = LucasTree(beta=0.97, gamma=2.0, mu=0.02, sigma=0.036) m = tree.moments() print(f"P/D = {m.price_dividend:.1f}, R_f = {m.risk_free - 1:.2%}, E[R_e] = {m.equity_return - 1:.2%}, premium = {m.equity_premium:.2%}") path = tree.simulate(100, rng=1978) D = np.cumprod(np.concatenate([[1.0], path.growth])) fig, ax = plt.subplots(figsize=(8, 3.5)) ax.semilogy(D * m.price_dividend, label="price P_t") ax.semilogy(D, "C3", lw=1, label="dividend D_t") ax.set_xlabel("year") ax.set_ylabel("price") ax.set_title("the price is a constant multiple of the dividend") ax.legend() fig.tight_layout() .. image-sg:: /api/gallery/asset_pricing/consumption/images/sphx_glr_plot_01_lucas_tree_001.png :alt: the price is a constant multiple of the dividend :srcset: /api/gallery/asset_pricing/consumption/images/sphx_glr_plot_01_lucas_tree_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none P/D = 19.6, R_f = 7.02%, E[R_e] = 7.30%, premium = 0.28% .. GENERATED FROM PYTHON SOURCE LINES 42-48 Prices and returns across risk aversion --------------------------------------- Higher :math:`\gamma` raises the riskless rate (the agent wants to borrow against future growth) but adds only :math:`\gamma\sigma^2` to the log premium. .. GENERATED FROM PYTHON SOURCE LINES 48-62 .. code-block:: Python gammas = np.linspace(0.5, 10, 60) ms = [LucasTree(0.97, g, 0.02, 0.036).moments() for g in gammas] fig, axes = plt.subplots(1, 2, figsize=(10, 4)) axes[0].plot(gammas, [x.price_dividend for x in ms]) axes[0].set_xlabel("risk aversion gamma") axes[0].set_ylabel("price-dividend ratio") axes[1].plot(gammas, [x.risk_free - 1 for x in ms], label="riskless rate") axes[1].plot(gammas, [x.equity_premium for x in ms], label="equity premium") axes[1].set_xlabel("risk aversion gamma") axes[1].legend() fig.tight_layout() plt.show() .. image-sg:: /api/gallery/asset_pricing/consumption/images/sphx_glr_plot_01_lucas_tree_002.png :alt: plot 01 lucas tree :srcset: /api/gallery/asset_pricing/consumption/images/sphx_glr_plot_01_lucas_tree_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.181 seconds) .. _sphx_glr_download_api_gallery_asset_pricing_consumption_plot_01_lucas_tree.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/asset_pricing/consumption/plot_01_lucas_tree.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_lucas_tree.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_lucas_tree.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_lucas_tree.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_