Hi,
I'm trying to use stretch_tsibble to check the performance of my model, follow below my reprex code, I`m not really sure what is the issue.
If someone could give some help I will appreciate.
Regards
library(dplyr)
#> Warning: package 'dplyr' was built under R version 3.6.2
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tsibble)
#> Warning: package 'tsibble' was built under R version 3.6.2
library(fable)
#> Warning: package 'fable' was built under R version 3.6.2
#> Carregando pacotes exigidos: fabletools
iniciativa <- tibble(
data_planejada = seq(as.Date("2020-01-01"), length = 200, by = "1 day"),
n = sample(seq(100), size = 200, replace = TRUE)
) %>%
as_tsibble(index = data_planejada)
h <- 5
iniciativa_cv <- iniciativa %>%
slice(1:(n() - h)) %>%
stretch_tsibble(.init=20, .step=1)
tslm_tbl <- iniciativa_cv %>%
model(
tslm1 = TSLM(n ~ trend() + fourier(K = 1)),
tslm2 = TSLM(n ~ trend() + fourier(K = 2)),
tslm3 = TSLM(n ~ trend() + fourier(K = 3)),
tslm4 = TSLM(n ~ trend() + season(period = "week"))
)
fc_tbl <- tslm_tbl %>%
forecast(h) %>%
group_by(.id) %>%
mutate(h = row_number()) %>%
ungroup()
fc_tbl %>% accuracy(
iniciativa,
by=c("h",".model"),
list(rmse = RMSE, mae = MAE, mape = MAPE, mase = MASE, crps = CRPS, winkler = winkler_score)
)