I have problem to make proper inverse transformation of a seasonally differenced forecast.
For example, I have the time series with the two periods period = c(19, 532)
like this:
set.seed(123)
per <- 19
x_ts <- rep(sin(seq(0, (2*pi), by = pi/9)), 84) + 200
x_ts[101:290] <- x_ts[101:290] + rep(seq(1, 20, by = 2), each = per)
x_ts[291:480] <- x_ts[291:480] + 20 - rep(seq(1, 20, by = 2), each = per)
x_ts[601:790] <- x_ts[601:790] + rep(seq(1, 23, by = 2.3), each = per)
x_ts[791:980] <- x_ts[791:980] + 23 - rep(seq(1, 23, by = 2.3), each = per)
x_ts[1101:1290] <- x_ts[1101:1290] + rep(seq(1, 19, by = 1.9), each = per)
x_ts[1291:1480] <- x_ts[1291:1480] + 19 - rep(seq(1, 19, by = 1.9), each = per)
x_ts <- x_ts + rnorm(length(x_ts), sd = 0.7)
plot(ts(x_ts))
This time series is obviously non-stationary (we need to do 2-times differentiation):
ndiffs(diff(x_ts, lag = per))
[1] 1
Now, I want to make a forecast of length 532 (the larger period).
I will do it by exponential smoothing from smooth
package:
library(smooth)
es_x <- es(ts(diff(x_ts, lag = per, differences = 2), freq = 532), model = "ANA", h = 532, silent = "none")
The forecast seems all right, isn't it?
But, when I want to make inverse transformation of the whole long forecast, something goes bad...
for_inv <- diffinv(es_x$forecast, lag = per, differences = 2, xi = tail(x_ts, per*2))
plot(ts(for_inv[-c(1:(per*2))]))
I am using the last two periods of original time series as initial values to inverse seasonal differentiation of level two.
Please, what is wrong with my approach? I don't want to use ARIMA or other typical time series forecasting method, but some advanced regression methods like boosting. Differentiating the time series make sense with these methods. I read questions about inverse transformation of differenced ts, but no one issued long forecasts of seasonally differenced ts.