-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can reconcile() be used for distributional forecasts #334
Comments
Almost. You need to remove the total column and set up the data as a tsibble with state as the key. Then generate the total using The distributions are reconciled as described here: https://otexts.com/fpp3/rec-prob.html |
Thanks for the quick response! I think I see where I am getting hung up. I am starting with the output from probabilistic forecasts (downstream from where the example starts). It looks like the fit <- prison_gts %>%
filter(year(Quarter) <= 2014) %>%
model(base = ETS(Count)) %>%
reconcile(
bottom_up = bottom_up(base), # <--- needs a mable object
MinT = min_trace(base, method = "mint_shrink")
) This is as far as I can get df <- readr::read_csv("https://storage.googleapis.com/data_xvzf/m5_hierarchical_forecast.csv") %>%
select(-y_sim_total) %>%
pivot_longer(cols = y_sim_ca:y_sim_wi, names_to = "state", values_to = "y_sim") %>%
as_tsibble(index = ds, key = c(rep, state)) %>%
aggregate_key(total = mean(y_sim)) %>%
reconcile(
bottom_up = bottom_up(), # <-- missing a mable object
MinT = min_trace(method = "mint_shrink")
) |
Currently At minimum, you'll need to convert your samples into a distribution using From there you can achieve bottom up reconciliation by summing the distribution column in |
I see what you are saying. Thanks for the info! |
Thanks again for the help. I just wanted to codify what you said above. This is where things are at the moment. df <- readr::read_csv("https://storage.googleapis.com/data_xvzf/m5_hierarchical_forecast.csv") %>%
dplyr::select(-y_sim_total) %>%
tidyr::pivot_longer(cols = y_sim_ca:y_sim_wi, names_to = "state", values_to = "y_sim") %>%
dplyr::group_by(ds, state) %>%
dplyr::summarise(dist = distributional::dist_sample(list(y_sim))) %>%
as_tsibble(index=ds, key = state) %>%
aggregate_key(total = sum(dist)) # <- error (I am not sure what to put here when my column is a dist object) |
I would like to know if
reconcile()
can be used with distributional forecasts.As a reproducible example I took the m5 data and generated naive forecasts for
total
,ca
,wi
, andtx
. The total is the sum of the three states. I generated 8000 samples over a 10 day forecast horizon. The data set can be grabbed with the following.This is the head
Can I use the
reconcile()
function to reconcile these forecasts to the total?The text was updated successfully, but these errors were encountered: