Skip to content

DEPR: pandas.stats.var, pandas.stats.plm, pandas.stats.ols, pandas.stats.fama_macbeth #11898

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

Merged
merged 4 commits into from
Dec 26, 2015
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
4 changes: 3 additions & 1 deletion doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ Deprecations
For example, instead of ``s.rolling(window=5,freq='D').max()`` to get the max value on a rolling 5 Day window, one could use ``s.resample('D',how='max').rolling(window=5).max()``, which first resamples the data to daily data, then provides a rolling 5 day window.

- ``pd.tseries.frequencies.get_offset_name`` function is deprecated. Use offset's ``.freqstr`` property as alternative (:issue:`11192`)
- ``pandas.stats.fama_macbeth`` routines are deprecated and will be removed in a future version (:issue:`6077`)
- ``pandas.stats.ols``, ``pandas.stats.plm`` and ``pandas.stats.var`` routines are deprecated and will be removed in a future version (:issue:`6077`)

.. _whatsnew_0180.prior_deprecations:

Expand Down Expand Up @@ -346,4 +348,4 @@ Bug Fixes

- Bug in ``read_sql`` with pymysql connections failing to return chunked data (:issue:`11522`)

- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`)
- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`)
8 changes: 7 additions & 1 deletion pandas/stats/fama_macbeth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def fama_macbeth(**kwargs):

nw_lags_beta: int
Newey-West adjusts the betas by the given lags
"""
"""
window_type = kwargs.get('window_type')
if window_type is None:
klass = FamaMacBeth
Expand All @@ -32,6 +32,12 @@ def __init__(self, y, x, intercept=True, nw_lags=None,
nw_lags_beta=None,
entity_effects=False, time_effects=False, x_effects=None,
cluster=None, dropped_dummies=None, verbose=False):
import warnings
warnings.warn("The pandas.stats.fama_macbeth module is deprecated and will be "
"removed in a future version. We refer to external packages "
"like statsmodels, see here: http://statsmodels.sourceforge.net/stable/index.html",
FutureWarning, stacklevel=4)

if dropped_dummies is None:
dropped_dummies = {}
self._nw_lags_beta = nw_lags_beta
Expand Down
16 changes: 12 additions & 4 deletions pandas/stats/ols.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class OLS(StringMixin):

def __init__(self, y, x, intercept=True, weights=None, nw_lags=None,
nw_overlap=False):
import warnings
warnings.warn("The pandas.stats.ols module is deprecated and will be "
"removed in a future version. We refer to external packages "
"like statsmodels, see some examples here: http://statsmodels.sourceforge.net/stable/regression.html",
FutureWarning, stacklevel=4)

try:
import statsmodels.api as sm
except ImportError:
Expand Down Expand Up @@ -1197,8 +1203,11 @@ def _results(self):

@cache_readonly
def _window_time_obs(self):
window_obs = moments.rolling_sum(self._time_obs_count > 0,
self._window, min_periods=1)
window_obs = (Series(self._time_obs_count > 0)
.rolling(self._window, min_periods=1)
.sum()
.values
)

window_obs[np.isnan(window_obs)] = 0
return window_obs.astype(int)
Expand All @@ -1211,8 +1220,7 @@ def _nobs_raw(self):
# expanding case
window = len(self._index)

result = moments.rolling_sum(self._time_obs_count, window,
min_periods=1)
result = Series(self._time_obs_count).rolling(window, min_periods=1).sum().values

return result.astype(int)

Expand Down
11 changes: 11 additions & 0 deletions pandas/stats/plm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def __init__(self, y, x, weights=None, intercept=True, nw_lags=None,
entity_effects=False, time_effects=False, x_effects=None,
cluster=None, dropped_dummies=None, verbose=False,
nw_overlap=False):
import warnings
warnings.warn("The pandas.stats.plm module is deprecated and will be "
"removed in a future version. We refer to external packages "
"like statsmodels, see some examples here: http://statsmodels.sourceforge.net/stable/mixed_linear.html",
FutureWarning, stacklevel=4)
self._x_orig = x
self._y_orig = y
self._weights = weights
Expand Down Expand Up @@ -732,6 +737,12 @@ def __init__(self, y, x, window_type='full_sample', window=None,
min_periods=None, intercept=True, nw_lags=None,
nw_overlap=False):

import warnings
warnings.warn("The pandas.stats.plm module is deprecated and will be "
"removed in a future version. We refer to external packages "
"like statsmodels, see some examples here: http://statsmodels.sourceforge.net/stable/mixed_linear.html",
FutureWarning, stacklevel=4)

for attr in self.ATTRIBUTES:
setattr(self.__class__, attr, create_ols_attr(attr))

Expand Down
12 changes: 8 additions & 4 deletions pandas/stats/tests/test_fama_macbeth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pandas.compat import range
from pandas import compat
import pandas.util.testing as tm
import numpy as np


Expand All @@ -23,8 +24,9 @@ def testFamaMacBethRolling(self):
def checkFamaMacBethExtended(self, window_type, x, y, **kwds):
window = 25

result = fama_macbeth(y=y, x=x, window_type=window_type, window=window,
**kwds)
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
result = fama_macbeth(y=y, x=x, window_type=window_type, window=window,
**kwds)
self._check_stuff_works(result)

index = result._index
Expand All @@ -43,10 +45,12 @@ def checkFamaMacBethExtended(self, window_type, x, y, **kwds):
x2[k] = v.truncate(start, end)
y2 = y.truncate(start, end)

reference = fama_macbeth(y=y2, x=x2, **kwds)
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
reference = fama_macbeth(y=y2, x=x2, **kwds)
assert_almost_equal(reference._stats, result._stats[:, i])

static = fama_macbeth(y=y2, x=x2, **kwds)
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
static = fama_macbeth(y=y2, x=x2, **kwds)
self._check_stuff_works(static)

def _check_stuff_works(self, result):
Expand Down
3 changes: 2 additions & 1 deletion pandas/stats/tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def test_solve_rect(self):

b = Series(np.random.randn(N), self.frame.index)
result = pmath.solve(self.frame, b)
expected = ols(y=b, x=self.frame, intercept=False).beta
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
expected = ols(y=b, x=self.frame, intercept=False).beta
self.assertTrue(np.allclose(result, expected))

def test_inv_illformed(self):
Expand Down
Loading