.. 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_02_breeden_ccapm.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_02_breeden_ccapm.py: Breeden's consumption CAPM ========================== Merton's intertemporal CAPM needs a beta for every state variable that shifts investment opportunities. Douglas Breeden (1979) showed that they all collapse into one: since optimal consumption already responds to every state variable, an asset's risk premium is proportional to its covariance with aggregate consumption growth, .. math:: E[R_i] - R_f \approx \gamma\,\mathrm{Cov}(R_i, \Delta c) = \gamma\,\beta_{i,c}\,\sigma_c^2. Assets that pay off when consumption is low are insurance and earn less. .. GENERATED FROM PYTHON SOURCE LINES 20-49 .. image-sg:: /api/gallery/asset_pricing/consumption/images/sphx_glr_plot_02_breeden_ccapm_001.png :alt: plot 02 breeden ccapm :srcset: /api/gallery/asset_pricing/consumption/images/sphx_glr_plot_02_breeden_ccapm_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none price of consumption risk: 0.00242 (true gamma sigma_c^2 = 0.00300) implied gamma: 24.2 | .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.asset_pricing import ccapm_expected_excess_return, estimate_beta rng = np.random.default_rng(1979) T, N, gamma, sigma_c = 400, 25, 30.0, 0.01 # quarterly data dc = 0.005 + sigma_c * rng.standard_normal(T) beta_c = np.linspace(-1.0, 5.0, N) premia = ccapm_expected_excess_return(beta_c, sigma_c, gamma) R = premia + np.outer(dc - dc.mean(), beta_c) + 0.06 * rng.standard_normal((T, N)) b_hat = estimate_beta(R, dc) slope, intercept = np.polyfit(b_hat, R.mean(axis=0), 1) print(f"price of consumption risk: {slope:.5f} (true gamma sigma_c^2 = {gamma * sigma_c**2:.5f})") print(f"implied gamma: {slope / sigma_c**2:.1f}") fig, ax = plt.subplots(figsize=(7, 4)) ax.plot(b_hat, R.mean(axis=0), "o", label="assets") bb = np.linspace(b_hat.min(), b_hat.max(), 2) ax.plot(bb, intercept + slope * bb, "C3", label="cross-sectional fit") ax.plot(bb, ccapm_expected_excess_return(bb, sigma_c, gamma), "k:", label="CCAPM") ax.axvline(0, color="0.6", lw=0.8) ax.set_xlabel("consumption beta") ax.set_ylabel("average excess return per quarter") ax.legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.040 seconds) .. _sphx_glr_download_api_gallery_asset_pricing_consumption_plot_02_breeden_ccapm.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_02_breeden_ccapm.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_breeden_ccapm.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_breeden_ccapm.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_breeden_ccapm.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_