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.
Arguments
- n
A (\(b \times 1\)) vector representing the \(i\)th cross-sectional series (\(i = 1, \dots, n\)), where \(b\) is the number of bounds to be set.
- k
A (\(b \times 1\)) vector specifying the temporal aggregation orders (\(k = m, \dots, 1\)).
- h
A (\(b \times 1\)) vector representing the forecast horizons (\(j = 1, \dots, m/k\)).
- lb, ub
A (\(b \times 1\)) vector of lower and upper bounds.
- approach
A string specifying the algorithm to compute bounded reconciled forecasts:
"
osqp
": quadratic programming optimization (osqp solver)."
sftb
": heuristic "set-forecasts-to-bounds", which adjusts the reconciled forecasts to be within specified bounds without further optimization.
- bounds
A matrix of previous bounds to be added. If not specified, new bounds will be computed.
See also
Utilities:
FoReco2matrix()
,
aggts()
,
balance_hierarchy()
,
commat()
,
csprojmat()
,
cstools()
,
ctprojmat()
,
cttools()
,
df2aggmat()
,
lcmat()
,
recoinfo()
,
res2matrix()
,
shrink_estim()
,
shrink_oasd()
,
teprojmat()
,
tetools()
,
unbalance_hierarchy()
Examples
# 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