Skip to content
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

OLS fitting fails if method='qr' and cov_type='HC0' are used at the same time #8157

Closed
borderite opened this issue Feb 28, 2022 · 1 comment · Fixed by #8161
Closed

OLS fitting fails if method='qr' and cov_type='HC0' are used at the same time #8157

borderite opened this issue Feb 28, 2022 · 1 comment · Fixed by #8161

Comments

@borderite
Copy link

borderite commented Feb 28, 2022

Describe the bug

In OLS regression, specifying method='qr' and cov_type='HC0' in the fit method results in an error. The error message is:

AttributeError: 'OLS' object has no attribute 'pinv_wexog'

Code Sample, a copy-pastable example if possible

import numpy as np
import statsmodels.api as sm


y = np.random.randn(100)

x = np.random.randn(100, 5)

res = sm.OLS(y, x, missing='drop').fit(method='qr', cov_type='HC0')

If the issue has not been resolved, please file it in the issue tracker.

Expected Output

The above-mentioned error does not occur.

Output of import statsmodels.api as sm; sm.show_versions()

INSTALLED VERSIONS

Python: 3.9.2.final.0
OS: Linux 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64
byteorder: little
LC_ALL: None
LANG: en_US.utf8

statsmodels

Installed: 0.12.2 (/usr/lib/python3/dist-packages/statsmodels)

Required Dependencies

cython: 0.29.21 (/usr/lib/python3/dist-packages/Cython)
numpy: 1.19.5 (/usr/lib/python3/dist-packages/numpy)
scipy: 1.6.0 (/usr/lib/python3/dist-packages/scipy)
pandas: 1.1.5 (/usr/lib/python3/dist-packages/pandas)
dateutil: 2.8.1 (/usr/lib/python3/dist-packages/dateutil)
patsy: 0.5.1 (/usr/lib/python3/dist-packages/patsy)

Optional Dependencies

matplotlib: 3.3.4 (/usr/lib/python3/dist-packages/matplotlib)
backend: TkAgg
cvxopt: 1.2.5 (/usr/lib/python3/dist-packages/cvxopt)Note: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.

Note: Please be sure you are using the latest released version of statsmodels, or a recent build of main. If your problem has been fixed in an unreleased version, you might be able to use main until a new release occurs.

Note: If you are using a released version, have you verified that the bug exists in the main branch of this repository? It helps the limited resources if we know problems exist in the current main branch so that they do not need to check whether the code sample produces a bug in the next release.

joblib: 0.17.0 (/usr/lib/python3/dist-packages/joblib)

Developer Tools

IPython: 7.20.0 (/usr/lib/python3/dist-packages/IPython)
jinja2: 2.11.3 (/usr/lib/python3/dist-packages/jinja2)
sphinx: Not installed
pygments: 2.7.1 (/usr/lib/python3/dist-packages/pygments)
pytest: 6.0.2 (/usr/lib/python3/dist-packages/pytest)
virtualenv: 20.4.0+ds (/usr/lib/python3/dist-packages/virtualenv)

bashtage added a commit to bashtage/statsmodels that referenced this issue Mar 1, 2022
Ensure pinv_wexog gets greated even when using QR

closes statsmodels#8157
@bashtage
Copy link
Member

bashtage commented Mar 1, 2022

Thanks for the report.

@bashtage bashtage modified the milestones: 0.13.2, 0.13.3 Oct 30, 2022
@bashtage bashtage modified the milestones: 0.13.3, 0.14 Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants