{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Method of Moment Estimation\n", "\n", "**Functions**\n", "\n", "`DataFrame.mean`, `DatFrame.sum`, `plt.subplots`, `plt.plot`, `stats.kurtosis`, `stats.skewness`\n", "\n", "### Exercise 16\n", "Estimate the mean, variance, skewness and kurtosis of the S&P 500 and Hang Seng using\n", "the method of moments using monthly data." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:33:38.306623Z", "iopub.status.busy": "2023-09-28T12:33:38.305623Z", "iopub.status.idle": "2023-09-28T12:33:39.187514Z", "shell.execute_reply": "2023-09-28T12:33:39.187514Z" } }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 17\n", "Estimate the asymptotic covariance of the mean and variance of the two series (separately,\n", "but not the skewness and kurtosis). " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:33:39.212426Z", "iopub.status.busy": "2023-09-28T12:33:39.212426Z", "iopub.status.idle": "2023-09-28T12:33:39.236166Z", "shell.execute_reply": "2023-09-28T12:33:39.236166Z" } }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 18\n", "Estimate the Sharpe ratio of the two series and compute the asymptotic variance of\n", "the Sharpe ratio. See Chapter 2 of the notes for more on this problem.\n", "\n", "\n", "The asymptotic variance is computed as \n", "\n", "$$ D \\Sigma D^\\prime$$\n", "\n", "where\n", "\n", "$$ D = [\\sigma^{-1}, -1/2 \\mu \\sigma^{-3} ] $$\n", "\n", "and $\\Sigma$ is the asymptotic covariance of the mean and variance. Finally, we\n", "divide by $n$ the sample size when computing the statistic variance. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:33:39.247629Z", "iopub.status.busy": "2023-09-28T12:33:39.247629Z", "iopub.status.idle": "2023-09-28T12:33:39.262021Z", "shell.execute_reply": "2023-09-28T12:33:39.262021Z" } }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "### Exercise 19\n", "Plot rolling estimates of the four moments using 120 months of consecutive data using a\n", "4 by 1 subplot against the dates.\n", "\n", "The simple approach to this problem uses a loop across 120, 121, ..., $n$ and computes\n", "the statistics using 120 observations. The figure is then created with a call to `plt.subplots`\n", "and the series can be directly plotted by calling `ax.plot`.\n", "\n", "The pandas-centric approach uses teh `rolling` method to compute rolling statistics and\n", "then uses `.plot.line` with `subplots=True` to produce the plot." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2023-09-28T12:33:39.274389Z", "iopub.status.busy": "2023-09-28T12:33:39.274389Z", "iopub.status.idle": "2023-09-28T12:33:40.472308Z", "shell.execute_reply": "2023-09-28T12:33:40.472308Z" } }, "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 }