forecast(auto.arima):match.fun(FUN):节点堆栈溢出

时间:2015-12-22 15:38:14

标签: r time-series forecasting

在花时间阅读和实施解决方案后,我仍然无法查明以下错误消息的原因,并希望得到一些反馈。

  • 作者的源代码:kukuruku.co可以跳过平稳性测试

我关注的是:

fcast.arima <- forecast(fit.arima, h, lambda=L) -> Error in match.fun(FUN) : node stack overflow

除非 R 中存在错误,否则我无法看到此错误的来源,说实话,在fit.arima产生一些输出的范围内,h&amp;&amp; L都很好。来自forecast{}包的文档允许使用语法forecast(object,h,lambda),因此理论上没有任何理论错误。最终加载了所有必需的libraries

最让我印象深刻的是:

fcast.nn <- forecast(fit.nn, h, lambda=L)

确实有效,所以肯定会发生一些奇怪的事情 R ARIMA

最佳,

以下是清理代码

library(Quandl)
library(tseries)
library(forecast)

oil.ts <- Quandl("DOE/RBRTE", trim_start="1987-11-10", trim_end="2015-01-01", type="zoo")
oil.tsw <-Quandl("DOE/RBRTE", trim_start="1987-11-10", trim_end="2015-01-01", type="zoo", collapse="weekly")
oil.tsm <-Quandl("DOE/RBRTE", trim_start="1987-11-10", trim_end="2015-01-01", type="ts", collapse="monthly")
plot(oil.tsm, xlab="Year", ylab="Price, $", type="l")
lines(lowess(oil.tsm), col="red", lty="dashed")

L <- BoxCox.lambda(ts(oil.ts, frequency=260), method="loglik")
Lw <- BoxCox.lambda(ts(oil.tsw, frequency=52), method="loglik")
Lm <- BoxCox.lambda(oil.tsm, method="loglik")

# Fit NN for long-run
fit.nn <- nnetar(ts(oil.ts, frequency=260), lambda=L, size=3)
fcast.nn <- forecast(fit.nn, h=520, lambda=L)
fit.nnw <- nnetar(ts(oil.tsw, frequency=52), lambda=Lw, size=3)
fcast.nnw <- forecast(fit.nnw, h=104, lambda=Lw)
fit.nnm <- nnetar(oil.tsm, lambda=Lm, size=3)
fcast.nnm <- forecast(fit.nnm, h=24, lambda=Lm)
par(mfrow=c(3, 1))
plot(fcast.nn, include=1040)
plot(fcast.nnw, include=208)
plot(fcast.nnm, include=48)

# Fit ARIMA, NN and ETS for short-run
short <- ts(oil.ts[index(oil.ts) > "2014-06-30" & index(oil.ts) < "2014-12-  01"], frequency=20)
short.test <- as.numeric(oil.ts[index(oil.ts) >= "2014-12-01",])
h <- length(short.test)
fit.arima <- auto.arima(short, lambda=L)
fcast.arima <- forecast(fit.arima, h, lambda=L)
fit.nn <- nnetar(short, size=7, lambda=L)
fcast.nn <- forecast(fit.nn, h, lambda=L)
fit.tbats <-tbats(short, lambda=L)
fcast.tbats <- forecast(fit.tbats, h, lambda=L)
par(mfrow=c(3, 1))
plot(fcast.arima, include=3*h)
plot(fcast.nn, include=3*h)
plot(fcast.tbats, include=3*h)

0 个答案:

没有答案