【发布时间】:2015-04-08 18:42:41
【问题描述】:
我在使用 R 中的函数 arma{tseries} 和 arima{stats} 拟合 ARMA 模型时发现了一些奇怪的现象。
两个函数采用的估计过程存在根本差异,arima{stats} 中的 Kalman 滤波器与 arma{tseries} 中的 ML 估计相反。
考虑到这两个函数在估计过程中的差异,如果我们使用相同的时间序列,我们不会期望这两个函数的结果会完全不同。
看来他们可以!
生成以下时间序列并添加 2 个异常值。
set.seed(1010)
ts.sim <- abs(arima.sim(list(order = c(1,0,0), ar = 0.7), n = 50))
ts.sim[8] <- ts.sim[12]*8
ts.sim[35] <- ts.sim[32]*8
使用这两个函数拟合一个 ARMA 模型。
# Works perfectly fine
arima(ts.sim, order = c(1,0,0))
# Works perfectly fine
arma(ts.sim, order = c(1,0))
将时间序列的级别更改 10 亿倍
# Introduce a multiplicative shift
ts.sim.1 <- ts.sim*1000000000
options(scipen = 999)
summary(ts.sim.1)
使用 2 个函数拟合 ARMA 模型:
# Works perfectly fine
arma(ts.sim.1, order = c(1,0))
# Does not work
arima(ts.sim.1, order = c(1,0,0))
## Error in solve.default(res$hessian * n.used, A): system is
computationally singular: reciprocal condition number = 1.90892e-19
我发现这个问题的原因是 SAS 软件成功地运行 proc x12 程序来进行季节性测试,但 R 上的相同功能给了我上述错误。这让我非常好奇并怀疑地看待 SAS 结果,但事实证明,这可能与 arima{stats} 有关。
谁能尝试详细说明导致我们无法使用 arima{stats} 拟合模型的上述错误的原因?
【问题讨论】:
标签: r time-series kalman-filter hessian-matrix