{{ message }}

Instantly share code, notes, and snippets.

# AustinRochford/gist:92b06d174a7f84fded6e

Created Mar 4, 2015
Maximum Likelihood Estimation in Python with StatsModels
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": "%matplotlib inline", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"source": "---\ntitle: Maximum Likelihood Estimation of Custom Models in Python with StatsModels\ntags: Statistics, Python\n---", "cell_type": "markdown", "metadata": {}}, {"source": "Maximum likelihood estimation is a common method for fitting statistical models. In Python, it is quite possible to fit maximum likelihood models using just [scipy.optimize](http://docs.scipy.org/doc/scipy/reference/optimize.html). Over time, however, I have come to prefer the convenience provided by [statsmodels'](http://statsmodels.sourceforge.net/) [GenericLikelihoodModel](http://statsmodels.sourceforge.net/devel/dev/generated/statsmodels.base.model.GenericLikelihoodModel.html). In this post, I will show how easy it is to subclass GenericLikelihoodModel and take advantage of much of statsmodels' well-developed machinery for maximum likelihood estimation of custom models.", "cell_type": "markdown", "metadata": {}}, {"source": "#### Zero-inflated Poisson models", "cell_type": "markdown", "metadata": {}}, {"source": "The model we use for this demonstration is a [zero-inflated Poisson model](http://en.wikipedia.org/wiki/Zero-inflated_model#Zero-inflated_Poisson). This is a model for count data that generalizes the Poisson model by allowing for an overabundance of zero observations.\n\nThe model has two parameters, $\\pi$, the proportion of excess zero observations, and $\\lambda$, the mean of the Poisson distribution. We assume that observations from this model are generated as follows. First, a weighted coin with probability $\\pi$ of landing on heads is flipped. If the result is heads, the observation is zero. If the result is tails, the observation is generated from a Poisson distribution with mean $\\lambda$. Note that there are two ways for an observation to be zero under this model:\n\n1. the coin is heads, and\n2. the coin is tails, and the sample from the Poisson distribution is zero.\n\nIf $X$ has a zero-inflated Poisson distribution with parameters $\\pi$ and $\\lambda$, its probability mass function is given by\n\n\\begin{align*}\nP(X = 0)\n & = \\pi + (1 - \\pi)\\ e^{-\\lambda} \\\\\nP(X = x)\n & = (1 - \\pi)\\ e^{-\\lambda}\\ \\frac{\\lambda^x}{x!} \\textrm{ for } x > 0.\n\\end{align*}\n\nIn this post, we will use the parameter values $\\pi = 0.3$ and $\\lambda = 2$. The probability mass function of the zero-inflated Poisson distribution is shown below, next to a normal Poisson distribution, for comparison.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 2, "cell_type": "code", "source": "from __future__ import division\n\nfrom matplotlib import pyplot as plt\nimport numpy as np\nfrom scipy import stats\nimport seaborn as sns\nfrom statsmodels.base.model import GenericLikelihoodModel", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 3, "cell_type": "code", "source": "np.random.seed(123456789)", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 4, "cell_type": "code", "source": "pi = 0.3\nlambda_ = 2.", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 5, "cell_type": "code", "source": "def zip_pmf(x, pi=pi, lambda_=lambda_):\n if pi < 0 or pi > 1 or lambda_ <= 0:\n return np.zeros_like(x)\n else:\n return (x == 0) * pi + (1 - pi) * stats.poisson.pmf(x, lambda_)", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 6, "cell_type": "code", "source": "fig, ax = plt.subplots(figsize=(8, 6))\n\nxs = np.arange(0, 10);\n\npalette = sns.color_palette()\n\nax.bar(2.5 * xs, stats.poisson.pmf(xs, lambda_), width=0.9, color=palette[0], label='Poisson');\nax.bar(2.5 * xs + 1, zip_pmf(xs), width=0.9, color=palette[1], label='Zero-inflated Poisson');\n\nax.set_xticks(2.5 * xs + 1);\nax.set_xticklabels(xs);\nax.set_xlabel('$x$');\n\nax.set_ylabel('$P(X = x)$');\n\nax.legend();", "outputs": [{"output_type": "display_data", "data": {"image/png": "iVBORw0KGgoAAAANSUhEUgAAAf0AAAGCCAYAAADquBqcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\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7fh+YERH/F/hH4MSI+ErBmfqVmc9Wf3ZSOdY8nI/rL6XyBcmfVJ9/ncqHgGZwKvAf\n1fd5uHsz8IPMfKF6ldZ7qfz9HrYy8/bMfHNmHg+8CGRRWSz9/nm9/yEWES3AbcDTmXlD0XlqERF7\nVr+pTUSMBk6m8gl+WMrMP8/M9sx8A5XduN/JzLOKzrU9EdEaEeOqj8cAp1D5pvawlJnPAR0R8d+q\nk04CfllgpB0xk8qHwWbwK+AtETG6+m/HSVS+nDpsRcSk6s/XA39IgYdRPKbfj8zcEBGbr/c/Arht\nuF/vPyL+kcpdCfeIiA7gysy8o+BY23M0ldNvfh4Rm4vzk5n5LwVm6s/ewJ3V4/q7AF/NzG8XnGlH\nNMNhq72A+ypnlTESuCszHy42Ur8+DNxV3UBYBJxTcJ5+VT9QnUTlG/HDXmY+Wd1LNY/KbvKfAl8q\nNlW/vh4Re1D5AuIHM/OlooJ47X1JkkrC3fuSJJWEpS9JUklY+pIklYSlL0lSSVj6kiSVhKUvSVJJ\nWPqSJJWEpS9JUklY+pIklYSX4ZVUdxHxHir3Od8fWAIcnJmXFhpKkqUvqb4i4k3Ao1T2JN4O/A3w\n60JDSQK89r6kIVLd2p/cLHdOlMrA0pdUVxFxGPAS8HHgDip3QTsqM/+t0GCS3L0vqe5OAdYAC4Ej\ngQOA/1NoIkmAW/qSJJWGp+xJklQSlr4kSSVh6UuSVBKWviRJJWHpS5JUEpa+JEklYelLklQSlr4k\nSSXx/wEKf0WcLgB7iwAAAABJRU5ErkJggg==\n", "text/plain": ""}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "#### Maximum likelihood estimation", "cell_type": "markdown", "metadata": {}}, {"source": "First we generate 1,000 observations from the zero-inflated model.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 7, "cell_type": "code", "source": "N = 1000", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 8, "cell_type": "code", "source": "inflated_zero = stats.bernoulli.rvs(pi, size=N)\nx = (1 - inflated_zero) * stats.poisson.rvs(lambda_, size=N)", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 9, "cell_type": "code", "source": "fig, ax = plt.subplots(figsize=(8, 6))\n\nax.hist(x, width=0.8, bins=np.arange(x.max() + 1), normed=True);\n\nax.set_xticks(np.arange(x.max() + 1) + 0.4);\nax.set_xticklabels(np.arange(x.max() + 1));\nax.set_xlabel('$x$');\n\nax.set_ylabel('Proportion of samples');", "outputs": [{"output_type": "display_data", "data": {"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfoAAAGCCAYAAAAIZAHlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+0XWdd5/F3cq9B0oTSwq2FcCVY4teWnykSGEuxZWon\ntdK6xuWEDIgglIAtVEdbZRwdQWc0INpCFxja0hFEUsUWAzb2B3RY4YeVDC2gDd8xdlJv0kKvTUyT\nVkzuj/ljn9TTy7337Jt7ds49T96vtbJy9j7Ps8/3Wf3xOc/+8ZxFk5OTSJKkMi3udQGSJKk5Br0k\nSQUz6CVJKphBL0lSwQx6SZIKZtBLklSwwSYPHhFrgauAAeC6zNw4Q7uXAl8G1mXmn7f27QIeAcaB\nw5m5pslaJUkqUWNBHxEDwDXAecAe4CsRsSUzd0zTbiPwV1MOMQmck5l7m6pRkqTSNXnqfg2wMzN3\nZeZhYDNw8TTt3g58Ehid5r1FDdYnSVLxmgz6FcBI2/bu1r7HRcQKqvD/UGtX+zJ9k8AdEbE9Ii5p\nsE5JkorVZNDXWVv3KuBXM3OSavbePoM/KzNXAxcAl0bE2Q3UKElS0Zq8GW8PMNy2PUw1q2/3EmBz\nRAA8HbggIg5n5pbMfBAgM0cj4maqSwHbZvqwsbHxycHBgW7WL0nSQtfxEneTQb8dWBURK4EHgHXA\n+vYGmfkDR15HxA3ApzNzS0QsBQYy80BEnACcD7xrtg/bt++xLpcPQ0PLGR090PXj9lqJ43JM/cEx\n9QfH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Df\n97QoSd/Fte4lzUtrVr+ipF8QlEpi0Es6KhHxIuAR4FeAG4CvAi/LzC/0tDBJT+Cpe0lH63zgMWAn\nsAZ4LvCnPa1I0ndxRi9JUsF8vE6SpIIZ9JIkFcyglySpYAa9JEkFM+glSSqYQS9JUsEMekmSCmbQ\nS5JUsP8PSe13gWnlsaUAAAAASUVORK5CYII=\n", "text/plain": ""}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "We are now ready to estimate $\\pi$ and $\\lambda$ by maximum likelihood. To do so, we define a class that inherits from statsmodels' GenericLikelihoodModel as follows.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 10, "cell_type": "code", "source": "class ZeroInflatedPoisson(GenericLikelihoodModel):\n def __init__(self, endog, exog=None, **kwds):\n if exog is None:\n exog = np.zeros_like(endog)\n \n super(ZeroInflatedPoisson, self).__init__(endog, exog, **kwds)\n \n def nloglikeobs(self, params):\n pi = params[0]\n lambda_ = params[1]\n\n return -np.log(zip_pmf(self.endog, pi=pi, lambda_=lambda_))\n \n def fit(self, start_params=None, maxiter=10000, maxfun=5000, **kwds):\n if start_params is None:\n lambda_start = self.endog.mean()\n excess_zeros = (self.endog == 0).mean() - stats.poisson.pmf(0, lambda_start)\n \n start_params = np.array([excess_zeros, lambda_start])\n \n return super(ZeroInflatedPoisson, self).fit(start_params=start_params,\n maxiter=maxiter, maxfun=maxfun, **kwds)", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"source": "The key component of this class is the method nloglikeobs, which returns the negative log likelihood of each observed value in endog. Secondarily, we must also supply reasonable initial guesses of the parameters in fit. Obtaining the maximum likelihood estimate is now simple.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 11, "cell_type": "code", "source": "model = ZeroInflatedPoisson(x)\nresults = model.fit()", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Optimization terminated successfully.\n Current function value: 1.586641\n Iterations: 37\n Function evaluations: 70\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "We see that we have estimated the parameters fairly well.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 12, "cell_type": "code", "source": "pi_mle, lambda_mle = results.params\n\npi_mle, lambda_mle", "outputs": [{"execution_count": 12, "output_type": "execute_result", "data": {"text/plain": "(0.31542487710071976, 2.0451304204850853)"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "There are many advantages to buying into the statsmodels ecosystem and subclassing GenericLikelihoodModel. The already-written statsmodels code handles storing the observations and the interaction with scipy.optimize for us. (It is possible to control the use of scipy.optimize through keyword arguments to fit.)\n\nWe also gain access to many of statsmodels' built in model analysis tools. For example, we can use bootstrap resampling to estimate the variation in our parameter estimates.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "boot_mean, boot_std, boot_samples = results.bootstrap(nrep=500, store=True)\nboot_pis = boot_samples[:, 0]\nboot_lambdas = boot_samples[:, 1]", "outputs": [{"output_type": "stream", "name": "stdout", "text": "\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 14, "cell_type": "code", "source": "fig, (pi_ax, lambda_ax) = plt.subplots(ncols=2, figsize=(16, 6))\n\nsns.boxplot(boot_pis, ax=pi_ax, names=['$\\pi$'], color=palette[0]);\nsns.boxplot(boot_lambdas, ax=lambda_ax, names=['$\\lambda$'], color=palette[1]);\n\nfig.suptitle('Boostrap distribution of maximum likelihood estimates');", "outputs": [{"output_type": "display_data", "data": {"image/png": "iVBORw0KGgoAAAANSUhEUgAAA6cAAAGSCAYAAAAfNLdHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucXWWd5/tPWVUqRUKITXmDwihN/wQaMKiBY7g6DCfi\nBUeYgSDSiDIMLQ7tdKPd9EFtOa+2g+Mx0MxBIkg3gmDLbXCaNMo4QriIRMJFib+eCIEQRAtMQkIJ\nVJKaP9Yq3BRVtStJJU921ef9euVVez3rWWv/9qWy67uftZ7VNjAwgCRJkiRJJb2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zF8CjwJR\nL/+q/tkL3EB1Co8kScU1C6eLgT0jYkZEvBo4HripsUNE7A5cD5yUmcsG2zPznMzsycy3AicAP8zM\nk8e3fEmSNIxfAEcCRMQbqILpIxHRFRFT6/YdgaOAh4pVKUlSg1EP683M9RFxJnAL1aVkLsvMpRFx\ner3+EuDzwHTg4oiAkaeld7ZeSZLGQURcDRwG7BIRK4AvAJ3w0mfz3wKXR8QDVF9EfzYzfxsRbwOu\nrz+vO4CrMvP7JR6DJElDtQ0MmBklSZIkSWU1O6xXkiRJkqStznAqSZIkSSrOcCpJkiRJKs5wKkmS\nJEkqznAqSZIkSSrOcCpJkiRtpoiYHhHfjojXla5FanVeSkZqERGxK/AVYE9gA/AMcFN9TUNJklRI\nRHwSeFVmLihdi9TKOkoXIGnM3pKZJ0bEicBAZl5duiBJkgTA94BvAoZTaQt4WK/UIjLzrogIYA3Q\nXboeSZJUycxfAztGxE6la5FameFUai0fBe4C9ogIj3yQJGk7EBGvBdYB7y9di9TKDKdSa+nJzFXA\nb4A9ShcjSdJkFxHtwBeBc4EPl61Gam1OiCRJkiRtpoiYD3wjM38eEXcDh2Xmi6XrklqRI6eSJEnS\nZoiI44CfZubP66b/ARxdsCSppTlyKkmSJEkqzpFTSZIkSVJxhlNJkiRJUnGGU0mSJElScYZTSZIk\nSVJxhlNJkiRJUnGGU0mSJElScYZTSZIkSVJx/wcVS32yEo37SgAAAABJRU5ErkJggg==\n", "text/plain": ""}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "The next time you are fitting a model using maximum likelihood, try integrating with statsmodels to take advantage of the significant amount of work that has gone into its ecosystem.", "cell_type": "markdown", "metadata": {}}, {"execution_count": null, "cell_type": "code", "source": "", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.6", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}}

### jeffjose commented Mar 30, 2017

This looks like a jupyter notebook.