时间序列包 `forecast` 和 `aTSA` 之间的冲突——如何在 RMarkdown 文档中使其协同工作
Conflict between time series packages `forecast` and `aTSA`- how to make it work together in RMarkdown document
我在进行时间序列分析时发现了一个有趣的错误,如果没有 this question.
我永远不会意识到
我使用了两个包:forecast
by Hyndman and Athanasopoulos and aTSA
.
我有模型
JJ_sarima <- Arima(JJ_data_ts_train, order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1), period = 4))
这给了我
Series: JJ_data_ts_train
ARIMA(0,1,1)(0,1,1)[4]
Coefficients:
ma1 sma1
-0.3419 -0.1849
s.e. 0.1344 0.1389
sigma^2 estimated as 0.001035: log likelihood=128
AIC=-250 AICc=-249.6 BIC=-243.57
在同一个 RMarkdown 文档中,我做了一个 Augmented Dickey-Fuller 测试。
adf.test(JJ_data$earnings, nlag = 10)
当我尝试使用 forecast
函数时,它不起作用。
jj_forecast <- forecast(JJ_sarima, h = 10)
预测错误(JJ_sarima,h = 10):未使用的参数(h = 10)
如果我删除 h,我得到
预测错误(JJ_sarima):'object' 应该是 'Arima' 或 'estimate' class 从 arima() 或估计()
我禁用了 aTSA
包,这在我的文档中是必需的,因为那时我无法 运行 ADF 测试。
Error in adf.test(JJ_data$earnings, nlag = 10) :
could not find function "adf.test"
但是它们 forecast()
有效,这很奇怪。但我想原因是 the function with the same name 存在于 aTSA
.
有什么想法可以让它们在 RMarkdown 中协同工作吗?可能 运行 在执行 ADF 测试后在不同的块中一个一个地进行,但不是一个好的解决方案。
我们可以用::
来区分包
forecast::forecast(JJ_sarima, h = 10)
我在进行时间序列分析时发现了一个有趣的错误,如果没有 this question.
我永远不会意识到我使用了两个包:forecast
by Hyndman and Athanasopoulos and aTSA
.
我有模型
JJ_sarima <- Arima(JJ_data_ts_train, order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1), period = 4))
这给了我
Series: JJ_data_ts_train
ARIMA(0,1,1)(0,1,1)[4]
Coefficients:
ma1 sma1
-0.3419 -0.1849
s.e. 0.1344 0.1389
sigma^2 estimated as 0.001035: log likelihood=128
AIC=-250 AICc=-249.6 BIC=-243.57
在同一个 RMarkdown 文档中,我做了一个 Augmented Dickey-Fuller 测试。
adf.test(JJ_data$earnings, nlag = 10)
当我尝试使用 forecast
函数时,它不起作用。
jj_forecast <- forecast(JJ_sarima, h = 10)
预测错误(JJ_sarima,h = 10):未使用的参数(h = 10)
如果我删除 h,我得到
预测错误(JJ_sarima):'object' 应该是 'Arima' 或 'estimate' class 从 arima() 或估计()
我禁用了 aTSA
包,这在我的文档中是必需的,因为那时我无法 运行 ADF 测试。
Error in adf.test(JJ_data$earnings, nlag = 10) :
could not find function "adf.test"
但是它们 forecast()
有效,这很奇怪。但我想原因是 the function with the same name 存在于 aTSA
.
有什么想法可以让它们在 RMarkdown 中协同工作吗?可能 运行 在执行 ADF 测试后在不同的块中一个一个地进行,但不是一个好的解决方案。
我们可以用::
来区分包
forecast::forecast(JJ_sarima, h = 10)