tidyverts / tidyverts/fable

THETA model can not using bootstrap

Open
#428 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
R
Stars
588
Forks
71
Avg merge
1h 58m
Merged PRs (30d)
1

Description

I try to use the THETA model to forecast, according to the official example:

deaths |> model(theta = THETA(sqrt(value))) |> forecast(h = '4 years')
# A fable: 48 x 4 [1M]
# Key:     .model [1]
   .model    index          value  .mean
   <chr>     <mth>         <dist>  <dbl>
 1 theta  1979 Jan  t(N(91, 1.9))  8268.
 2 theta  1979 Feb  t(N(87, 2.5))  7504.
 3 theta  1979 Mar  t(N(91, 3.1))  8320.
 4 theta  1979 Apr  t(N(92, 3.7))  8552.
 5 theta  1979 May  t(N(97, 4.2))  9447.
 6 theta  1979 Jun  t(N(99, 4.8))  9869.
 7 theta  1979 Jul t(N(104, 5.4)) 10819.
 8 theta  1979 Aug   t(N(100, 6)) 10092.
 9 theta  1979 Sep  t(N(95, 6.5))  8947.
10 theta  1979 Oct  t(N(97, 7.1))  9333.
# ℹ 38 more rows
# ℹ Use `print(n = ...)` to see more rows

However, I encountered an error when I used the bootstrap method in forecast function:

deaths |> model(theta = THETA(sqrt(value))) |> forecast(h = '4 years', bootstrap = TRUE, times = 100)
Error in `mutate()`:
ℹ In argument: `theta = (function (object, ...) ...`.
Caused by error in `UseMethod()`:
! no applicable method for 'generate' applied to an object of class "fable_theta"
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/dplyr:::mutate_error>
Error in `mutate()`:
ℹ In argument: `theta = (function (object, ...) ...`.
Caused by error in `UseMethod()`:
! no applicable method for 'generate' applied to an object of class "fable_theta"
---
Backtrace:
     ▆
  1. ├─generics::forecast(...)
  2. ├─fabletools:::forecast.mdl_df(...)
  3. │ └─dplyr::mutate_at(...)
  4. │   ├─dplyr::mutate(.tbl, !!!funs)
  5. │   └─dplyr:::mutate.data.frame(.tbl, !!!funs)
  6. │     └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
  7. │       ├─base::withCallingHandlers(...)
  8. │       └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
  9. │         └─mask$eval_all_mutate(quo)
 10. │           └─dplyr (local) eval()
 11. ├─generics (local) `<fn>`(...)
 12. └─fabletools:::forecast.lst_mdl(...)
 13.   └─fabletools:::mapply_maybe_parallel(...)
 14.     └─base::mapply(FUN = .fp, ..., MoreArgs = MoreArgs, SIMPLIFY = SIMPLIFY)
 15.       └─fabletools (local) `<fn>`(...)
 16.         ├─generics (local) .f(...)
 17.         └─fabletools:::forecast.mdl_ts(...)
 18.           ├─generics::generate(...)
 19.           └─fabletools:::generate.mdl_ts(...)
 20.             └─generics::generate(...)
Run rlang::last_trace(drop = FALSE) to see 3 hidden frames.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the THETA model and forecast(..., bootstrap = TRUE, times = 100) example in the issue. Start by tracing forecast.mdl_ts through generate.mdl_ts and the generate dispatch for the fable_theta object. Done means bootstrap forecasting works for this model without the generate method error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.