Skip to content

BUG: OLS with clustering and nw_lags does not error #8360

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

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions doc/source/v0.15.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -940,3 +940,6 @@ Bug Fixes
- Bug where ``col_space`` was ignored in ``DataFrame.to_string()`` when ``header=False`` (:issue:`8230`).

- Bug in DataFrame terminal display: Setting max_column/max_rows to zero did not trigger auto-resizing of dfs to fit terminal width/height (:issue:`7180`).
- Bug in OLS where running with "cluster" and "nw_lags" parameters did not work correctly, but also did not throw an error
(:issue:`5884', :issue:`8360`).

8 changes: 8 additions & 0 deletions pandas/stats/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def ols(**kwargs):
The appropriate OLS object, which allows you to obtain betas and various
statistics, such as std err, t-stat, etc.
"""

if (kwargs.get('cluster') is not None and
kwargs.get('nw_lags') is not None):
raise ValueError(
'Pandas OLS does not work with Newey-West correction '
'and clustering.')


pool = kwargs.get('pool')
if 'pool' in kwargs:
del kwargs['pool']
Expand Down
12 changes: 7 additions & 5 deletions pandas/stats/tests/test_ols.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,13 +682,15 @@ def testRollingWithTimeCluster(self):
cluster='time')

def testRollingWithNeweyWestAndEntityCluster(self):
self.checkMovingOLS(self.panel_x, self.panel_y,
nw_lags=1, cluster='entity')
self.assertRaises(ValueError, self.checkMovingOLS,
self.panel_x, self.panel_y,
nw_lags=1, cluster='entity')

def testRollingWithNeweyWestAndTimeEffectsAndEntityCluster(self):
self.checkMovingOLS(self.panel_x, self.panel_y,
nw_lags=1, cluster='entity',
time_effects=True)
self.assertRaises(ValueError,
self.checkMovingOLS, self.panel_x, self.panel_y,
nw_lags=1, cluster='entity',
time_effects=True)

def testExpanding(self):
self.checkMovingOLS(
Expand Down