Skip to content

Commit

Permalink
REF: hac-panel, hac_groupsum, avoid np.diff for group identification
Browse files Browse the repository at this point in the history
  • Loading branch information
josef-pkt committed Aug 16, 2016
1 parent 1ecc95e commit 7066842
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions statsmodels/base/covtype.py
Expand Up @@ -252,7 +252,7 @@ def get_robustcov_results(self, cov_type='HC1', use_t=None, **kwds):
nobs_ = len(groups)
elif time is not None:
# TODO: clumsy time index in cov_nw_panel
tt = (np.nonzero(np.diff(time) < 0)[0] + 1).tolist()
tt = (np.nonzero(time[1:] < time[:-1])[0] + 1).tolist()
nobs_ = len(time)
else:
raise ValueError('either time or groups needs to be given')
Expand All @@ -277,7 +277,7 @@ def get_robustcov_results(self, cov_type='HC1', use_t=None, **kwds):
res.cov_kwds['weights_func'] = weights_func
if adjust_df:
# need to find number of groups
tt = (np.nonzero(np.diff(time) < 0)[0] + 1)
tt = (np.nonzero(time[1:] < time[:-1])[0] + 1)
self.n_groups = n_groups = len(tt) + 1
res.cov_params_default = sw.cov_nw_groupsum(self, maxlags, time,
weights_func=weights_func,
Expand Down
1 change: 0 additions & 1 deletion statsmodels/discrete/tests/test_sandwich_cov.py
Expand Up @@ -653,7 +653,6 @@ def setup_class(cls):
use_correction='hac',
df_correction=False)
cls.res1 = mod1.fit(cov_type='hac-panel', cov_kwds=kwds)
cls.res1b = mod1.fit(cov_type='nw-panel', cov_kwds=kwds)

mod2 = OLS(endog, exog)
cls.res2 = mod2.fit(cov_type='hac-panel', cov_kwds=kwds)
Expand Down
4 changes: 2 additions & 2 deletions statsmodels/regression/linear_model.py
Expand Up @@ -2054,7 +2054,7 @@ def get_robustcov_results(self, cov_type='HC1', use_t=None, **kwds):
nobs_ = len(groups)
elif time is not None:
# TODO: clumsy time index in cov_nw_panel
tt = (np.nonzero(np.diff(time) < 0)[0] + 1).tolist()
tt = (np.nonzero(time[1:] < time[:-1])[0] + 1).tolist()
nobs_ = len(time)
else:
raise ValueError('either time or groups needs to be given')
Expand All @@ -2079,7 +2079,7 @@ def get_robustcov_results(self, cov_type='HC1', use_t=None, **kwds):
res.cov_kwds['weights_func'] = weights_func
if adjust_df:
# need to find number of groups
tt = (np.nonzero(np.diff(time) < 0)[0] + 1)
tt = (np.nonzero(time[1:] < time[:-1])[0] + 1)
self.n_groups = n_groups = len(tt) + 1
res.cov_params_default = sw.cov_nw_groupsum(self, maxlags, time,
weights_func=weights_func,
Expand Down

0 comments on commit 7066842

Please sign in to comment.