| set_bounds | R Documentation |
This function defines the bounds matrix considering cross-sectional,
temporal, or cross-temporal frameworks. The output matrix can be used as
input for the bounds parameter in functions such as csrec, terec,
or ctrec, to perform bounded reconciliations.
set_bounds(n, k, h, lb = -Inf, ub = Inf, approach = "osqp", bounds = NULL)
n |
A ( |
k |
A ( |
h |
A ( |
lb, ub |
A ( |
approach |
A string specifying the algorithm to compute bounded reconciled forecasts:
|
bounds |
A matrix of previous bounds to be added. If not specified, new bounds will be computed. |
A numeric matrix representing the computed bounds, which can be:
Cross-sectional (b \times 3) matrix for cross-sectional
reconciliation (csrec).
Temporal (b \times 4) matrix for temporal reconciliation
(terec).
Cross-temporal (b \times 5) matrix for cross-temporal
reconciliation (ctrec).
Utilities:
FoReco2matrix(),
aggts(),
as_ctmatrix(),
as_tevector(),
balance_hierarchy(),
commat(),
csprojmat(),
cstools(),
ctprojmat(),
cttools(),
df2aggmat(),
lcmat(),
recoinfo(),
res2matrix(),
shrink_estim(),
shrink_oasd(),
teprojmat(),
tetools(),
unbalance_hierarchy()
# Example 1
# Two cross-sectional series (i = 2,3),
# with each series required to be between 0 and 1.
n <- c(2, 3)
lb <- c(0, 0)
ub <- c(1,1)
bounds_mat <- set_bounds(n = c(2, 3),
lb = rep(0, 2), # or lb = 0
ub = rep(1, 2)) # or ub = 1
# Example 2
# All the monthly values are between 0 and 1.
bounds_mat <- set_bounds(k = rep(1, 12), # or k = 1
h = 1:12,
lb = rep(0, 12), # or lb = 0
ub = rep(1, 12)) # or ub = 1
# Example 3
# For two cross-sectional series (i = 2,3),
# all the monthly values are between 0 and 1.
bounds_mat <- set_bounds(n = rep(c(2, 3), each = 12),
k = 1,
h = rep(1:12, 2),
lb = 0, # or lb = 0
ub = 1) # or ub = 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.