Internal function that performs the core reconciliation logic using top-down conditioning (TD) for mixed hierarchies. First, upper forecasts are reconciled analytically via conditioning (if necessary), then bottom distributions are updated through probabilistic top-down procedure by conditioning on the reconciled upper values.
.core_reconc_TDcond(
A,
mean_upper,
cov_upper,
L_pmf,
num_samples,
return_type,
return_upper = TRUE,
suppress_warnings = TRUE,
min_fraction_samples_ok = .MIN_FRACTION_SAMPLES_OK
)A list containing:
bottom_rec_pmf: list of PMF objects for each bottom series (only if return_type is 'pmf' or 'all').
bottom_rec_samples: matrix (n_bottom x num_samples) of reconciled bottom samples (only if return_type is 'samples' or 'all').
upper_rec_pmf: list of PMF objects for each upper series (only if return_type is 'pmf' or 'all', and return_upper = TRUE).
upper_rec_samples: matrix (n_upper x num_samples) of reconciled upper samples (only if return_type is 'samples' or 'all', and return_upper = TRUE).
Matrix (n_upper x n_bottom) defining the hierarchy where upper = A %*% bottom.
Vector of mean forecasts for upper level.
Covariance matrix of upper level forecasts.
List of PMF objects representing the bottom level base forecasts.
Number of samples to draw from the reconciled distribution.
Character string specifying return format: 'pmf', 'samples', or 'all'.
Logical, whether to return reconciled upper forecasts (default TRUE).
Logical, whether to suppress warnings about samples outside support (default TRUE).
Numeric between 0 and 1, minimum fraction of reconciled upper samples that must lie in the support of the bottom-up distribution (default 0.5). If the fraction is below this threshold, the function returns an error.
The function internally:
Identifies the "lowest upper" nodes in the hierarchy.
If all uppers are lowest-uppers, samples directly from the upper MVN. Otherwise, analytically reconciles the upper hierarchy and samples from the lowest level.
Reconciles bottom distributions by conditioning on the sampled/reconciled upper values using the probabilistic top-down algorithm.
Discards samples that fall outside the support of the bottom-up distribution.