我正在尝试使用 statsmodels 运行 VAR 算法来预测一些未来值,但我被卡住了。
我有一个这样的值数组:
php_resp_time = [349.70448833, 304.32462033000002, 228.08079499999999, 245.03481033, 268.90133700000001, 275.58803332999997, ......, etc.]
我所做的是:
>>> mdata = DataFrame(php_resp_time)
>>> output:
0
0 349.704488
1 304.324620
2 228.080795
3 245.034810
4 268.901337
5 275.588033
etc.
>>> dates = sm.tsa.datetools.dates_from_range('1961', length=len(php_resp_time)) #create a range of random dates
>>> output: [datetime.datetime(1961, 12, 31, 0, 0), datetime.datetime(1962, 12, 31, 0, 0), datetime.datetime(1963, 12, 31, 0, 0), datetime.datetime(1964, 12, 31, 0, 0), etc.]
>>> mdata.index = pandas.DatetimeIndex(dates) #assign dates as indexes
>>> data = np.log(mdata).diff().dropna()
>>> output:
0
1962-12-31 -0.138994
1963-12-31 -0.288395
1964-12-31 0.071700
1965-12-31 0.092944
1966-12-31 0.024563
1967-12-31 0.047386
1968-12-31 -0.048385
1969-12-31 0.071730
etc.
#now when I am trying to call the VAR model I get this error:
>>>model = sm.tsa.VAR(data)
>>>output: File "/usr/local/lib/python2.7/dist-packages/statsmodels/tsa/vector_ar/var_model.py", line 345, in __init__
self.neqs = self.endog.shape[1]
IndexError: tuple index out of range
有谁知道如何解决这个问题?
谢谢!