From 6e1d1c0ff645e3cde990187d26fc25d9742e17e1 Mon Sep 17 00:00:00 2001 From: thequackdaddy Date: Sun, 25 Feb 2018 18:57:43 -0600 Subject: [PATCH] Notebook shoudl probably use Gaussian distribution for GLM fit --- .../notebooks/distributed_estimation.ipynb | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/examples/notebooks/distributed_estimation.ipynb b/examples/notebooks/distributed_estimation.ipynb index 0a60f1f011c..89f1dc61ffd 100644 --- a/examples/notebooks/distributed_estimation.ipynb +++ b/examples/notebooks/distributed_estimation.ipynb @@ -9,13 +9,12 @@ }, { "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", + "from scipy.stats.distributions import norm\n", "from statsmodels.base.distributed_estimation import DistributedModel\n", "\n", "def _exog_gen(exog, partitions):\n", @@ -52,16 +51,14 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "X = np.random.normal(size=(1000, 25))\n", "beta = np.random.normal(size=25)\n", "beta *= np.random.randint(0, 2, size=25)\n", - "y = X.dot(beta) + np.random.normal(size=1000)\n", + "y = norm.rvs(loc=X.dot(beta))\n", "m = 5" ] }, @@ -74,10 +71,8 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "debiased_OLS_mod = DistributedModel(m)\n", @@ -94,17 +89,17 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { - "collapsed": false + "scrolled": false }, "outputs": [], "source": [ "from statsmodels.genmod.generalized_linear_model import GLM\n", - "from statsmodels.genmod.families import Binomial\n", + "from statsmodels.genmod.families import Gaussian\n", "\n", "debiased_GLM_mod = DistributedModel(m, model_class=GLM,\n", - " init_kwds={\"family\": Binomial()})\n", + " init_kwds={\"family\": Gaussian()})\n", "debiased_GLM_fit = debiased_GLM_mod.fit(zip(_endog_gen(y, m), _exog_gen(X, m)),\n", " fit_kwds={\"alpha\": 0.2})" ] @@ -118,10 +113,8 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": true - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "from statsmodels.base.distributed_estimation import _est_regularized_naive, _join_naive\n", @@ -142,10 +135,8 @@ }, { "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": true - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "from statsmodels.base.distributed_estimation import _est_unregularized_naive, DistributedResults\n", @@ -175,7 +166,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.10" + "version": "2.7.14" } }, "nbformat": 4,