小编deb*_*deb的帖子

如何在Python中实现向量自动回归?

我想在python中实现向量自动回归.我的数据保存为3个列表的列表.我找到了这个 - http://statsmodels.sourceforge.net/stable/vector_ar.html#var,但无法弄清楚实施的正确方法.假设tsdata是3个长度为100的列表的列表,是我的数据.我试过了

varmodel = ts.VAR(tsdata)

results = varmodel.fit(maxlags=5, ic='aic')
Run Code Online (Sandbox Code Playgroud)

但上述情况并不奏效.

更新:我已根据以下建议将列表列表更改为列堆栈.现在工作正常.所以tsdata,这是一个列表列表更改为

tsdata  = np.column_stack(tsdata)
Run Code Online (Sandbox Code Playgroud)

python time-series forecasting pandas statsmodels

6
推荐指数
1
解决办法
4995
查看次数

如何从R中的预测中提取预测?

我在具有多个位置的时间序列上运行VAR.假设loc1,loc2和loc3是时间序列数据的列名.

fitVAR = VAR(data,p=order,type = "both", ic = "AIC") 
pred = predict(fitVAR,n.ahead = L)
Run Code Online (Sandbox Code Playgroud)

我知道我可以通过pred$fcst$loc1[,1]等等来获得预测.但是假设我想编写一个函数来执行此操作,它将位置名称作为输入变量(例如,LOC=c("loc1","loc2","loc3")).我该怎么做?

r predict

4
推荐指数
1
解决办法
2376
查看次数

标签 统计

forecasting ×1

pandas ×1

predict ×1

python ×1

r ×1

statsmodels ×1

time-series ×1