Closed vidarsumo closed 3 years ago
Hey Vidar,
I'm unfortunately not able to reproduce any errors. Here is the code I'm using and it seems to work fine. If you are still experiencing an issue, then please provide a reproducible example and I'd be happy to take a look.
library(tidyverse)
library(tidymodels)
library(modeltime)
library(timetk)
m750_splits
#> <Analysis/Assess/Total>
#> <282/24/306>
# Model 1: auto_arima ----
model_fit_arima <- arima_reg() %>%
set_engine(engine = "auto_arima") %>%
fit(value ~ date, data = training(m750_splits))
#> frequency = 12 observations per 1 year
# Model 2: prophet ----
model_fit_prophet <- prophet_reg() %>%
set_engine(engine = "prophet") %>%
fit(value ~ date, data = training(m750_splits))
#> Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this.
#> Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
# Submodels
submodels_tbl <- modeltime_table(
model_fit_arima,
model_fit_prophet
)
submodels_tbl %>%
modeltime_calibrate(testing(m750_splits)) %>%
modeltime_forecast(
new_data = testing(m750_splits),
actual_data = m750
) %>%
plot_modeltime_forecast(.interactive = FALSE)
#> Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning -
#> Inf
# Final Model
final_model <- submodels_tbl %>%
filter(str_detect(.model_desc, "PROPHET"))
final_model %>%
modeltime_calibrate(testing(m750_splits)) %>%
modeltime_forecast(
new_data = testing(m750_splits),
actual_data = m750
) %>%
plot_modeltime_forecast(.interactive = FALSE)
#> Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning -
#> Inf
Created on 2021-05-27 by the reprex package (v2.0.0)
I have a modeltime table with nine models and I select one of them as the best model.
doing so results in an error when creating forecast, only when I do not use modeltime calibrate.
This gives me the error:
Error: Internal error in
df_slice()
: Columns must match the data frame size.But this works:
If I do not filter on the modeltime table, everything works fine without calibration. I.e., this works: