StatsModels には、将来の値を予測するために使用される 3 つの時系列変数を持つベクトル自己回帰 (VAR) モデルがあります。モデル出力の一部として予測せずに、ラグ値ではなく現在の値を使用して、モデルに追加の予測子を追加したいと思います。
コンテキストは、この変数が時系列変数の先行指標であるため、望ましい結果はx, y, z
、過去の値とこの先行指標の現在の値の関数としてモデル化することです。
この追加は StatsModels VAR を使用して可能ですか、それとも他の場所を探す必要がありますか?
以下のコードは、現在の基本モデルを設定するために使用される関連コードを示しています。
# nobs is the number of periods into the future to forecast
nobs = 1
# load the data
data = pd.read_csv('Data/data-merged.csv', index_col=0)
# x, y, z are each a time series
data = data[['x', 'y', 'z']]
train, test = train_test_split(data, train_size=0.8, shuffle=False)
###
# code here runs tests on the data and finds the best_order
###
# fit VAR model
var = VAR(endog=train.values)
var_result = var.fit(maxlags=best_order)
###
# code here tests the model results on the test data
###