I have a subset of a pandas dataframe that contains a time series I want to analyze with an AR or ARIMA model using statsmodel:
data_sci = H_Clinton_social_vector.Florida
The data looks like this:
Date
2015-09-28 587
2015-10-05 582
2015-10-12 606
2015-10-19 698
My AR model is created like this, aggregating the time series on a weekly basis:
ar_model = sm.tsa.AR(data_sci, freq='W')
ar_model
<statsmodels.tsa.ar_model.AR at 0x1178f5490>
Next, I want to do a Maximum Likelihood Estimator (MLE) fit of the AR parameters, with a half year lag:
ar_res = ar_model.fit(maxlag=26, method='mle')
I get the following results:
correlate() got an unexpected keyword argument 'old behavior'
I don't understand what the problem is, which I assume is related to the auto correlation of the data, due the correlate() argument. There is high autocorrelation in my data so this should be ok.
I am not very familiar with stasmodels, and prefer avoding coding an AR or ARIMA model from scratch.
After some research, the problem was incompatibility of statsmodel with numpy 1.10. Although I had the latest release of stasmodel, there was an internal problem with autocorrelation (incompatibility with latest version of numpy), that required the install of the master code at Github.
First, I found out what versions of stasmodels' dependencies I had:
Python >= 2.6, including Python 3.x
NumPy >= 1.5.1
SciPy >= 0.9.0
Pandas >= 0.7.1
Patsy >= 0.3.0
All of them were OK, so in order to install from source, I needed to have Cython >= 20.1, which I downloaded from here. Uncompress, navigate to that directory and do:
python setup.py install
After that is done, navigate to the downloaded copy of statsmodel from Github, and build stasmodel:
python setup.py install
You'll see:
Cythonizing sources
Processing statsmodels/nonparametric/_smoothers_lowess.pyx
Processing statsmodels/nonparametric/linbin.pyx
Processing statsmodels/tsa/kalmanf/kalman_loglike.pyx
Processing statsmodels/tsa/statespace/_statespace.pyx.in
etc. After a while, you'll have the latest build of statsmodel. Now my AR model works fine, although with some warnings that you can ignore or disable.
You need to downgrade numpy
to version 1.9.2
or below, just tested and did not get this error for your code anymore. It is due to a call to np.correlate()
in _presample_varcov
where statsmodels.tsa.armodel
calculates the inverse of the presample variance-covariance.
Numpy
has deprecated the use of multiarray.correlate()
(the old behavior
) with 1.10
around June 2015 (see docs), but statsmodels
has not been updated in this respect (0.6.1
dates from December 2014).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With