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 figure out the proper way to implement.
Suppose tsdata - a list of 3 lists of length 100 each, is my data. I tried
varmodel = ts.VAR(tsdata)
results = varmodel.fit(maxlags=5, ic='aic')
But the above is not working.
Update: I have changed the list of lists to a column stack according to suggestions below. It is working fine now. So tsdata, which was a list of lists is changed to
tsdata = np.column_stack(tsdata)
VAR(data_as_lists).fit(maxlags=5, ic='aic').summary()
I get output -- unclear whether said output is sensible. Even so, your data should probably be a pandas DataFrame with a DatetimeIndex. – Cleodelltsdata
in your code? You mention it in the question, but all I see isresid
. – Francinafrancine