Skip to content

THETA model can not using bootstrap #428

@xmusphlkg

Description

@xmusphlkg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions