0
$\begingroup$

I am trying to understand how to "add" coherent distributions from reconciled probabilistic forecasts, assuming the base forecasts are normally distributed as discussed in https://otexts.com/fpp3/rec-prob.html.

library(fable)
library(tsibble)
library(dplyr)
library(lubridate)
library(tidyr)
library(purrr)

prison <- readr::read_csv("https://OTexts.com/fpp3/extrafiles/prison_population.csv") %>%
  mutate(Quarter = yearquarter(Date)) %>%
  select(-Date)  %>%
  as_tsibble(key = c(Gender, Legal, State, Indigenous), index = Quarter) %>%
  relocate(Quarter)

prison_gts <- prison %>%
              aggregate_key(Gender * Legal * State, Count = sum(Count)/1e3)

fit <- prison_gts %>%
       model(base = ETS(Count))

fc <- fit %>%
      reconcile(ols = min_trace(base, method = "ols")) %>%
      forecast(h = 8)

Initially, I expected the distributions to function like the coherent point forecasts below. Although, I believe it is more complex than simply adding normal distributions or adding the variances.

female <- fc %>%
   filter(.model == 'ols') %>%
   filter(Gender == 'Female') %>%
   filter(is_aggregated(Legal), is_aggregated(State))

male <- fc %>%
   filter(.model == 'ols') %>%
   filter(Gender == 'Male') %>%
   filter(is_aggregated(Legal), is_aggregated(State))

total <- fc %>%
   filter(.model == 'ols') %>%
   filter(is_aggregated(Gender), is_aggregated(Legal), is_aggregated(State))

# Successfully reconciled/coherent point forecasts
> female$.mean + male$.mean
40.08728 40.91325 41.18228 41.76685 42.32751 43.14612 43.38576 43.95771
> total$.mean
40.08728 40.91325 41.18228 41.76685 42.32751 43.14612 43.38576 43.95771

# Attempt to add distributions
> male$Count + female$Count
N(40, 0.042) N(41, 0.11)  N(41, 0.2)   N(42, 0.33)  N(42, 0.5)   N(43, 0.73)  N(43, 0.98)  N(44, 1.3)
> total$Count
N(40, 0.027) N(41, 0.071) N(41, 0.14)  N(42, 0.23)  N(42, 0.37)  N(43, 0.55)  N(43, 0.76)  N(44, 1) 

I suspect it has to do with the dependence between the series/ using covariances, although am not sure how to solve from there to see that the distributions are coherent. Any help would be much appreciated!

$\endgroup$
3
  • $\begingroup$ The equations are given here: robjhyndman.com/publications/coherentprob $\endgroup$ – Rob Hyndman Mar 15 at 21:14
  • $\begingroup$ Thank you so much for the quick response! Is this the equation you are referring to N (SGµˆ,SGΣˆ G'S')? Also, do you know if there's a function in fabletools to do this? If so, would you mind providing an example of how to use it? $\endgroup$ – Noah Sayre Mar 15 at 22:27
  • $\begingroup$ Yes. fable uses this equation when producing coherent normal distributions. There is an example here: otexts.com/fpp3/prison.html $\endgroup$ – Rob Hyndman Mar 16 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.