Skip to content

Commit

Permalink
BUG: acorr_breush_godfrey fix nlags choice closes statsmodels#676
Browse files Browse the repository at this point in the history
  • Loading branch information
josef-pkt committed Aug 8, 2013
1 parent 1e679b0 commit 9ca454a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions statsmodels/sandbox/stats/diagnostic.py
Expand Up @@ -490,14 +490,14 @@ def acorr_breush_godfrey(results, nlags=None, store=False):
'''

x = np.concatenate((np.zeros(nlags), results.resid))
x = np.asarray(results.resid)
exog_old = results.model.exog
x = np.asarray(x)
nobs = x.shape[0]
if nlags is None:
#for adf from Greene referencing Schwert 1989
nlags = 12. * np.power(nobs/100., 1/4.)#nobs//4 #TODO: check default, or do AIC/BIC
nlags = np.trunc(12. * np.power(nobs/100., 1/4.))#nobs//4 #TODO: check default, or do AIC/BIC

x = np.concatenate((np.zeros(nlags), x))

#xdiff = np.diff(x)
#
Expand Down
5 changes: 5 additions & 0 deletions statsmodels/stats/tests/test_diagnostic.py
Expand Up @@ -294,6 +294,11 @@ def test_acorr_breush_godfrey(self):
breushgodfrey_f['statistic'], breushgodfrey_f['pvalue']]
assert_almost_equal(bg, bg_r, decimal=13)

# check that lag choice works
bg2 = smsdia.acorr_breush_godfrey(res, nlags=None)
bg3 = smsdia.acorr_breush_godfrey(res, nlags=14)
assert_almost_equal(bg2, bg3, decimal=13)

def test_acorr_ljung_box(self):
res = self.res

Expand Down

0 comments on commit 9ca454a

Please sign in to comment.