Closed robjhyndman closed 3 years ago
Here is a simpler MRE
library(fpp3)
#> ── Attaching packages ─────────────────────────────────────── fpp3 0.3.0.9000 ──
#> ✓ tibble 3.0.5 ✓ tsibble 0.9.3
#> ✓ dplyr 1.0.3 ✓ tsibbledata 0.2.0
#> ✓ tidyr 1.1.2 ✓ feasts 0.1.6.9000
#> ✓ lubridate 1.7.9.2 ✓ fable 0.2.1.9000
#> ✓ ggplot2 3.3.3
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> x lubridate::date() masks base::date()
#> x dplyr::filter() masks stats::filter()
#> x tsibble::interval() masks lubridate::interval()
#> x dplyr::lag() masks stats::lag()
PBS %>%
filter(ATC2 == "A15", Concession != "Concessional") %>%
aggregate_key(Type, Scripts = sum(Scripts)) %>%
fill_gaps(Scripts=0) %>%
model(ets = ETS(Scripts)) %>%
reconcile(ets2 = min_trace(etsmodel)) %>%
forecast(h = 1)
#> Error: Problem with `mutate()` input `ets2`.
#> x object 'etsmodel' not found
#> ℹ Input `ets2` is `min_trace(etsmodel)`.
Created on 2021-02-02 by the reprex package (v1.0.0)
Silly issue, should be fixed now. The problem arises with ATC1=="A"
as some series are incomplete.
Second MRE appears to be a different issue.
Second issue from MRE: min_trace(etsmodel)
should be min_trace(ets)
library(fpp3)
#> ── Attaching packages ─────────────────────────────────────── fpp3 0.3.0.9000 ──
#> ✓ tibble 3.0.5 ✓ tsibble 0.9.4
#> ✓ dplyr 1.0.3 ✓ tsibbledata 0.2.0
#> ✓ tidyr 1.1.2 ✓ feasts 0.1.6.9000
#> ✓ lubridate 1.7.9.2 ✓ fable 0.2.1.9000
#> ✓ ggplot2 3.3.3
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> x lubridate::date() masks base::date()
#> x dplyr::filter() masks stats::filter()
#> x tsibble::intersect() masks base::intersect()
#> x tsibble::interval() masks lubridate::interval()
#> x dplyr::lag() masks stats::lag()
#> x tsibble::setdiff() masks base::setdiff()
#> x tsibble::union() masks base::union()
PBS %>%
filter(ATC2 == "A15", Concession != "Concessional") %>%
aggregate_key(Type, Scripts = sum(Scripts)) %>%
fill_gaps(Scripts=0) %>%
model(ets = ETS(Scripts)) %>%
reconcile(ets2 = min_trace(ets)) ->fit
fit %>%
forecast(h = 1)
#> # A fable: 6 x 5 [1M]
#> # Key: Type, .model [6]
#> Type .model Month Scripts .mean
#> <chr*> <chr> <mth> <dist> <dbl>
#> 1 Co-payments ets 2008 Jul N(0.077, 0.12) 0.0766
#> 2 Co-payments ets2 2008 Jul N(0.079, 0.12) 0.0788
#> 3 Safety net ets 2008 Jul N(-0.97, 35) -0.973
#> 4 Safety net ets2 2008 Jul N(-0.43, 17) -0.432
#> 5 <aggregated> ets 2008 Jul N(0.19, 34) 0.190
#> 6 <aggregated> ets2 2008 Jul N(-0.35, 17) -0.353
Created on 2021-02-02 by the reprex package (v0.3.0)
I'm not sure what is happening here. I've narrowed it down to
ATC1=="A"
but not which series is causing the problem.Created on 2021-02-01 by the reprex package (v1.0.0)