如何对nnfor包的mlp()和elm()预测使用偏差调整?
我想知道如果事先使用了BoxCox变换,如何对如何对nnfor包的mlp()和elm()预测使用偏差调整?,r,forecasting,R,Forecasting,我想知道如果事先使用了BoxCox变换,如何对mlp或elm预测执行偏差调整 不幸的是,nnfor包的mlp和elm函数没有返回置信区间,包括上限值和下限值。 如果存在这些值,则可以使用forecast软件包的InvBoxCox功能执行偏差调整。我目前正在使用此函数对平均值和拟合值进行反向变换,但我只能对拟合值执行偏差调整 以下是我当前的工作流程: library(nnfor) library(forecast) library(dplyr) lambda <- 0 biasadj &l
mlp
或elm
预测执行偏差调整
不幸的是,nnfor
包的mlp
和elm
函数没有返回置信区间,包括上限值和下限值。
如果存在这些值,则可以使用forecast
软件包的InvBoxCox
功能执行偏差调整。我目前正在使用此函数对平均值和拟合值进行反向变换,但我只能对拟合值执行偏差调整
以下是我当前的工作流程:
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, lambda = lambda, biasadj = biasadj, fvar = var(forecast$residuals, na.rm = TRUE))
)
, class = "forecast"
)
output$residuals <- output$x - output$fitted
}else{
output <- forecast
}
#plot output
plot(output)
库(nnfor)
图书馆(预测)
图书馆(dplyr)
兰姆达