reconc_TDcond {bayesRecon}R Documentation

Probabilistic forecast reconciliation of mixed hierarchies via top-down conditioning

Description

Uses the top-down conditioning algorithm to draw samples from the reconciled forecast distribution. Reconciliation is performed in two steps: first, the upper base forecasts are reconciled via conditioning, using only the hierarchical constraints between the upper variables; then, the bottom distributions are updated via a probabilistic top-down procedure.

Usage

reconc_TDcond(
  S,
  fc_bottom,
  fc_upper,
  bottom_in_type = "pmf",
  distr = NULL,
  num_samples = 20000,
  return_type = "pmf",
  suppress_warnings = FALSE,
  seed = NULL
)

Arguments

S

Summing matrix (n x n_bottom).

fc_bottom

A list containing the bottom base forecasts, see details.

fc_upper

A list containing the upper base forecasts, see details.

bottom_in_type

A string with three possible values:

  • 'pmf' if the bottom base forecasts are in the form of pmf, see details;

  • 'samples' if the bottom base forecasts are in the form of samples;

  • 'params' if the bottom base forecasts are in the form of estimated parameters.

distr

A string describing the type of bottom base forecasts ('poisson' or 'nbinom').

This is only used if bottom_in_type=='params'.

num_samples

Number of samples drawn from the reconciled distribution. This is ignored if bottom_in_type='samples'; in this case, the number of reconciled samples is equal to the number of samples of the base forecasts.

return_type

The return type of the reconciled distributions. A string with three possible values:

  • 'pmf' returns a list containing the reconciled marginal pmf objects;

  • 'samples' returns a list containing the reconciled multivariate samples;

  • 'all' returns a list with both pmf objects and samples.

suppress_warnings

Logical. If TRUE, no warnings about samples are triggered. If FALSE, warnings are generated. Default is FALSE. See Details.

seed

Seed for reproducibility.

Details

The base bottom forecasts fc_bottom must be a list of length n_bottom, where each element is either

The base upper forecasts fc_upper must be a list containing the parameters of the multivariate Gaussian distribution of the upper forecasts. The list must contain only the named elements mu (vector of length n_upper) and Sigma (n_upper x n_upper matrix)

A PMF object is a numerical vector containing the probability mass function of a discrete distribution. Each element corresponds to the probability of the integers from 0 to the last value of the support. See also PMF.get_mean, PMF.get_var, PMF.sample, PMF.get_quantile, PMF.summary for functions that handle PMF objects.

If some of the reconciled upper samples lie outside the support of the bottom-up distribution, those samples are discarded and a warning is triggered. The warning reports the percentage of samples kept.

Value

A list containing the reconciled forecasts. The list has the following named elements:

References

Corani, G., Azzimonti, D., Augusto, J.P.S.C., Zaffalon, M. (2021). Probabilistic Reconciliation of Hierarchical Forecast via Bayes' Rule. ECML PKDD 2020. Lecture Notes in Computer Science, vol 12459. doi:10.1007/978-3-030-67664-3_13.

Zambon, L., Agosto, A., Giudici, P., Corani, G. (2024). Properties of the reconciled distributions for Gaussian and count forecasts. International Journal of Forecasting (in press). doi:10.1016/j.ijforecast.2023.12.004.

Zambon, L., Azzimonti, D., Rubattu, N., Corani, G. (2024). Probabilistic reconciliation of mixed-type hierarchical time series. The 40th Conference on Uncertainty in Artificial Intelligence, accepted.

See Also

reconc_MixCond(), reconc_BUIS()

Examples


library(bayesRecon)

# Consider a simple hierarchy with two bottom and one upper
A <- matrix(c(1,1),nrow=1)
S <- rbind(A,diag(nrow=2))
# The bottom forecasts are Poisson with lambda=15
lambda <- 15
n_tot <- 60
fc_bottom <- list()
fc_bottom[[1]] <- apply(matrix(seq(0,n_tot)),MARGIN=1,FUN=function(x) dpois(x,lambda=lambda))
fc_bottom[[2]] <- apply(matrix(seq(0,n_tot)),MARGIN=1,FUN=function(x) dpois(x,lambda=lambda))

# The upper forecast is a Normal with mean 40 and std 5
fc_upper<- list(mu=40, Sigma=matrix(c(5^2)))

# We can reconcile with reconc_TDcond
res.TDcond <- reconc_TDcond(S, fc_bottom, fc_upper)

# Note that the bottom distributions are shifted to the right
PMF.summary(res.TDcond$bottom_reconciled$pmf[[1]])
PMF.summary(fc_bottom[[1]])

PMF.summary(res.TDcond$bottom_reconciled$pmf[[2]])
PMF.summary(fc_bottom[[2]])

# The upper distribution remains similar
PMF.summary(res.TDcond$upper_reconciled$pmf[[1]])
PMF.get_var(res.TDcond$upper_reconciled$pmf[[1]])


[Package bayesRecon version 0.3.0 Index]