Модели fabletools не объединяются, чтобы дать правильный ответ, как отлаживать?

Краткое содержание

У меня есть таблица, которую я преобразовал в смешанный иерархический (и сгруппированный) временной ряд. Для подавляющего большинства указанных временных рядов я могу получить прогнозы с помощью следующего:

      fit <- hg_ts %>%
  fabletools::model(
    stl = fabletools::decomposition_model(
      feasts::STL(log(y), robust = TRUE),
      fable::ETS(season_adjust)))

fit %>%
  fabletools::forecast(h = 4)

Для многих оставшихся временных рядов это не дает прогноза. В частности, некоторые временные ряды возвращаются

      Warning: Non-integer lag orders for random walk models are not supported. Rounding to the nearest integer.
...
Warning: 29 errors (1 unique) encountered for stl
[29] The models specified do not combine to give the correct response.
Please check that you have specified the decomposition models appropriately.

Трудности отладки

Если я попытаюсьdebugonce(fabletools::decomposition_model), я вижу звонки наfabletools::new_model_class()иfabletools::new_model_definition(). Я взглянул на https://fabletools.tidyverts.org/articles/extension_models.html (а также на &lt;ahref="https: articles="" debugging.html"="" r6.r-lib.org="" rel="nofollow noopener noreferrer"&gt;https://r6.r-lib.org/articles/Debugging.html ), но в настоящее время многое выше моего понимания. .&lt;/ahref="https:&gt;

Как я могу достичь точки «отладки» (где я могу проверить все объекты, о которых знает реальное выполнение кода) вmodel_decomposition.Rкод, где он говорит

        if(!isTRUE(all.equal(response(model)[[".response"]], .data[[measured_vars(.data)]]))){
    abort(
"The models specified do not combine to give the correct response.
Please check that you have specified the decomposition models appropriately.")
  }

если бы это была моя модель декомпозиции:

      library(magrittr)

tsibble::tourism %>%
    fabletools::aggregate_key((State/Region) * Purpose, Trips = sum(Trips)) %>% 
    dplyr::filter(Purpose == "Business", State == "New South Wales") %>% 
    fabletools::model(
        stl = fabletools::decomposition_model(
            feasts::STL(log(Trips), robust = TRUE), 
            fable::ETS(season_adjust)))
#> Warning: 1 error encountered for dcmp
#> [1] promise already under evaluation: recursive default argument reference or earlier problems?
#> Warning: 1 error encountered for stl
#> [1] Problem while computing `cmp = map(.fit, components)`.
#> Loading required namespace: crayon
#> # A mable: 14 x 4
#> # Key:     State, Purpose, Region [14]
#>    State           Purpose  Region                                       stl
#>    <chr*>          <chr*>   <chr*>                                   <model>
#>  1 New South Wales Business Blue Mountains         <STL decomposition model>
#>  2 New South Wales Business Capital Country        <STL decomposition model>
#>  3 New South Wales Business Central Coast                       <NULL model>
#>  4 New South Wales Business Central NSW            <STL decomposition model>
#>  5 New South Wales Business Hunter                 <STL decomposition model>
#>  6 New South Wales Business New England North West <STL decomposition model>
#>  7 New South Wales Business North Coast NSW        <STL decomposition model>
#>  8 New South Wales Business Outback NSW            <STL decomposition model>
#>  9 New South Wales Business Riverina               <STL decomposition model>
#> 10 New South Wales Business Snowy Mountains        <STL decomposition model>
#> 11 New South Wales Business South Coast            <STL decomposition model>
#> 12 New South Wales Business Sydney                 <STL decomposition model>
#> 13 New South Wales Business The Murray             <STL decomposition model>
#> 14 New South Wales Business <aggregated>           <STL decomposition model>

Создано 05 января 2023 г. с репрексом v2.0.2

Например, я мог бы захотеть просмотреть код, чтобы изучить «ошибки» / «предупреждения», или понять, почему «Центральное побережье» имеет модель NULL и т. д. Спасибо.

0 ответов

Другие вопросы по тегам