如何解决如何对nnfor软件包的mlp和elm预测使用偏见调整?
我想知道如果预先使用BoxCox变换,如何对mlp
或elm
的预测进行偏差判断。
不幸的是,mlp
程序包的elm
和nnfor
函数不返回包括上限值和下限值的置信区间。
如果存在这些值,则可以使用InvBoxCox
包的forecast
函数执行偏置调整。我目前正在使用此功能对均值和拟合值进行逆变换,但是我只能对拟合值进行偏差调整。
这是我当前的工作流程:
library(nnfor)
library(forecast)
library(dplyr)
lambda <- 0
biasadj <- TRUE
ts <- AirPassengers
h <- 24
#use boxcox transformation if required
if(!is.null(lambda)) {
if(lambda == "auto"){
lambda <- BoxCox.lambda(ts)
}
ts_adj <- BoxCox(ts,lambda)
}else{
ts_adj <- ts
}
#fit elm model
forecast <- ts_adj %>% elm() %>% forecast(h = h)
#create new forecast object to fix bugs of nnfor package
forecast <- structure(
list(
mean = forecast$mean %>% as.numeric %>% ts(frequency = frequency(ts),start = time(forecast$mean)[1]),x = ts,fitted = c(rep(NA,length(ts) - length(forecast$fitted)),forecast$fitted) %>% as.numeric %>% ts(frequency = frequency(ts),start = time(ts)[1]),residuals = c(rep(NA,length(ts) - length(forecast$residuals)),forecast$residuals) %>% as.numeric %>% ts(frequency = frequency(ts),start = time(ts)[1])
),class = "forecast"
)
#generate output and back transform if required
if(!is.null(lambda)) {
output <- structure(
list(
mean = InvBoxCox(forecast$mean,lambda = lambda,biasadj = FALSE),x = forecast$x,fitted = InvBoxCox(forecast$fitted,biasadj = biasadj,fvar = var(forecast$residuals,na.rm = TRUE))
),class = "forecast"
)
output$residuals <- output$x - output$fitted
}else{
output <- forecast
}
#plot output
plot(output)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。