statsmodels/statsmodels — Issue #131: easy fix for float used for range in sandbox.stats.diagnostic.acorr_lm
Author: robinkraft
Created: 2011-12-24 17:00:06+00:00
State: open

In sandbox.stats.diagnostic.acorr_lm, if you don't provide a maximum lag one is calculated for you. The result of that calculation is a float64 value, which causes the mlag loop to choke:

File "/home/ubuntu/epd-7.2-1-rh5-x86_64/lib/python2.7/site-packages/scikits/statsmodels/sandbox/stats/diagnostic.py", line 271, in acorr_lm
for mlag in range(1,maxlag):
TypeError: range() integer end argument expected, got numpy.float64.

Line 271 is this:

for mlag in range(1,maxlag):

maxlag is calculated on line 255:

maxlag = 12. * np.power(nobs/100., 1/4.)

So the fix is either to change the loop or the calculation:

for mlag in range(1,int(maxlag)):

Or

maxlag = int(12. * np.power(nobs/100., 1/4.))

Or you could change the original calculation:

Thanks!