【问题标题】:Outier detection using tsoutlier in R在 R 中使用 ts 异常值检测异常值
【发布时间】:2015-07-12 13:39:30
【问题描述】:

我正在尝试使用 ARIMA 模型预测 Nifty 的每周股价。资料可以下载here。我尝试了以下三种情况:

第一种情况:我使用 tsoutliers 包中的 tso 函数来识别异常值(如果有)并拟合 ARIMA 模型。我得到的结果是 ARIMA(1,1,1),没有检测到异常值。最小代码:

outliers1 <- tso(close, tsmethod = c("auto.arima"), args.tsmethod = list(allowdrift=TRUE))

获得的结果:

ARIMA(1,1,1)                    

Coefficients:
         ar1      ma1
      0.6112  -0.5684
s.e.  0.3496   0.3632

sigma^2 estimated as 25268:  log likelihood=-2523.68
AIC=5053.35   AICc=5053.41   BIC=5065.24

No outliers were detected.

第二种情况:由于没有检测到异常值,我使用了预测包中的auto.arima() 来查看我得到的模型。正如之前的帖子中所建议的,我逐步逼近了 FALSE。我获得了 ARIMA (3,1,2) 模型。最小代码:

close <- read.ts("close.csv", header = FALSE")
fit <- auto.arima(close, stepwise = FALSE, trace = TRUE, approximation = FALSE)

获得的结果:

Series: close 
ARIMA(3,1,2) with drift         

Coefficients:
          ar1      ar2     ar3     ma1     ma2    drift
      -1.7302  -0.7838  0.0624  1.7730  0.9097  10.4769
s.e.   0.0695   0.1125  0.0578  0.0483  0.0475   8.4509

sigma^2 estimated as 24413:  log likelihood=-2510.18
AIC=5034.37   AICc=5034.66   BIC=5062.11

第三种情况:在我的第三种情况下,我尝试在 tso 中使用第二种情况下获得的 ARIMA(3,1,2) 来检查任何异常值。但该模型没有检测到异常值。最小代码:

outlier2 <- tso(close, maxit = 10, tsmethod = c("arima"), args.tsmethod = list(order =c(3,1,2)))

获得的结果:

    Coefficients:
          ar1     ar2      ar3     ma1      ma2
      -0.2224  0.3573  -0.0186  0.2451  -0.2548
s.e.   0.7914  0.4344   0.1107  0.7884   0.4603
sigma^2 estimated as 24986:  log likelihood = -2521.51,  aic = 5055.02
No outliers were detected.

我的问题是,如果数据中没有任何异常值,那么为什么案例 1 和案例 2 中的结果会有所不同。我在模型构建中是否遗漏了什么?此外,使用 ARIMA (3,1,2) 和 (1,1,1) 获得的预测效果不佳。

【问题讨论】:

    标签: r automated-tests time-series forecasting


    【解决方案1】:

    在第一种情况下,tso 使用默认参数stepwise=TRUE。在第二种情况下,您正在设置stepwise=FALSE。这可能导致对 ARIMA 模型的不同选择。通过 tso 中的参数 args.tsmethod 传递 stepwise=FALSE 应该会产生相同的结果(除非发现此模型的异常值)。

    【讨论】:

    • 您的建议解决了我的问题。我将代码更改为outliers &lt;- tso(close, tsmethod = c("auto.arima"), args.tsmethod = list(allowdrift=TRUE, stepwise=FALSE, approximation=FALSE))。现在,对于案例 1 和 2,我得到了 ARIMA (3,1,2)。:)
    猜你喜欢
    • 2021-03-08
    • 1970-01-01
    • 2020-02-23
    • 2019-07-24
    • 1970-01-01
    • 2019-10-01
    • 2015-01-09
    • 1970-01-01
    • 2020-04-03
    相关资源
    最近更新 更多