diff --git a/doc/source/whatsnew/v0.18.0.txt b/doc/source/whatsnew/v0.18.0.txt index f9bb37359235c..b443bb74e98ea 100644 --- a/doc/source/whatsnew/v0.18.0.txt +++ b/doc/source/whatsnew/v0.18.0.txt @@ -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: @@ -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`) \ No newline at end of file +- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`) diff --git a/pandas/stats/fama_macbeth.py b/pandas/stats/fama_macbeth.py index 30726d82e1aa9..01e68be273226 100644 --- a/pandas/stats/fama_macbeth.py +++ b/pandas/stats/fama_macbeth.py @@ -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 @@ -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 diff --git a/pandas/stats/ols.py b/pandas/stats/ols.py index d1d74442d8961..7031d55c0f682 100644 --- a/pandas/stats/ols.py +++ b/pandas/stats/ols.py @@ -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: @@ -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) @@ -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) diff --git a/pandas/stats/plm.py b/pandas/stats/plm.py index 53b8cce64b74a..177452476b875 100644 --- a/pandas/stats/plm.py +++ b/pandas/stats/plm.py @@ -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 @@ -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)) diff --git a/pandas/stats/tests/test_fama_macbeth.py b/pandas/stats/tests/test_fama_macbeth.py index dd2f196361226..05849bd80c7a8 100644 --- a/pandas/stats/tests/test_fama_macbeth.py +++ b/pandas/stats/tests/test_fama_macbeth.py @@ -4,6 +4,7 @@ from pandas.compat import range from pandas import compat +import pandas.util.testing as tm import numpy as np @@ -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 @@ -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): diff --git a/pandas/stats/tests/test_math.py b/pandas/stats/tests/test_math.py index 1d1288e126418..628a37006cfeb 100644 --- a/pandas/stats/tests/test_math.py +++ b/pandas/stats/tests/test_math.py @@ -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): diff --git a/pandas/stats/tests/test_ols.py b/pandas/stats/tests/test_ols.py index 60e976f09365b..01095ab2336ce 100644 --- a/pandas/stats/tests/test_ols.py +++ b/pandas/stats/tests/test_ols.py @@ -115,7 +115,8 @@ def testWLS(self): self._check_wls(X, Y, weights) def _check_wls(self, x, y, weights): - result = ols(y=y, x=x, weights=1 / weights) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=y, x=x, weights=1 / weights) combined = x.copy() combined['__y__'] = y @@ -153,10 +154,12 @@ def checkDataSet(self, dataset, start=None, end=None, skip_moving=False): def checkOLS(self, exog, endog, x, y): reference = sm.OLS(endog, sm.add_constant(exog, prepend=False)).fit() - result = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=y, x=x) # check that sparse version is the same - sparse_result = ols(y=y.to_sparse(), x=x.to_sparse()) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + sparse_result = ols(y=y.to_sparse(), x=x.to_sparse()) _compare_ols_results(result, sparse_result) assert_almost_equal(reference.params, result._beta_raw) @@ -175,16 +178,18 @@ def checkOLS(self, exog, endog, x, y): _check_non_raw_results(result) def checkMovingOLS(self, window_type, x, y, weights=None, **kwds): - window = sm.tools.tools.rank(x.values) * 2 + window = np.linalg.matrix_rank(x.values) * 2 - moving = ols(y=y, x=x, weights=weights, window_type=window_type, - window=window, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + moving = ols(y=y, x=x, weights=weights, window_type=window_type, + window=window, **kwds) # check that sparse version is the same - sparse_moving = ols(y=y.to_sparse(), x=x.to_sparse(), - weights=weights, - window_type=window_type, - window=window, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + sparse_moving = ols(y=y.to_sparse(), x=x.to_sparse(), + weights=weights, + window_type=window_type, + window=window, **kwds) _compare_ols_results(moving, sparse_moving) index = moving._index @@ -202,7 +207,8 @@ def checkMovingOLS(self, window_type, x, y, weights=None, **kwds): x_iter[k] = v.truncate(before=prior_date, after=date) y_iter = y.truncate(before=prior_date, after=date) - static = ols(y=y_iter, x=x_iter, weights=weights, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + static = ols(y=y_iter, x=x_iter, weights=weights, **kwds) self.compare(static, moving, event_index=i, result_index=n) @@ -248,7 +254,8 @@ def compare(self, static, moving, event_index=None, def test_ols_object_dtype(self): df = DataFrame(np.random.randn(20, 2), dtype=object) - model = ols(y=df[0], x=df[1]) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=df[0], x=df[1]) summary = repr(model) @@ -269,7 +276,8 @@ def test_f_test(self): x = tm.makeTimeDataFrame() y = x.pop('A') - model = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x) hyp = '1*B+1*C+1*D=0' result = model.f_test(hyp) @@ -289,8 +297,10 @@ def test_r2_no_intercept(self): x_with = x.copy() x_with['intercept'] = 1. - model1 = ols(y=y, x=x) - model2 = ols(y=y, x=x_with, intercept=False) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model1 = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model2 = ols(y=y, x=x_with, intercept=False) assert_series_equal(model1.beta, model2.beta) # TODO: can we infer whether the intercept is there... @@ -298,28 +308,33 @@ def test_r2_no_intercept(self): # rolling - model1 = ols(y=y, x=x, window=20) - model2 = ols(y=y, x=x_with, window=20, intercept=False) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model1 = ols(y=y, x=x, window=20) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model2 = ols(y=y, x=x_with, window=20, intercept=False) assert_frame_equal(model1.beta, model2.beta) self.assertTrue((model1.r2 != model2.r2).all()) def test_summary_many_terms(self): x = DataFrame(np.random.randn(100, 20)) y = np.random.randn(100) - model = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x) model.summary def test_y_predict(self): y = tm.makeTimeSeries() x = tm.makeTimeDataFrame() - model1 = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model1 = ols(y=y, x=x) assert_series_equal(model1.y_predict, model1.y_fitted) assert_almost_equal(model1._y_predict_raw, model1._y_fitted_raw) def test_predict(self): y = tm.makeTimeSeries() x = tm.makeTimeDataFrame() - model1 = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model1 = ols(y=y, x=x) assert_series_equal(model1.predict(), model1.y_predict) assert_series_equal(model1.predict(x=x), model1.y_predict) assert_series_equal(model1.predict(beta=model1.beta), model1.y_predict) @@ -358,7 +373,8 @@ def test_predict_longer_exog(self): endog = Series(endogenous) exog = Series(exogenous) - model = ols(y=endog, x=exog) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=endog, x=exog) pred = model.y_predict self.assertTrue(pred.index.equals(exog.index)) @@ -368,7 +384,8 @@ def test_longpanel_series_combo(self): lp = wp.to_frame() y = lp.pop('ItemA') - model = ols(y=y, x=lp, entity_effects=True, window=20) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=lp, entity_effects=True, window=20) self.assertTrue(notnull(model.beta.values).all()) tm.assertIsInstance(model, PanelOLS) model.summary @@ -376,8 +393,10 @@ def test_longpanel_series_combo(self): def test_series_rhs(self): y = tm.makeTimeSeries() x = tm.makeTimeSeries() - model = ols(y=y, x=x) - expected = ols(y=y, x={'x': x}) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + expected = ols(y=y, x={'x': x}) assert_series_equal(model.beta, expected.beta) # GH 5233/5250 @@ -388,7 +407,8 @@ def test_various_attributes(self): x = DataFrame(np.random.randn(100, 5)) y = np.random.randn(100) - model = ols(y=y, x=x, window=20) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x, window=20) series_attrs = ['rank', 'df', 'forecast_mean', 'forecast_vol'] @@ -405,17 +425,22 @@ def test_catch_regressor_overlap(self): y = tm.makeTimeSeries() data = {'foo': df1, 'bar': df2} - self.assertRaises(Exception, ols, y=y, x=data) + def f(): + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + ols(y=y, x=data) + self.assertRaises(Exception, f) def test_plm_ctor(self): y = tm.makeTimeDataFrame() x = {'a': tm.makeTimeDataFrame(), 'b': tm.makeTimeDataFrame()} - model = ols(y=y, x=x, intercept=False) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x, intercept=False) model.summary - model = ols(y=y, x=Panel(x)) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=Panel(x)) model.summary def test_plm_attrs(self): @@ -423,8 +448,10 @@ def test_plm_attrs(self): x = {'a': tm.makeTimeDataFrame(), 'b': tm.makeTimeDataFrame()} - rmodel = ols(y=y, x=x, window=10) - model = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + rmodel = ols(y=y, x=x, window=10) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x) model.resid rmodel.resid @@ -433,7 +460,8 @@ def test_plm_lagged_y_predict(self): x = {'a': tm.makeTimeDataFrame(), 'b': tm.makeTimeDataFrame()} - model = ols(y=y, x=x, window=10) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x, window=10) result = model.lagged_y_predict(2) def test_plm_f_test(self): @@ -441,7 +469,8 @@ def test_plm_f_test(self): x = {'a': tm.makeTimeDataFrame(), 'b': tm.makeTimeDataFrame()} - model = ols(y=y, x=x) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=y, x=x) hyp = '1*a+1*b=0' result = model.f_test(hyp) @@ -456,12 +485,16 @@ def test_plm_exclude_dummy_corner(self): x = {'a': tm.makeTimeDataFrame(), 'b': tm.makeTimeDataFrame()} - model = ols( - y=y, x=x, entity_effects=True, dropped_dummies={'entity': 'D'}) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols( + y=y, x=x, entity_effects=True, dropped_dummies={'entity': 'D'}) model.summary - self.assertRaises(Exception, ols, y=y, x=x, entity_effects=True, - dropped_dummies={'entity': 'E'}) + def f(): + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + ols(y=y, x=x, entity_effects=True, + dropped_dummies={'entity': 'E'}) + self.assertRaises(Exception, f) def test_columns_tuples_summary(self): # #1837 @@ -469,7 +502,8 @@ def test_columns_tuples_summary(self): Y = Series(np.random.randn(10)) # it works! - model = ols(y=Y, x=X) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + model = ols(y=Y, x=X) model.summary @@ -484,7 +518,8 @@ class TestPanelOLS(BaseTest): _other_fields = ['resid', 'y_fitted'] def testFiltering(self): - result = ols(y=self.panel_y2, x=self.panel_x2) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y2, x=self.panel_x2) x = result._x index = x.index.get_level_values(0) @@ -544,8 +579,10 @@ def test_wls_panel(self): stack_x.index = stack_x.index._tuple_index stack_weights.index = stack_weights.index._tuple_index - result = ols(y=y, x=x, weights=1 / weights) - expected = ols(y=stack_y, x=stack_x, weights=1 / stack_weights) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=y, x=x, weights=1 / weights) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + expected = ols(y=stack_y, x=stack_x, weights=1 / stack_weights) assert_almost_equal(result.beta, expected.beta) @@ -555,7 +592,8 @@ def test_wls_panel(self): assert_almost_equal(rvals, evals) def testWithTimeEffects(self): - result = ols(y=self.panel_y2, x=self.panel_x2, time_effects=True) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y2, x=self.panel_x2, time_effects=True) assert_almost_equal(result._y_trans.values.flat, [0, -0.5, 0.5]) @@ -565,7 +603,8 @@ def testWithTimeEffects(self): # _check_non_raw_results(result) def testWithEntityEffects(self): - result = ols(y=self.panel_y2, x=self.panel_x2, entity_effects=True) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y2, x=self.panel_x2, entity_effects=True) assert_almost_equal(result._y.values.flat, [1, 4, 5]) @@ -577,8 +616,9 @@ def testWithEntityEffects(self): # _check_non_raw_results(result) def testWithEntityEffectsAndDroppedDummies(self): - result = ols(y=self.panel_y2, x=self.panel_x2, entity_effects=True, - dropped_dummies={'entity': 'B'}) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y2, x=self.panel_x2, entity_effects=True, + dropped_dummies={'entity': 'B'}) assert_almost_equal(result._y.values.flat, [1, 4, 5]) exp_x = DataFrame([[1., 6., 14., 1.], [1, 9, 17, 1], [0, 30, 48, 1]], @@ -589,7 +629,8 @@ def testWithEntityEffectsAndDroppedDummies(self): # _check_non_raw_results(result) def testWithXEffects(self): - result = ols(y=self.panel_y2, x=self.panel_x2, x_effects=['x1']) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y2, x=self.panel_x2, x_effects=['x1']) assert_almost_equal(result._y.values.flat, [1, 4, 5]) @@ -600,8 +641,9 @@ def testWithXEffects(self): assert_frame_equal(res, exp_x.reindex(columns=res.columns)) def testWithXEffectsAndDroppedDummies(self): - result = ols(y=self.panel_y2, x=self.panel_x2, x_effects=['x1'], - dropped_dummies={'x1': 30}) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y2, x=self.panel_x2, x_effects=['x1'], + dropped_dummies={'x1': 30}) res = result._x assert_almost_equal(result._y.values.flat, [1, 4, 5]) @@ -612,7 +654,8 @@ def testWithXEffectsAndDroppedDummies(self): assert_frame_equal(res, exp_x.reindex(columns=res.columns)) def testWithXEffectsAndConversion(self): - result = ols(y=self.panel_y3, x=self.panel_x3, x_effects=['x1', 'x2']) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y3, x=self.panel_x3, x_effects=['x1', 'x2']) assert_almost_equal(result._y.values.flat, [1, 2, 3, 4]) exp_x = [[0, 0, 0, 1, 1], [1, 0, 0, 0, 1], [0, 1, 1, 0, 1], @@ -625,8 +668,9 @@ def testWithXEffectsAndConversion(self): # _check_non_raw_results(result) def testWithXEffectsAndConversionAndDroppedDummies(self): - result = ols(y=self.panel_y3, x=self.panel_x3, x_effects=['x1', 'x2'], - dropped_dummies={'x2': 'foo'}) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=self.panel_y3, x=self.panel_x3, x_effects=['x1', 'x2'], + dropped_dummies={'x2': 'foo'}) assert_almost_equal(result._y.values.flat, [1, 2, 3, 4]) exp_x = [[0, 0, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 1], @@ -707,7 +751,8 @@ def testUnknownWindowType(self): def checkNonPooled(self, x, y, **kwds): # For now, just check that it doesn't crash - result = ols(y=y, x=x, pool=False, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=y, x=x, pool=False, **kwds) _check_repr(result) for attr in NonPooledPanelOLS.ATTRIBUTES: @@ -716,8 +761,9 @@ def checkNonPooled(self, x, y, **kwds): def checkMovingOLS(self, x, y, window_type='rolling', **kwds): window = 25 # must be larger than rank of x - moving = ols(y=y, x=x, window_type=window_type, - window=window, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + moving = ols(y=y, x=x, window_type=window_type, + window=window, **kwds) index = moving._index @@ -734,7 +780,8 @@ def checkMovingOLS(self, x, y, window_type='rolling', **kwds): x_iter[k] = v.truncate(before=prior_date, after=date) y_iter = y.truncate(before=prior_date, after=date) - static = ols(y=y_iter, x=x_iter, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + static = ols(y=y_iter, x=x_iter, **kwds) self.compare(static, moving, event_index=i, result_index=n) @@ -743,8 +790,10 @@ def checkMovingOLS(self, x, y, window_type='rolling', **kwds): def checkForSeries(self, x, y, series_x, series_y, **kwds): # Consistency check with simple OLS. - result = ols(y=y, x=x, **kwds) - reference = ols(y=series_y, x=series_x, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + result = ols(y=y, x=x, **kwds) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + reference = ols(y=series_y, x=series_x, **kwds) self.compare(reference, result) @@ -783,9 +832,11 @@ def test_auto_rolling_window_type(self): data = tm.makeTimeDataFrame() y = data.pop('A') - window_model = ols(y=y, x=data, window=20, min_periods=10) - rolling_model = ols(y=y, x=data, window=20, min_periods=10, - window_type='rolling') + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + window_model = ols(y=y, x=data, window=20, min_periods=10) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + rolling_model = ols(y=y, x=data, window=20, min_periods=10, + window_type='rolling') assert_frame_equal(window_model.beta, rolling_model.beta) diff --git a/pandas/stats/var.py b/pandas/stats/var.py index be55507f976cb..b06e2f3181496 100644 --- a/pandas/stats/var.py +++ b/pandas/stats/var.py @@ -26,6 +26,12 @@ class VAR(StringMixin): """ def __init__(self, data, p=1, intercept=True): + import warnings + warnings.warn("The pandas.stats.var 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/vector_ar.html#var", + FutureWarning, stacklevel=4) + try: import statsmodels.tsa.vector_ar.api as sm_var except ImportError: