Skip to content

Commit ae7d7d0

Browse files
committed
Updated caption of figures in vignettes.
1 parent d327985 commit ae7d7d0

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
^\./tests/testthat/dataForTests/generate_weeklyTestData\.R$
1414
^bayesRecon\.Rproj$
1515
^tests/testthat/dataForTests/generate_monthlyCountData\.R$
16+
^_pkgdown\.yml$
17+
^docs$
18+
^pkgdown$

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
inst/doc
88
/doc/
99
/Meta/
10+
docs

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ Suggests:
5252
testthat (>= 3.0.0)
5353
Config/testthat/edition: 3
5454
VignetteBuilder: knitr
55-
URL: https://github.com/IDSIA/bayesRecon
55+
URL: https://github.com/IDSIA/bayesRecon, https://idsia.github.io/bayesRecon/
5656
BugReports: https://github.com/IDSIA/bayesRecon/issues

vignettes/mixed_reconciliation.Rmd

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ Sect. 5 of the paper presents the results for 10 stores, each reconciled
3737
The M5 competition [@MAKRIDAKIS20221325] is about daily time series of sales data referring to 10 different stores.
3838
Each store has the same hierarchy: 3049 bottom time series (single items) and 11 upper time series, obtained by aggregating the items by department, product category, and store; see the figure below.
3939

40-
```{r out.width = '100%', echo = FALSE}
40+
```{r M5hier, fig.cap="**Figure 1**: graph of the M5 hierarchy.", out.width = '100%', echo = FALSE}
4141
knitr::include_graphics("img/M5store_hier.png")
4242
```
4343

4444
We reproduce the results of the store "CA_1". The base forecasts (for h=1) of the bottom and upper time series are stored in `M5_CA1_basefc`, available as data in the package.
4545
The base forecast are computed using ADAM [@svetunkov2023iets], implemented in the R package smooth [@smooth_pkg].
4646

4747

48-
```{r}
48+
```{r InitializeHierarchy}
4949
# Hierarchy composed by 3060 time series: 3049 bottom and 11 upper
5050
n_b <- 3049
5151
n_u <- 11
@@ -74,7 +74,7 @@ It assumes all forecasts to be Gaussian, even though the bottom base forecasts
7474
We assume the upper base forecasts to be a multivariate Gaussian and we estimate their covariance matrix from the in-sample residuals. We assume also the bottom base forecasts to be independent Gaussians.
7575

7676

77-
```{r}
77+
```{r readBaseForecasts}
7878
# Parameters of the upper base forecast distributions
7979
mu_u <- unlist(lapply(base_fc_upper, "[[", "mu")) # upper means
8080
# Compute the (shrinked) covariance matrix of the residuals
@@ -107,7 +107,7 @@ We reconcile using the function `reconc_gaussian()`, which takes as input:
107107

108108
The function returns the reconciled mean and covariance for the bottom time series.
109109

110-
```{r}
110+
```{r GaussianReconciliation}
111111
# Gaussian reconciliation
112112
start <- Sys.time()
113113
gauss <- reconc_gaussian(A, base_forecasts.mu, base_forecasts.Sigma)
@@ -136,7 +136,7 @@ The algorithm is implemented in the function `reconc_MixCond()`. The function ta
136136

137137
The function returns the reconciled forecasts in the form of probability mass functions for both the upper and bottom time series. The function parameter `return_type` can be changed to `samples` or `all` to obtain the IS samples.
138138

139-
```{r}
139+
```{r MixedCondReconciliation}
140140
seed <- 1
141141
N_samples_IS <- 5e4
142142
@@ -169,7 +169,7 @@ Moreover, forecasts for count time series are usually biased and their sum tends
169169
Top down conditioning (TD-cond; see @zambon2024mixed, Sect. 4) is a more reliable approach for reconciling mixed variables in high dimensions.
170170
The algorithm is implemented in the function `reconc_TDcond()`; it takes the same arguments as `reconc_MixCond()` and returns reconciled forecasts in the same format.
171171

172-
```{r}
172+
```{r TDcondReconciliation}
173173
N_samples_TD <- 1e4
174174
175175
# TDcond reconciliation
@@ -182,7 +182,7 @@ stop <- Sys.time()
182182
The algorithm TD-cond raises a warning regarding the incoherence between the joint bottom-up and the upper base forecasts.
183183
We will see that this warning does not impact the performances of TD-cond.
184184

185-
```{r}
185+
```{r print computational time TD cond}
186186
rec_fc$TD_cond <- list(
187187
bottom = td$bottom_reconciled$pmf,
188188
upper = td$upper_reconciled$pmf
@@ -206,7 +206,7 @@ For each time series in the hierarchy, we compute the following scores for each
206206

207207
- RPS: Ranked Probability Score
208208

209-
```{r}
209+
```{r InitializeMetrics}
210210
# Parameters for computing the scores
211211
alpha <- 0.1 # MIS uses 90% coverage intervals
212212
jitt <- 1e-9 # jitter for numerical stability
@@ -236,7 +236,7 @@ The following functions are used for computing the scores:
236236

237237
The implementation of these functions is available in the source code of the vignette but not shown here.
238238

239-
```{r,include=FALSE}
239+
```{r metricFunctions,include=FALSE}
240240
# Functions for computing the scores of a PMF
241241
AE_pmf <- function(pmf, actual) {
242242
return(abs(PMF.get_quantile(pmf,p=0.5) - actual))
@@ -278,7 +278,7 @@ MIS_gauss <- function(mus, sds, actuals, alpha, trunc=FALSE) {
278278

279279

280280

281-
```{r}
281+
```{r computeScores}
282282
# Compute scores for the base forecasts
283283
# Upper
284284
mu_u <- unlist(lapply(base_fc_upper, "[[", "mu"))
@@ -324,7 +324,7 @@ $$ \text{Skill}_{\%}\,(\text{RPS, }Gauss) = 100 \cdot
324324

325325
This formula is implemented in the function `skill.score`, available in the source code of the vignette but not shown here.
326326

327-
```{r,include=FALSE}
327+
```{r skillScoreFunction,include=FALSE}
328328
# Function for computing the skill score
329329
skill.score <- function(ref, met) {
330330
s <- (2 * (ref - met) / (ref + met)) * 100
@@ -334,7 +334,7 @@ skill.score <- function(ref, met) {
334334
```
335335

336336

337-
```{r}
337+
```{r ComputeScores}
338338
scores <- list(
339339
mase = mase,
340340
mis = mis,
@@ -361,7 +361,7 @@ for (s in scores_) {
361361
We report in the tables below the mean values for each skill score.
362362

363363

364-
```{r}
364+
```{r AverageScores}
365365
mean_skill_scores <- list()
366366
367367
for (s in scores_) {
@@ -372,17 +372,17 @@ for (s in scores_) {
372372
}
373373
```
374374

375-
```{r}
375+
```{r printMASETable}
376376
knitr::kable(mean_skill_scores$mase,digits = 2,caption = "Mean skill score on MASE.",align = 'lccc')
377377
```
378378
The mean MASE skill score is positive only for the TD-cond reconciliation. Both Mix-cond and Gauss achieve scores lower than the base forecasts, even if Mix-cond degrades less the base forecasts compared to Gauss.
379379

380-
```{r}
380+
```{r PrintMIStable}
381381
knitr::kable(mean_skill_scores$mis,digits = 2,caption = "Mean skill score on MIS.")
382382
```
383383
The mean MIS score of TD-cond is slightly above that of the base forecasts. Mix-cond achieves slightly higher scores than the base forecasts only on the bottom variables. Gauss strongly degrades the base forecasts according to this metric.
384384

385-
```{r}
385+
```{r printRPStable}
386386
knitr::kable(mean_skill_scores$rps,digits = 2,caption = "Mean skill score on RPS.")
387387
```
388388
The mean RPS skill score for TD-cond is positive for both upper and bottom time series. Mix-cond slightly improves the base forecasts on the bottom variables, however it degrades the upper base forecasts. Gauss strongly degrades both upper and bottom base forecasts.
@@ -391,7 +391,7 @@ The mean RPS skill score for TD-cond is positive for both upper and bottom time
391391

392392
Finally, we show the boxplots of the skill scores for each method divided in upper and bottom levels.
393393

394-
```{r,fig.width=7,fig.height=8}
394+
```{r MASEboxplots, fig.cap="**Figure 2**: boxplot of MASE skill scores for upper and bottom time series.", fig.width=7,fig.height=8}
395395
custom_colors <- c("#a8a8e4",
396396
"#a9c7e4",
397397
"#aae4df")
@@ -405,13 +405,13 @@ boxplot(skill_scores$mase$bottom, main = "MASE bottom time series",
405405
col = custom_colors, ylim = c(-200,200))
406406
abline(h=0,lty=3)
407407
```
408-
```{r,eval=TRUE,include=FALSE}
408+
```{r setupParams,eval=TRUE,include=FALSE}
409409
par(mfrow = c(1, 1))
410410
```
411411

412412
Both Mix-cond and TD-cond do not improve the bottom MASE over the base forecasts (boxplot flattened on the value zero), however TD-cond provides a slight improvement over the upper base forecasts (boxplot over the zero line).
413413

414-
```{r,fig.width=7,fig.height=8}
414+
```{r MISboxplots, fig.cap="**Figure 3**: boxplot of MIS skill scores for upper and bottom time series.", fig.width=7,fig.height=8}
415415
# Boxplots of MIS skill scores
416416
par(mfrow = c(2, 1))
417417
boxplot(skill_scores$mis$upper, main = "MIS upper time series",
@@ -428,7 +428,7 @@ par(mfrow = c(1, 1))
428428
Both Mix-cond and TD-cond do not improve nor degrade the bottom base forecasts in MIS score as shown by the small boxplots centered around zero. On the upper variables instead only TD-cond does not degrade the MIS score of the base forecasts.
429429

430430

431-
```{r,fig.width=7,fig.height=8}
431+
```{r RPSboxplots,fig.cap="**Figure 4**: boxplot of RPS skill scores for upper and bottom time series.", fig.width=7,fig.height=8}
432432
# Boxplots of RPS skill scores
433433
par(mfrow = c(2,1))
434434
boxplot(skill_scores$rps$upper, main = "RPS upper time series",

vignettes/reconciliation_properties.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The hierarchy is composed of 5 bottom time series, the daily number of extreme m
4444
events in each sector, and 1 upper time series (the sum of the different sectors).
4545
Data are stored in `extr_mkt_events`.
4646

47-
```{r out.width = '50%', echo = FALSE}
47+
```{r finTShier, fig.cap="**Figure 1**: financial time series hierarchy.", out.width = '80%', echo = FALSE}
4848
knitr::include_graphics("img/finTS_hier.jpg")
4949
```
5050

0 commit comments

Comments
 (0)