{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Linear Regression: Rolling and Recursive\n", "\n", "**Functions**\n", "\n", "`sm.OLS`, `plt.title`, `plt.legend`, `plt.subplots`, `plt.plot`\n", "\n", "### Exercise 35\n", "For the same portfolios in the previous exercise, compute rolling $\\beta$s\n", "using 60 consecutive observations." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:33:53.629390Z", "iopub.status.busy": "2023-09-28T12:33:53.629390Z", "iopub.status.idle": "2023-09-28T12:33:56.100580Z", "shell.execute_reply": "2023-09-28T12:33:56.099572Z" } }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 36\n", "\n", "For each of the four $\\beta$s, produce a plot containing four series: \n", "\n", "* A line corresponding to the constant $\\beta$ (full sample) \n", "* The $\\beta$ estimated on the rolling sample \n", "* The constant $\\beta$ plus $1.96 \\times$ the variance of a 60-observation estimate of $\\beta$. \n", " The 60-month covariance can be estimated using a full sample VCV and rescaling it by T/60 \n", " where T is the length of the full sample used to estimate the VCV. Alternatively, the VCV\n", " could be estimated by first estimating the 60-month VCV for each sub-sample and then averaging\n", " these.\n", "* The constant $\\beta$ minus $1.96 \\times$ the variance of a 60-observation estimate of $\\beta$. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:33:59.010487Z", "iopub.status.busy": "2023-09-28T12:33:59.010487Z", "iopub.status.idle": "2023-09-28T12:34:06.378621Z", "shell.execute_reply": "2023-09-28T12:34:06.378621Z" } }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 37\n", "\n", "Do the factor exposures appear constant?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:34:06.382426Z", "iopub.status.busy": "2023-09-28T12:34:06.382426Z", "iopub.status.idle": "2023-09-28T12:34:06.387574Z", "shell.execute_reply": "2023-09-28T12:34:06.387574Z" } }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 38\n", "\n", "What happens if only the market is used as a factor (repeat the exercise excluding SMB and HML)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:34:06.390581Z", "iopub.status.busy": "2023-09-28T12:34:06.389582Z", "iopub.status.idle": "2023-09-28T12:34:09.306277Z", "shell.execute_reply": "2023-09-28T12:34:09.306277Z" } }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" }, "pycharm": { "stem_cell": { "cell_type": "raw", "metadata": { "collapsed": false }, "source": [] } } }, "nbformat": 4, "nbformat_minor": 4 }