Skip to content

Commit

Permalink
Changed naming of matrix A to use "aggregation matrix" everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
dazzimonti committed Aug 28, 2024
1 parent df536b7 commit 2e9e145
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bayesRecon 0.3.1

* IMPORTANT CHANGE IN THE API OF THE `reconc_*` functions: they now require the aggregating matrix A and not the summing matrix S.
* IMPORTANT CHANGE IN THE API OF THE `reconc_*` functions: they now require the aggregation matrix A and not the summing matrix S.

* The examples section of the `reconc_TDcond` now contains an example showing how to handle the case of an unbalanced hierarchy.

Expand Down
2 changes: 1 addition & 1 deletion R/hierarchy.R
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ get_reconc_matrices <- function(agg_levels, h) {
}


# Get the aggregating matrix Au of the sub-hierarchy composed just by the uppers
# Get the aggregation matrix Au of the sub-hierarchy composed just by the uppers
.get_Au <- function(A, lowest_rows=NULL) {

if (is.null(lowest_rows)) lowest_rows = .lowest_lev(A)
Expand Down
2 changes: 1 addition & 1 deletion R/reconc_MCMC.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ reconc_MCMC <- function(A,
# @title Compute acceptance probability
# @param b proposal state
# @param b0 current state
# @param A aggregating matrix
# @param A aggregation matrix
# @param distr list of strings specifying the distribution of each variable
# @param params list of the parameters of the distributions
# @return the acceptance probability alpha
Expand Down
2 changes: 1 addition & 1 deletion R/reconc_TDcond.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
#' 5, 0, 0, var_b5), nrow=4, byrow = TRUE)
#' fc_upper<- list(mu=mu, Sigma=Sigma)
#'
#' # We also need to update the aggregating matrix
#' # We also need to update the aggregation matrix
#' A <- matrix(c(1,1,1,1,1,
#' 1,1,0,0,0,
#' 0,0,1,1,0,
Expand Down
2 changes: 1 addition & 1 deletion man/reconc_TDcond.Rd

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

12 changes: 6 additions & 6 deletions vignettes/bayesRecon.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ for (l in seq_along(train.agg)) {
```


Reconciliation requires the aggregating matrix $\mathbf{A}$, which we obtain using the function `get_reconc_matrices`.
Reconciliation requires the aggregation matrix $\mathbf{A}$, which we obtain using the function `get_reconc_matrices`.
It requires:

* the aggregation factors of the hierarchy, which in this example are $\{2, 3, 4, 6, 12\}$;
* the length of the forecasting horizon at the bottom level, which is 12 in this example.

``` {r aggregatingMatrix}
``` {r aggregationMatrix}
recon.matrices <- bayesRecon::get_reconc_matrices(agg_levels = c(2, 3, 4, 6, 12), h = 12)
# Aggregating matrix
# Aggregation matrix
A <- recon.matrices$A
```

Expand Down Expand Up @@ -279,7 +279,7 @@ for (level in train.agg) {

Using the function `get_reconc_matrices`, we get matrix $\mathbf{A}$.

```{r m3-rmat, dpi=300, out.width = '70%', fig.align='center', fig.cap="**Figure 4**: M3 - The aggregating matrix A (red=1, yellow=0).", fig.dim = c(8, 8)}
```{r m3-rmat, dpi=300, out.width = '70%', fig.align='center', fig.cap="**Figure 4**: M3 - The aggregation matrix A (red=1, yellow=0).", fig.dim = c(8, 8)}
rmat <- get_reconc_matrices(agg_levels = c(2, 3, 4, 6, 12), h = 18)
par(mai = c(1,1,0.5,0.5))
Expand Down Expand Up @@ -392,7 +392,7 @@ for (s in infantMortality) {

Now we build the $\mathbf{A}$ matrix.

```{r infants-s, dpi=300, out.width = '70%', fig.align='center', fig.cap="**Figure 6**: Infants mortality - The aggregating matrix A (red=1, yellow=0).", fig.dim = c(8, 8)}
```{r infants-s, dpi=300, out.width = '70%', fig.align='center', fig.cap="**Figure 6**: Infants mortality - The aggregation matrix A (red=1, yellow=0).", fig.dim = c(8, 8)}
# we have 16 bottom time series, and 11 upper time series
A <- matrix(data = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Expand Down Expand Up @@ -444,4 +444,4 @@ upper_mu_reconc
```

# References
<div id="refs"></div>
<div id="refs"></div>
2 changes: 1 addition & 1 deletion vignettes/reconciliation_properties.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ n_b <- 5
n_u <- 1
n <- n_b + n_u
A <- matrix(1, ncol = n_b, nrow = n_u) # aggregating matrix
A <- matrix(1, ncol = n_b, nrow = n_u) # aggregation matrix
# Actual values:
actuals <- data.frame(extr_mkt_events) # convert to data frame
Expand Down

0 comments on commit 2e9e145

Please sign in to comment.