tidyverts / fabletools

General fable features useful for extension packages
http://fabletools.tidyverts.org/
89 stars 31 forks source link

add reconciliation with immutable forecasts #353

Open AngelPone opened 2 years ago

AngelPone commented 2 years ago

see https://github.com/tidyverts/fabletools/issues/352. I implemented the immutability method only for sparse=TRUE for now.

examples:

tourism_full <- tsibble::tourism %>%
  aggregate_key((State/Region) * Purpose, Trips = sum(Trips))
fit <- tourism_full %>%
  filter(year(Quarter) <= 2015) %>%
  model(base = fable::ARIMA(Trips))
fit <- reconcile(
  fit,
  ols_td = min_trace(base, method = "ols", 
                    immu = is_aggregated(State) & is_aggregated(Purpose)),
  ols_purpose_mo = min_trace(base, method = "ols", 
                             immu = is_aggregated(State) & !is_aggregated(Purpose)),
  ols_state_mo = min_trace(base, method = "ols", 
                           immu = !is_aggregated(State) & is_aggregated(Purpose) & is_aggregated(Region))
)
mitchelloharawild commented 2 years ago

Looks great and simple, thanks! I'll use this code and rework it into a more general nicer interface for reconciliation. Could you add yourself as ctb for this package, and provide a NEWS entry that summarises this change?