| foreco-class | R Documentation |
The foreco class represents reconciled forecasts produced by the FoReco
package. It extends a numeric matrix, vector, or distributional object with
additional attributes that store metadata about the reconciliation procedure
(framework, function used, forecast type, and other reconciliation-specific
information). The class provides dedicated methods for printing,
summarising, extracting components and visualising reconciled forecasts.
new_foreco_class(reco, framework, rfun, rtype, rinfo = NULL, nninfo = NULL)
## S3 method for class 'foreco'
summary(object, keep_forecasts = TRUE, ...)
## S3 method for class 'summary_foreco'
print(x, n_row = 4L, n_col = 6L, ...)
## S3 method for class 'foreco'
print(x, n_row = NULL, n_col = NULL, ...)
## S3 method for class 'foreco'
plot(x, cs = NULL, te = 1, alpha = 0.95, ...)
## S3 method for class 'foreco'
components(
object,
cs = NULL,
te = NULL,
keep_names = FALSE,
temporal_names = NULL,
simplify = FALSE,
...
)
drop_foreco_class(x)
reco |
A numeric matrix/vector (when |
framework |
A character string identifying the reconciliation framework.
Must be one of |
rfun |
A character scalar with the name of the FoReco function that
produced the reconciled forecasts (e.g. |
rtype |
A character string indicating the type of reconciled forecasts.
Must be one of |
rinfo |
An optional named list with additional reconciliation
information (e.g. covariance approximation |
nninfo |
An optional matrix with information about the non-negativity
procedure applied during reconciliation. Stored as the |
keep_forecasts |
Logical; if |
... |
Additional arguments passed to the underlying methods
(e.g. |
x, object |
An object of class |
n_row, n_col |
Integers giving the maximum number of rows and columns to
display when printing. If |
cs |
Optional integer vector selecting the cross-sectional series to
keep. If |
te |
Optional vector (numeric or character) selecting the temporal
aggregation orders to keep, matched against the elements of |
alpha |
Nominal coverage of the prediction interval drawn by
|
keep_names |
Logical. If |
temporal_names |
Optional character vector of labels for the temporal
aggregation orders returned by |
simplify |
Logical. If |
new_foreco_class() is the low-level constructor. It is exported so
that companion packages can produce objects that integrate with FoReco's
print(), summary(), plot() and components() methods.
plot.foreco() draws the reconciled forecasts as line/point plots. For
probabilistic forecasts (rtype = "probabilistic") it also overlays a
shaded central alpha * 100% prediction interval, built from the
(1 - alpha)/2 and 1 - (1 - alpha)/2 quantiles of the distributional
object; the median is shown as a dashed line and the interval limits as
dotted lines.
A foreco object extending the reconciled forecasts/distributions with
reconciliation metadata.
components.foreco() returns a named list of reconciled forecasts split
by temporal aggregation order. For the cross-sectional framework the list
has a single element "k-1".
set.seed(123)
# Aggregation matrix for Z = X + Y
A <- t(c(1, 1))
bts <- matrix(rnorm(6, mean = 10), 3, 2)
reco <- csbu(base = bts, agg_mat = A)
# Print and summarise the reconciled forecasts
print(reco)
print(reco, n_row = 2, n_col = 2)
summary(reco)
summary(reco, keep_forecasts = FALSE)
# Extract reconciled forecasts by temporal aggregation order
components(reco)
# Remove the foreco class
drop_foreco_class(reco)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.