Error with cross validation tsibble

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)
)

try forecast(h = h), which is the same as forecast(h = 5) using the value you assigned to a variable named h

Got this message: Error in is.data.frame(x) : object (list)
cannot be coerced to type 'double'

I ran your code (with library(fpp3) instead of loading individual packages), changing forecast(h) to forecast(h = h). There were no problems and it produced a tibble with the test results. Perhaps you have old versions of the fpp3 packages?

I am using R 4.0.4.

I just updated my tsibble package, thanks for helping me with the issue

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.