来自-Inf值的tbats错误

时间:2016-12-21 22:15:44

标签: r time-series forecasting

我的最终目标是从不会预测负值的tbats模型创建预测。所以我使用下面的代码强制boxcox转换使用lambda = 0.我正在运行的问题是我的dataTs中有0,产生log(0)= -Inf,并且tbats抛出错误传递它时下面的消息-Inf。任何提示将不胜感激。

Code:

Log_TBATS<-function(y){
                        x <- log(y)
                        fit <- tbats(x, use.box.cox=FALSE)
                        fit$lambda <- 0
                        fit$control$use.box.cox <- TRUE
                        fc <- forecast(fit,h=20)
                        fc$x <- exp(x)
                        fc
}



Log_TBATS(dataTs)


Trace back:

Error in checkForRemoteErrors(val) : 
3 nodes produced errors; first error: NA/NaN/Inf in 'y' 
7. stop(count, " nodes produced errors; first error: ", firstmsg, 
    domain = NA) 
6. checkForRemoteErrors(val) 
5. dynamicClusterApply(cl, fun, length(x), argfun) 
4. clusterApplyLB(clus, c(1:nrow(control.array)), parFilterSpecifics, 
y = y, control.array = control.array, seasonal.periods = seasonal.periods, 
use.arma.errors = use.arma.errors, init.box.cox = init.box.cox, 
bc.lower = bc.lower, bc.upper = bc.upper, ...) 
3. bats(as.numeric(y), use.box.cox = use.box.cox, use.trend = use.trend, 
use.damped.trend = use.damped.trend, use.arma.errors = use.arma.errors, 
use.parallel = use.parallel, num.cores = num.cores, bc.lower = bc.lower, 
bc.upper = bc.upper, ...) 
2. tbats(x, use.box.cox = FALSE) 
1. Log_TBATS(dataTs) 





dput(dataTs)
c(2, 2, 1, 0, 0, 1, 2, 0, 1, 4, 8, 7, 7, 6, 5, 5, 4, 3, 1, 5, 
9, 5, 3, 2, 0, 0, 1, 0, 1, 0, 0, 2, 1, 5, 6, 5, 3, 2, 5, 4, 6, 
5, 3, 4, 2, 5, 2, 1, 0, 4, 1, 2, 2, 2, 1, 1, 2, 1, 2, 7, 7, 3, 
7, 3, 3, 2, 0, 4, 1, 3, 4, 1, 3, 0, 1, 3, 1, 0, 1, 3, 2, 4, 4, 
2, 4, 5, 4, 3, 8, 3, 3, 5, 4, 3, 1, 1, 1, 2, 1, 1)

0 个答案:

没有答案