I'm just starting to learn how to do time series forecasting in the tidymodel framework. I'm using Augmented Dynamic Adaptive models (adam). Using ADAM from the smooth package, I can do this to save nsims (e.g. 1000) forecasts of 10 years of data for further analysis:
library(smooth)
data(BJsales)
adamETSBJ <- adam(BJsales, "AAN")
OneKForecastsOf10Years <- forecast(adamETSBJ,h=10, interval="simulated",scenarios=TRUE,nsim=1000)
plot(OneKForecastsOf10Years$scenarios[,1], ylab="Sales",ylim=range(OneKForecastsOf10Years$scenarios), xlab="Horizon",col=rgb(0.8,0.8,0.8,0.4))
Plot all the generated lines
for(i in 2:1000){
lines(OneKForecastsOf10Years$scenarios[,i],col=rgb(0.8,0.8,0.8,0.4))
}
To do this in a tidymodel framework, I do:
library(modeltime)
library(tidymodels)
BJsales.tidy <- tibble(BJsales) %>% mutate(FakeDate = seq(as.Date('2020-01-01'),by='day',length.out = 150))
model_spec <- adam_reg(ets_model = "AAN") %>%
set_engine("adam")
model_fit <- model_spec %>%
fit(BJsales ~ FakeDate, data = BJsales.tidy)
models_tbl <- modeltime_table(
model_fit
)
But I can only seem to extract the summary stats for the forecasts, not the simulation paths
TidyForecasts <- models_tbl %>%
modeltime_forecast(
h=10,
actual_data = BJsales.tidy,
interval="simulated",scenarios=TRUE,nsims=1000
)
Any suggestions on what I'm missing? Thanks!