Skip to content

Error in ETS forecast #425

@robjhyndman

Description

@robjhyndman

As reported at https://github.com/orgs/OTexts/discussions/31

library(fpp3)
#> Registered S3 method overwritten by 'tsibble':
#>   method               from 
#>   as_tibble.grouped_df dplyr
#> ── Attaching packages ──────────────────────────────────────────── fpp3 1.0.1 ──
#> ✔ tibble      3.2.1     ✔ tsibble     1.1.6
#> ✔ dplyr       1.1.4     ✔ tsibbledata 0.4.1
#> ✔ tidyr       1.3.1     ✔ feasts      0.4.1
#> ✔ lubridate   1.9.4     ✔ fable       0.4.1
#> ✔ ggplot2     3.5.2
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> ✖ lubridate::date()    masks base::date()
#> ✖ dplyr::filter()      masks stats::filter()
#> ✖ tsibble::intersect() masks base::intersect()
#> ✖ tsibble::interval()  masks lubridate::interval()
#> ✖ dplyr::lag()         masks stats::lag()
#> ✖ tsibble::setdiff()   masks base::setdiff()
#> ✖ tsibble::union()     masks base::union()

train <- data.frame(
    YM = seq(yearmonth(ymd("20220101")), yearmonth(ymd("20241201")), by = 1),
    value = c(rep(-78040, 11), -78061, rep(-78040, 11), -78061, rep(-78040, 11), -78061)
) %>% 
    as_tsibble(index = YM)

fit <- train %>%
    model(ETS(value))

fit %>%
    forecast(h = 12)  # Error
#> Error in `mutate()`:
#> ℹ In argument: `ETS(value) = (function (object, ...) ...`.
#> Caused by error in `[<-`:
#> ! only 0's may be mixed with negative subscripts

Created on 2025-05-20 with reprex v2.1.1

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