Learn R Programming

FoReco (version 0.2.6)

oct_bounds: Optimal cross-temporal bounds

Description

Function to export the constraints designed for the cross-sectional and/or temporal reconciled forecasts

Usage

oct_bounds(hts_bounds, thf_bounds, m, C, Ut)

Value

A matrix with the cross-temporal bounds.

Arguments

hts_bounds

(n 2) matrix with cross-sectional bounds: the first column is the lower bound, and the second column is the upper bound.

thf_bounds

((k^ + m) 2) matrix with temporal bounds: the first column is the lower bound, and the second column is the upper bound.

m

Highest available sampling frequency per seasonal cycle (max. order of temporal aggregation, m), or a subset of p factors of m.

C

(n_a n_b) cross-sectional (contemporaneous) matrix mapping the bottom level series into the higher level ones.

Ut

Zero constraints cross-sectional (contemporaneous) kernel matrix (U'y = 0) spanning the null space valid for the reconciled forecasts. It can be used instead of parameter C, but nb (n = n_a + n_b) is needed if U' [I \ -C]. If the hierarchy admits a structural representation, U' has dimension (n_a n).

See Also

Other utilities: Cmatrix(), FoReco2ts(), agg_ts(), arrange_hres(), commat(), ctf_tools(), hts_tools(), lcmat(), residuals_matrix(), score_index(), shrink_estim(), thf_tools()

Examples

Run this code
data(FoReco_data)
# monthly base forecasts
mbase <- FoReco2matrix(FoReco_data$base, m = 12)$k1
# monthly residuals
mres <- FoReco2matrix(FoReco_data$res, m = 12)$k1

# For example, in FoReco_data we want that BA > 78, and C > 50
cs_bound <- matrix(c(rep(-Inf, 5), 78, -Inf, 50, rep(+Inf, 8)), ncol = 2)
## Cross-sectional reconciliation
csobj <- htsrec(mbase, C = FoReco_data$C, comb = "shr", res = mres, bounds = cs_bound)

# Extension of the constraints to the cross-temporal case
ct_bound <- oct_bounds(hts_bounds = cs_bound, m = 12)
## Cross-temporal reconciliation
obj <- octrec(FoReco_data$base, m = 12, C = FoReco_data$C, comb = "bdshr",
              res = FoReco_data$res, bounds = ct_bound)

Run the code above in your browser using DataLab