VAR多变量预测

from statsmodels.tsa.api import VAR
# VAR example
from statsmodels.tsa.vector_ar.var_model import VAR
from random import random
# VAR example
from statsmodels.tsa.vector_ar.var_model import VAR
from random import random
# contrived dataset with dependency
data = list()
for i in range(100):
    v1 = i + random()
    v2 = v1 + random()
    row = [v1, v2]
    data.append(row)

# fit model
model = VAR(data)
model_fit = model.fit()

# make prediction
yhat = model_fit.forecast(model_fit.y, steps=10)
print(yhat)
posted @ 2021-11-18 18:36  oaksharks  阅读(348)  评论(0编辑  收藏  举报