This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Introduction to Expectation Maximization via Example" | |
] | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"nbformat_minor": 0, "cells": [{"source": "The following problem arises in the context of private equity, which typically \nreport 'smoothed' returns (think of it as a moving average). As you can imagine, \n'smoothed' returns would have a much lower volatility compared to the volatility \nof 'unsmoothed' returns. For risk calculation we are interested in volatility of \n'unsmoothed' returns.\n\nMathematically, suppose I observe a process $\\bar{r}_t$ which is a moving \naverage of process $r_t$, i.e., $\\bar{r}_t = \\sum_{k=0}^p w_k r_{t-k}$. I also \nknow that $r_t = \\alpha + \\beta r_{I, t} + \\epsilon_t$, where $r_{I, t}$ are \nreturns of a public index and $\\epsilon_t = N(0, \\sigma^2)$. I would like to \nestimate `unsmoothed' returns $r_t, t = 0, \\ldots, T$ from the data: \n$\\bar{r}_t, r_{I,t}, t=0, 1, \\ldots, T$.\n\nWe will view it as a state-space model:\n$$\n\\begin{split}\nz_t\n&=\nA_t z_{t-1} + B_t u_t + \\epsilon_t,\n\\\\\ny_t \n&=\nC_t z_t + D_t u_t + \\delta_t,\n\\\\\n\\epsilon_t &\\sim \\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"nbformat_minor": 0, "cells": [{"execution_count": 1, "cell_type": "code", "source": "import pandas as pd\nimport numpy as np\nimport pykalman as kf\nimport scipy as sp\n%pylab inline", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Populating the interactive namespace from numpy and matplotlib\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "### Convention", "cell_type": "markdown", "metadata": {}}, {"source": "$$\n\\begin{split}\nx_{t+1} \n&= \nAx_t + b_t + \\epsilon_t,\\ \\epsilon_t\\sim \\mathscr{N}(0, Q_t) \n\\\\\nz_t\n&=\nC_tx_t + d_t + \\delta_t,\\ \\delta_t\\sim\\mathscr{N}(0, R_t)\n\\end{split}\n$$", "cell_type": "markdown", "metadata": {}}, {"execution_count": 2, "cell_type": "code", "source": "n_obs, n_lat = 1, 2\nT = 1000", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 3, "cell_type": "code", "source": "x = np.zeros((T,n_lat))\nz = np.zeros((T,n_obs))", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Running following code: | |
clf = AdaBoostClassifier(n_estimators=100, base_estimator=KNeighborsClassifier()); clf.fit(x,y) | |
I get the following traceback: | |
TypeError Traceback (most recent call last) | |
/usr/local/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where) | |
176 else: |