How to implement vector autoregression in Python?

I want to implement vector autoregression in Python. My data is saved as a list of 3 lists. I found this - http://statsmodels.sourceforge.net/stable/vector_ar.html#var , but could not find the correct implementation method.

Suppose tsdata is a list of 3 lists of 100 each, this is my data. I did my best

varmodel = ts.VAR(tsdata) results = varmodel.fit(maxlags=5, ic='aic') 

But the above does not work.

Update : I changed the list of lists to a stack of columns as suggested below. Now it works fine. So tsdata, which was a list of lists, is changed to

 tsdata = np.column_stack(tsdata) 
+5
source share

Source: https://habr.com/ru/post/1498115/


All Articles