robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.1k stars 340 forks source link

Added faster and better hfitted method for ETS model #950

Closed mitchelloharawild closed 4 months ago

mitchelloharawild commented 6 months ago

Much like #949, I have a faster version of multi-step fitted values for ETS which I have incorporated here. It additionally uses the initial states to produce a h-step fit at time h-1.

devtools::load_all("~/github/forecast/")
#> ℹ Loading forecast
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo
fit <- ets(USAccDeaths)
bench::mark(
  forecast:::hfitted.default(fit, 4),
  hfitted(fit, 4),
  check = FALSE
)
#> # A tibble: 2 × 6
#>   expression                           min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                      <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 forecast:::hfitted.default(fit… 106.88ms 106.88ms      9.36    6.23MB     37.4
#> 2 hfitted(fit, 4)                   1.15ms   1.23ms    769.        624B     13.0

Created on 2023-12-27 with reprex v2.0.2