【问题标题】:Fitted values from ARIMA in pythonpython中ARIMA的拟合值
【发布时间】:2018-09-06 09:45:16
【问题描述】:

我正在研究时间序列模型。我必须在 pyramid-arima 模块中使用 auto_arima 模型。我在我的数据集上安装了一个 auto_arima 模型。现在我有两个问题。

  1. 我想查看模型参数。

  2. 我想从模型中获取拟合值。

下面是我的示例代码。

m1_hist = auto_arima(ts1_hist, start_p=1, start_q=1,
                       max_p=3, max_q=3, m=12,
                       start_P=0, seasonal=True,
                       d=1, D=1, trace=True,
                       error_action='ignore',  
                       suppress_warnings=True, 
                       stepwise=True)

m1_hist2 = m1_hist.fit(ts1_hist)

我使用m1_hist.params 来获取模型参数。但它没有向我显示输出。

你能解决我的问题吗?

提前致谢。

【问题讨论】:

    标签: scikit-learn time-series statsmodels pyramid-arima


    【解决方案1】:

    其实你应该使用

    m1_hist.arparams()
    # output: array([-0.06322811,  0.26664419]) in my case
    

    m1_hist.params()
    # array([-3.53003470e-03, -6.32281127e-02,  2.66644193e-01, -3.67248974e-01,-5.76907932e-01,  5.83541332e-01, -2.66632875e-01, -1.28657280e+00,  4.93685722e-01,  5.05488473e+00])
    

    【讨论】:

      【解决方案2】:

      找到模型后,您应该将其拟合到您的实际 (y) 值。基于 arima 中所选模型的 y 值预测将是拟合值。

      例如,

      start_index = 0 
      end_index = 15
      forecast_index = 15
      y = df.iloc[start_index:end_index] # end index in iloc is exclusive
      model = auto_arima(y, ....)
      
      # Predictions of y values based on "model", namely fitted values
      yhat = model_fit.predict_in_sample(start=start_ind, end=end_ind - 1)
      
      # One step forecast: forecast the element at index 15 
      forecast = model_fit.predict(n_periods=1)
      

      【讨论】:

        猜你喜欢
        • 2022-01-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-01
        • 2021-12-13
        • 1970-01-01
        相关资源
        最近更新 更多