本文整理汇总了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])