Skip to content

Commit

Permalink
Notebook shoudl probably use Gaussian distribution for GLM fit
Browse files Browse the repository at this point in the history
  • Loading branch information
thequackdaddy committed Feb 26, 2018
1 parent 1b386fc commit 6e1d1c0
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions examples/notebooks/distributed_estimation.ipynb
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
]
},
Expand All @@ -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",
Expand All @@ -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})"
]
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -175,7 +166,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.14"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 6e1d1c0

Please sign in to comment.