Open mitchelloharawild opened 2 years ago
I'm encountering this problem even with @robjhyndman's example code provided above (via https://github.com/earowang/hts/issues/43#issuecomment-1139303691).
I've tried downgrading from fabletools 0.3.3.900 to 0.3.3 and get the same error.
library(dplyr , quietly = TRUE)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tsibble, quietly = TRUE)
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, union
library(fable , quietly = TRUE)
tsibble::tourism %>%
filter(State == 'ACT') %>%
aggregate_key(State / Region, Trips = sum(Trips)) %>%
model(base = fable::SNAIVE(Trips)) %>%
reconcile(mint_cov = min_trace(base, method = "mint_cov")) %>%
forecast(h = 1)
#> Error in `mutate()`:
#> ℹ In argument: `mint_cov = (function (object, ...) ...`.
#> Caused by error:
#> ! min_trace needs covariance matrix to be positive definite.
#> Backtrace:
#> ▆
#> 1. ├─... %>% forecast(h = 1)
#> 2. ├─generics::forecast(., h = 1)
#> 3. ├─fabletools:::forecast.mdl_df(., h = 1)
#> 4. │ └─dplyr::mutate_at(...)
#> 5. │ ├─dplyr::mutate(.tbl, !!!funs)
#> 6. │ └─dplyr:::mutate.data.frame(.tbl, !!!funs)
#> 7. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
#> 8. │ ├─base::withCallingHandlers(...)
#> 9. │ └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
#> 10. │ └─mask$eval_all_mutate(quo)
#> 11. │ └─dplyr (local) eval()
#> 12. ├─generics (local) `<fn>`(...)
#> 13. └─fabletools:::forecast.lst_mint_mdl(...)
#> 14. └─rlang::abort(...)
Created on 2023-06-09 with reprex v2.0.2
I tried running some code from fpp chapter 11.4 - it worked as expected without error. No idea what's going on here...
library(fpp3)
#> ── Attaching packages ────────────────────────────────────────────── fpp3 0.5 ──
#> ✔ tibble 3.1.8 ✔ tsibble 1.1.3
#> ✔ dplyr 1.1.0 ✔ tsibbledata 0.4.1
#> ✔ tidyr 1.3.0 ✔ feasts 0.3.0
#> ✔ lubridate 1.9.2 ✔ fable 0.3.3
#> ✔ ggplot2 3.4.2 ✔ fabletools 0.3.3
#> ── 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()
tourism_full <- tourism |>
aggregate_key((State/Region) * Purpose, Trips = sum(Trips))
fit <- tourism_full |>
filter(year(Quarter) <= 2015) |>
model(base = ETS(Trips)) |>
reconcile(
bu = bottom_up(base),
ols = min_trace(base, method = "ols"),
mint = min_trace(base, method = "mint_shrink")
)
fc <- fit |>
forecast(h = "2 years")
fc |>
filter(is_aggregated(Region), is_aggregated(Purpose)) |>
autoplot(
tourism_full |> filter(year(Quarter) >= 2011),
level = NULL
) +
labs(y = "Trips ('000)") +
facet_wrap(vars(State), scales = "free_y")
Created on 2023-06-09 with reprex v2.0.2
From https://github.com/earowang/hts/issues/43#issuecomment-1139303691