-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when trying to use an exposure term or offset term with statsmodels.discrete.count_model.Poisson
#7015
Comments
thanks for a compete example that can be run. looks like exposure is missing an Using numpy array for exposure I get a ConvergenceWarning, but the summary says converged. The ConvergenceWarning is likely from an initial model estimate to get better start_params and not the final model. |
Thanks for the quick response! Presumably a line could be added to the docs that a pandas series does not count as an "array-like" in this case. Although would make even more sense to add code to handle a series in the same way that the I only tested these two model types but I would guess that it also applies to other discrete and count models such as NegativeBinomial. |
It's actually pretty obvious from the traceback, knowing statsmodels internals. GLM has an asarray for maybe in the old times, np.log of a pandas Series returned an ndarray. obviously no unit tests for pandas exposure I think the easiest is to use |
If we release a 0.12.1, then fixing this would be a backport candidate. |
Describe the bug
Error when trying to use an exposure term or offset term with
statsmodels.discrete.count_model.Poisson
andstatsmodels.discrete.count_model.ZeroInflatedPoisson
.Traceback
Fitting a Poisson model with an exposure or offset term works if done through the formula API but trying to do so using the non-fomrula API gives the error above. This is especialyl a problem when the model is not accessible with the formula API e.g.
statsmodels.discrete.count_model.ZeroInflatedPoisson
.Output of
import statsmodels.api as sm; sm.show_versions()
INSTALLED VERSIONS
Python: 3.6.7.final.0
OS: Linux 5.8.0-1-default #1 SMP Tue Aug 4 07:30:59 UTC 2020 (9bc0044) x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
statsmodels
Installed: 0.12.0 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/statsmodels)
Required Dependencies
cython: Not installed
numpy: 1.19.1 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/numpy)
scipy: 1.5.2 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/scipy)
pandas: 1.1.1 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/pandas)
dateutil: 2.8.1 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/dateutil)
patsy: 0.5.1 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/patsy)
Optional Dependencies
matplotlib: 3.3.1 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/matplotlib)
backend: module://ipykernel.pylab.backend_inline
cvxopt: Not installed
joblib: Not installed
Developer Tools
IPython: 7.11.1 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/IPython)
jinja2: Not installed
sphinx: Not installed
pygments: 2.6.1 (/home/ilya/miniconda3/envs/stdsci/lib/python3.6/site-packages/pygments)
pytest: Not installed
virtualenv: Not installed
The text was updated successfully, but these errors were encountered: