| csboot | R Documentation |
Joint block bootstrap for generating probabilistic base forecasts that take into account the correlation between different time series (Panagiotelis et al. 2023).
csboot(model_list, boot_size, block_size, seed = NULL, xreg = NULL, ...)
model_list |
A list of all the |
boot_size |
The number of bootstrap replicates. |
block_size |
Block size of the bootstrap, which is typically equivalent to the forecast horizon. |
seed |
An integer seed. |
xreg |
An optional 3-d numeric array of dimensions
( |
... |
Additional arguments for the |
A 3-d array (\text{block\_size} \times n \times \text{boot\_size}).
Panagiotelis, A., Gamakumara, P., Athanasopoulos, G. and Hyndman, R.J. (2023), Probabilistic forecast reconciliation: Properties, evaluation and score optimisation, European Journal of Operational Research, 306(2), 693–706. \Sexpr[results=rd]{tools:::Rd_expr_doi("http://dx.doi.org/10.1016/j.ejor.2022.07.040")}
Bootstrap samples:
ctboot(),
teboot()
Cross-sectional framework:
csbu(),
cscov(),
cslcc(),
csmo(),
csmvn(),
csrec(),
cssmp(),
cstd(),
cstools()
set.seed(123)
# Minimal example functions: each "model" stores Gaussian residuals;
# simulate() draws new innovations (innov=NULL) or uses the supplied ones
# (innov given).
simple_model <- function(res) {
structure(list(residuals = res, sigma = sd(res)), class = "simple_model")
}
simulate.simple_model <- function(object, nsim = 1, innov = NULL,
future = TRUE, ...) {
if (is.null(innov)) {
rnorm(nsim, mean = 0, sd = object$sigma)
} else {
as.numeric(innov)[seq_len(nsim)]
}
}
# Hierarchy Z = X + Y: 3 series, 50 in-sample residuals each
n <- 3
res <- matrix(rnorm(50 * n), nrow = 50, ncol = n)
# One model per cross-sectional series
model_list <- lapply(seq_len(n), function(i) simple_model(res[, i]))
# Joint block bootstrap: 100 replicates, forecast horizon h = 4
boot <- csboot(model_list = model_list, boot_size = 100, block_size = 4,
seed = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.