Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docs/source/generated
docs/source/dev/generated
docs/source/examples/generated
docs/source/examples/notebooks/generated
docs/source/datasets
docs/source/datasets/statsmodels.datasets.*
docs/gettingstarted_0.png
examples/executed

Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ html:
@echo "Generating datasets from installed statsmodels.datasets"
$(TOOLSPATH)$(DATASETBUILD)
@echo "Generating notebooks from examples/notebooks folder"
$(TOOLSPATH)$(NOTEBOOKBUILD) --parallel --report-errors
$(TOOLSPATH)$(NOTEBOOKBUILD) --parallel --report-errors --skip-existing
@echo "Running sphinx-build"
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo "Copying rendered example notebooks"
Expand Down
4 changes: 2 additions & 2 deletions docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ if "%1" == "html" (
REM python %TOOLSPATH%/%EXAMPLEBUILD%
echo mkdir %BUILDDIR%\html\_static
mkdir %BUILDDIR%\html\_static
echo python %TOOLSPATH%/%NOTEBOOKBUILD% --parallel --report-errors
REM python %TOOLSPATH%/%NOTEBOOKBUILD% --parallel --report-errors
echo python %TOOLSPATH%/%NOTEBOOKBUILD% --parallel --report-errors --skip-existing
python %TOOLSPATH%/%NOTEBOOKBUILD% --parallel --report-errors --skip-existing
echo python %TOOLSPATH%/%DATASETBUILD%
python %TOOLSPATH%/%DATASETBUILD%
echo %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contingency_tables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ methods and attributes.
data = sm.datasets.china_smoking.load()

mat = np.asarray(data.data)
tables = [np.reshape(x, (2, 2)) for x in mat]
tables = [np.reshape(x.tolist()[1:], (2, 2)) for x in mat]

st = sm.stats.StratifiedTable(tables)
print(st.summary())
Expand Down
4 changes: 2 additions & 2 deletions docs/source/contrasts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Example Data
.. ipython:: python

import pandas
url = 'http://www.ats.ucla.edu/stat/data/hsb2.csv'
hsb2 = pandas.read_table(url, delimiter=",")
url = 'https://stats.idre.ucla.edu/stat/data/hsb2.csv'
hsb2 = pandas.read_csv(url)

It will be instructive to look at the mean of the dependent variable, write, for each level of race ((1 = Hispanic, 2 = Asian, 3 = African American and 4 = Caucasian)).

Expand Down
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ Table of Contents
rlm
mixed_linear
discretemod
mixed_glm
anova
tsa
statespace
vector_ar
duration
stats
nonparametric
Expand All @@ -136,4 +138,3 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

22 changes: 22 additions & 0 deletions docs/source/mixed_glm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,25 @@ References

Blei, Kucukelbir, McAuliffe (2017). Variational Inference: A review
for Statisticians https://arxiv.org/pdf/1601.00670.pdf

Module Reference
----------------

.. module:: statsmodels.genmod.bayes_mixed_glm
:synopsis: Bayes Mixed Generalized Linear Models


The model classes are:

.. autosummary::
:toctree: generated/

BinomialBayesMixedGLM
PoissonBayesMixedGLM

The result class is:

.. autosummary::
:toctree: generated/

BayesMixedGLMResults
4 changes: 2 additions & 2 deletions docs/source/multivariate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ Factor Rotation
Canonical Correlation
---------------------

.. currentmodule:: statsmodels.multivariate.cancor
.. currentmodule:: statsmodels.multivariate.cancorr

.. autosummary::
:toctree: generated/

CanCor
CanCorr


MANOVA
Expand Down
2 changes: 1 addition & 1 deletion docs/source/plots/graphics-mean_diff_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
m2 = np.random.random(20)

f, ax = plt.subplots(1, figsize = (8,5))
sm.graphics.bland_altman_plot(m1, m2, ax = ax)
sm.graphics.mean_diff_plot(m1, m2, ax = ax)

plt.show()
1 change: 1 addition & 0 deletions docs/source/vector_ar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ explicitly:
matplotlib.style.use('ggplot')

.. ipython:: python
:okwarning:

# some example data
import numpy as np
Expand Down
4 changes: 3 additions & 1 deletion statsmodels/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from .regression.quantile_regression import QuantReg
from .regression.mixed_linear_model import MixedLM
from .genmod import api as genmod
from .genmod.api import GLM, GEE, OrdinalGEE, NominalGEE, families, cov_struct
from .genmod.api import (GLM, GEE, OrdinalGEE, NominalGEE, families,
cov_struct,
BinomialBayesMixedGLM, PoissonBayesMixedGLM)
from . import robust
from .robust.robust_linear_model import RLM
from .discrete.discrete_model import (Poisson, Logit, Probit,
Expand Down
4 changes: 2 additions & 2 deletions statsmodels/base/elastic_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def _opt_1d(func, grad, hess, model, start, L1_wt, tol,
"""
One-dimensional helper for elastic net.

Parameters:
-----------
Parameters
----------
func : function
A smooth function of a single variable to be optimized
with L1 penaty.
Expand Down
5 changes: 1 addition & 4 deletions statsmodels/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,6 @@ def t_test_pairwise(self, term_name, method='hs', alpha=0.05,

Notes
-----

Status: experimental. Currently only checked for treatment coding with
and without specified reference level.

Expand All @@ -1696,16 +1695,14 @@ def t_test_pairwise(self, term_name, method='hs', alpha=0.05,
>>> res = ols("np.log(Days+1) ~ C(Weight) + C(Duration)", data).fit()
>>> pw = res.t_test_pairwise("C(Weight)")
>>> pw.result_frame
coef std err t P>|t| Conf. Int. Low \
coef std err t P>|t| Conf. Int. Low
2-1 0.632315 0.230003 2.749157 8.028083e-03 0.171563
3-1 1.302555 0.230003 5.663201 5.331513e-07 0.841803
3-2 0.670240 0.230003 2.914044 5.119126e-03 0.209488

Conf. Int. Upp. pvalue-hs reject-hs
2-1 1.093067 0.010212 True
3-1 1.763307 0.000002 True
3-2 1.130992 0.010212 True

"""
res = t_test_pairwise(self, term_name, method=method, alpha=alpha,
factor_labels=factor_labels)
Expand Down
6 changes: 5 additions & 1 deletion statsmodels/datasets/statecrime/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,9 @@ def _get_data():
filepath = dirname(abspath(__file__))
##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
with open(filepath + '/statecrime.csv', 'rb') as f:
data = np.recfromtxt(f, delimiter=",", names=True, dtype=None)
try:
data = np.recfromtxt(f, delimiter=",", names=True,
dtype=None, encoding='utf-8')
except TypeError:
data = np.recfromtxt(f, delimiter=",", names=True, dtype=None)
return data
4 changes: 2 additions & 2 deletions statsmodels/duration/survfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ def survdiff(time, status, group, weight_type=None, strata=None,
"""
Test for the equality of two survival distributions.

Parameters:
-----------
Parameters
----------
time : array-like
The event or censoring times.
status : array-like
Expand Down
4 changes: 2 additions & 2 deletions statsmodels/genmod/bayes_mixed_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ def fit_vb(self, mean=None, sd=None, minim_opts=None, verbose=False):
"""
Fit a model using the variational Bayes mean field approximation.

Parameters:
-----------
Parameters
----------
mean : array-like
Starting value for VB mean vector
sd : array-like
Expand Down
9 changes: 5 additions & 4 deletions statsmodels/genmod/families/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,10 +1165,11 @@ class NegativeBinomial(Family):

Parameterization for :math:`y=0, 1, 2, \ldots` is

:math:`f(y) = \frac{\Gamma(y+\frac{1}{\alpha})}
{y!\Gamma(\frac{1}{\alpha})}
\left(\frac{1}{1+\alpha\mu}\right)^{\frac{1}{\alpha}}
\left(\frac{\alpha\mu}{1+\alpha\mu}\right)^y`
.. math::

f(y) = \frac{\Gamma(y+\frac{1}{\alpha})}{y!\Gamma(\frac{1}{\alpha})}
\left(\frac{1}{1+\alpha\mu}\right)^{\frac{1}{\alpha}}
\left(\frac{\alpha\mu}{1+\alpha\mu}\right)^y

with :math:`E[Y]=\mu\,` and :math:`Var[Y]=\mu+\alpha\mu^2`.
"""
Expand Down
12 changes: 5 additions & 7 deletions statsmodels/graphics/agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import numpy as np
from . import utils

def mean_diff_plot(m1, m2,
sd_limit=1.96,
ax=None,
scatter_kwds=None,
mean_line_kwds=None,
limit_lines_kwds=None):
def mean_diff_plot(m1, m2, sd_limit=1.96, ax=None, scatter_kwds=None,
mean_line_kwds=None, limit_lines_kwds=None):
"""
Tukey's Mean Difference Plot.

Expand All @@ -32,7 +28,9 @@ def mean_diff_plot(m1, m2,
the differences. If `md` is the mean of the differences, and `sd` is
the standard deviation of those differences, then the limits of
agreement that will be plotted will be

md - sd_limit * sd, md + sd_limit * sd

The default of 1.96 will produce 95% confidence intervals for the means
of the differences.
If sd_limit = 0, no limits will be plotted, and the ylimit of the plot
Expand Down Expand Up @@ -78,7 +76,7 @@ def mean_diff_plot(m1, m2,
>>> m1 = np.random.random(20)
>>> m2 = np.random.random(20)
>>> f, ax = plt.subplots(1, figsize = (8,5))
>>> sm.graphics.bland_altman_plot(m1, m2, ax = ax)
>>> sm.graphics.mean_diff_plot(m1, m2, ax = ax)
>>> plt.show()

.. plot:: plots/graphics-mean_diff_plot.py
Expand Down
8 changes: 4 additions & 4 deletions statsmodels/imputation/bayes_mi.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ class MI(object):
"""
MI performs multiple imputation using a provided imputer object.

Parameters:
-----------
Parameters
----------
imp : object
An imputer class, such as BayesGaussMI.
model : model class
Expand Down Expand Up @@ -318,8 +318,8 @@ class MIResults(LikelihoodModelResults):
"""
A results class for multiple imputation (MI).

Parameters:
-----------
Parameters
----------
mi : MI instance
The MI object that produced the results
model : instance of statsmodels model class
Expand Down
2 changes: 2 additions & 0 deletions statsmodels/multivariate/cancorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ class CanCorr(Model):

For matrices exog=x and endog=y, find projections x_cancoef and y_cancoef
such that:

x1 = x * x_cancoef, x1' * x1 is identity matrix
y1 = y * y_cancoef, y1' * y1 is identity matrix

and the correlation between x1 and y1 is maximized.

Attributes
Expand Down
Loading