本文整理匯總了Python中statsmodels.tsa.vector_ar.var_model.VAR.select_order方法的典型用法代碼示例。如果您正苦於以下問題:Python VAR.select_order方法的具體用法?Python VAR.select_order怎麽用?Python VAR.select_order使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類statsmodels.tsa.vector_ar.var_model.VAR
的用法示例。
在下文中一共展示了VAR.select_order方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_select_order
# 需要導入模塊: from statsmodels.tsa.vector_ar.var_model import VAR [as 別名]
# 或者: from statsmodels.tsa.vector_ar.var_model.VAR import select_order [as 別名]
def test_select_order(self):
result = self.model.fit(10, ic='aic', verbose=True)
result = self.model.fit(10, ic='fpe', verbose=True)
# bug
model = VAR(self.model.endog)
model.select_order()
示例2: test_lag_order_selection
# 需要導入模塊: from statsmodels.tsa.vector_ar.var_model import VAR [as 別名]
# 或者: from statsmodels.tsa.vector_ar.var_model.VAR import select_order [as 別名]
def test_lag_order_selection():
if debug_mode:
if "lag order" not in to_test:
return
else:
print("\n\nLAG ORDER SELECTION", end="")
for ds in datasets:
for dt in dt_s_list:
if debug_mode:
print("\n" + dt_s_tup_to_string(dt) + ": ", end="")
endog_tot = data[ds]
exog = generate_exog_from_season(dt[1], len(endog_tot))
model = VAR(endog_tot, exog)
obtained_all = model.select_order(10, trend=dt[0])
for ic in ["aic", "fpe", "hqic", "bic"]:
err_msg = build_err_msg(ds, dt,
"LAG ORDER SELECTION - " + ic.upper())
obtained = getattr(obtained_all, ic)
desired = results_ref[ds][dt]["lagorder"][ic]
assert_allclose(obtained, desired, rtol, atol, False, err_msg)
示例3: dates_from_str
# 需要導入模塊: from statsmodels.tsa.vector_ar.var_model import VAR [as 別名]
# 或者: from statsmodels.tsa.vector_ar.var_model.VAR import select_order [as 別名]
import pandas as pd
import numpy as np
import statsmodels.api as sm
import pylab
from statsmodels.tsa.base.datetools import dates_from_str
from statsmodels.tsa.vector_ar.var_model import VAR
mdata = sm.datasets.macrodata.load_pandas().data
dates = mdata[['year', 'quarter']].astype(int).astype(str)
quarterly = dates["year"] + "Q" + dates["quarter"]
quarterly = dates_from_str(quarterly)
mdata = mdata[['realgdp','realcons','realinv']]
mdata.index = pd.DatetimeIndex(quarterly)
data = np.log(mdata).diff().dropna() # log difference
# make a VAR model
model = VAR(data)
results = model.fit(2)
print results.summary()
results.plot()
results.plot_acorr() #autocorrelation
model.select_order(15)
results = model.fit(maxlags=15, ic='aic')
irf = results.irf(10)
irf.plot(orth=True) #Orthogonalization
pylab.show()
示例4: VAR
# 需要導入模塊: from statsmodels.tsa.vector_ar.var_model import VAR [as 別名]
# 或者: from statsmodels.tsa.vector_ar.var_model.VAR import select_order [as 別名]
print mn_bm, sd_bm, sr_bm
#calc beta's alpha's
#do forecast of returns, correlation. Use to Weight
rets.iloc[:,0:10].plot()
###DETOUR TO VAR FORECASTING
from statsmodels.tsa.vector_ar.var_model import VAR, VARResults, VARProcess
import statsmodels
statsmodels.version.version
#Check for NA's in data - have to reduce number of series used as full 30
#gave singular matrix
v1 = VAR(rets_train[series_red], freq='D')
v1.select_order(maxlags=30)
results = v1.fit(5) #From fitted
# results.summary()
results.plot()
# results.plot_acorr()
# plt.show()
#Make forecast for 3months
test_index = rets_test.index
fc_range = pd.date_range(start=test_index[0], periods=2, freq='3M')
fc_periods = len(rets_test[fc_range[0]:fc_range[1]])
lag_order = results.k_ar
fc = results.forecast(rets_train[series_red].values,fc_periods)
fc.shape
fc[:,-1]
df_fc = pd.DataFrame(fc,index=rets.index[0:fc_periods],columns=rets_train[series_red])