Skip to content

Commit

Permalink
Merge pull request #1987 from josef-pkt/bugs_tsa_base
Browse files Browse the repository at this point in the history
BUG tsa pacf, base bootstrap
  • Loading branch information
josef-pkt committed Sep 23, 2014
2 parents 09038b4 + b716b91 commit f8cf491
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion statsmodels/base/model.py
Expand Up @@ -1700,7 +1700,7 @@ def bootstrap(self, nrep=100, method='nm', disp=0, store=1):
print(self.model.__class__)
hascloneattr = True if hasattr(self, 'cloneattr') else False
for i in range(nrep):
rvsind = np.random.randint(self.nobs - 1, size=self.nobs)
rvsind = np.random.randint(self.nobs, size=self.nobs)
#this needs to set startparam and get other defining attributes
#need a clone method on model
fitmod = self.model.__class__(self.endog[rvsind],
Expand Down
4 changes: 3 additions & 1 deletion statsmodels/base/tests/test_data.py
Expand Up @@ -726,8 +726,9 @@ def test_hasconst(self):
assert_equal(mod.data.const_idx, result[1])

# extra check after fit, some models raise on singular
fit_kwds = getattr(self, 'fit_kwds', {})
try:
res = mod.fit()
res = mod.fit(**fit_kwds)
assert_equal(res.model.k_constant, result[0])
assert_equal(res.model.data.k_constant, result[0])
except:
Expand Down Expand Up @@ -795,6 +796,7 @@ def __init__(self):
from statsmodels.discrete.discrete_model import Logit
self.mod = Logit
self.y = self.y_bin
self.fit_kwds = {'disp': False}


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions statsmodels/base/tests/test_optimize.py
Expand Up @@ -17,10 +17,10 @@ def dummy_func(x):
return x**2

def dummy_score(x):
return 2*x
return 2.*x

def dummy_hess(x):
return [[2]]
return [[2.]]

def test_full_output_false():
# just a smoke test
Expand Down
3 changes: 2 additions & 1 deletion statsmodels/tsa/stattools.py
Expand Up @@ -582,9 +582,10 @@ def pacf(x, nlags=40, method='ywunbiased', alpha=None):
else:
raise ValueError('method not available')
if alpha is not None:
varacf = 1. / len(x)
varacf = 1. / len(x) # for all lags >=1
interval = stats.norm.ppf(1. - alpha / 2.) * np.sqrt(varacf)
confint = np.array(lzip(ret - interval, ret + interval))
confint[0] = ret[0] # fix confidence interval for lag 0 to varpacf=0
return ret, confint
else:
return ret
Expand Down
4 changes: 4 additions & 0 deletions statsmodels/tsa/tests/test_stattools.py
Expand Up @@ -179,6 +179,10 @@ def test_ols(self):
# from edited Stata ado file
res = [[-.1375625, .1375625]] * 40
assert_almost_equal(centered[1:41], res, DECIMAL_6)
# check lag 0
assert_equal(centered[0], [0., 0.])
assert_equal(confint[0], [1, 1])
assert_equal(pacfols[0], 1)


def test_yw(self):
Expand Down

0 comments on commit f8cf491

Please sign in to comment.