I have tried and tried to figure this out but am having no luck!!
I have constructed a model that aims to forecast a relatively short time series using an exponential smoothing method. The results need to be constrained to between 0 and 1, so I use the scaled logit transformation detailed by the package authors here.
The model works beautifully for over 1000 groups across my dataset, but a single group produces an unexpected forecast as shown in the reprex.
Note that very small changes will change the result. For example, if I set upper
to 1.1, the model looks much more sensible. Likewise, if I reduce the value of the last number in x
, the model produces a sensible result.
I'm afraid I just don't understand the methods here well enough to diagnose this. Any help is much appreciated.
library(dplyr)
library(tsibble)
library(fable)
scaled_logit <- function(x, lower = 0, upper = 1) {
log((x - lower) / (upper - x))
}
inv_scaled_logit <- function(x, lower = 0, upper = 1) {
(upper - lower) * exp(x) / (1 + exp(x)) + lower
}
my_scaled_logit <- new_transformation(
scaled_logit, inv_scaled_logit)
x = c(0.5156105, 0.5137760, 0.5275933, 0.5561075, 0.5722731, 0.6237780, 0.6243926, 0.6256203, 0.8582260)
tibble(time = seq(2004, 2020, by = 2), x = x) %>%
as_tsibble(index = time) %>%
model(fit = ETS(my_scaled_logit(x, lower = 0, upper = 1) ~ trend("Ad") + season("N"))) %>%
forecast(h = 15) %>% autoplot()
Created on 2022-10-29 with reprex v2.0.2