Skip to content

Commit

Permalink
reconc_gaussian: updated doc, added example on how to obtain reconcil…
Browse files Browse the repository at this point in the history
…ed samples by using the matrix S (issue #9)
  • Loading branch information
nicorbtt committed Nov 30, 2023
1 parent b0b9251 commit 53f8127
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
14 changes: 13 additions & 1 deletion R/reconc.R
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,17 @@ reconc_BUIS <- function(S,
#'
#' @details
#' The order of the base forecast means and covariance is given by the order of the time series in the summing matrix.
#'
#' The function returns only the reconciled parameters of the bottom variables.
#' The reconciled parameters for the upper variables or reconciled samples for the entire hierarchy can be obtained from these.
#' The Examples section shows how.
#'
#'
#' @return A list containing the bottom reconciled forecasts. The list has the following named elements:
#'
#' * `bottom_reconciled_mean`: reconciled mean for the bottom forecasts;
#' * `bottom_reconciled_covariance`: reconciled covariance for the bottom forecasts.
#'
#' How to obtain the reconciled upper parameters is shown in Examples.
#'
#' @examples
#'
Expand Down Expand Up @@ -433,6 +436,15 @@ reconc_BUIS <- function(S,
#'Y_mu_reconc <- S %*% bottom_mu_reconc
#'Y_Sigma_reconc <- S %*% bottom_Sigma_reconc %*% t(S) # note: singular matrix
#'
#'# Obtain reconciled samples for the entire hierarchy:
#'# i.e., sample from the reconciled bottoms and multiply by S
#'chol_decomp = chol(bottom_Sigma_reconc) # Compute the Cholesky Decomposition
#'Z = matrix(rnorm(n = 2000), nrow = 2) # Sample from standard normal
#'B = chol_decomp %*% Z + matrix(rep(bottom_mu_reconc, 1000), nrow=2) # Apply the transformation
#'
#'U = S %*% B
#'Y_reconc = rbind(U, B)
#'
#' @references
#' Corani, G., Azzimonti, D., Augusto, J.P.S.C., Zaffalon, M. (2021). *Probabilistic Reconciliation of Hierarchical Forecast via Bayes' Rule*. In: Hutter, F., Kersting, K., Lijffijt, J., Valera, I. (eds) Machine Learning and Knowledge Discovery in Databases. ECML PKDD 2020. Lecture Notes in Computer Science(), vol 12459. Springer, Cham. \doi{10.1007/978-3-030-67664-3_13}.
#'
Expand Down
15 changes: 13 additions & 2 deletions man/reconc_gaussian.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53f8127

Please sign in to comment.