当前位置: 首页>>代码示例>>Python>>正文


Python VAR.select_order方法代码示例

本文整理汇总了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()
开发者ID:Wombatpm,项目名称:statsmodels,代码行数:9,代码来源:test_var.py

示例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)
开发者ID:ChadFulton,项目名称:statsmodels,代码行数:22,代码来源:test_var_jmulti.py

示例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()
开发者ID:shimaXX,项目名称:workspace,代码行数:32,代码来源:var_example.py

示例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])
开发者ID:GBelzoni,项目名称:BigGits,代码行数:33,代码来源:CAPM.py


注:本文中的statsmodels.tsa.vector_ar.var_model.VAR.select_order方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。