Description Usage Arguments Details Value Author(s) References See Also Examples
Using the method of Wickramasuriya et al. (2019), this function combines the
forecasts at all levels of a hierarchical or grouped time series. The
forecast.gts
calls this function when the MinT
method
is selected.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
fcasts |
Matrix of forecasts for all levels of a hierarchical or grouped time series. Each row represents one forecast horizon and each column represents one time series of aggregated or disaggregated forecasts. |
nodes |
If the object class is hts, a list contains the number of child nodes referring to hts. |
groups |
If the object is gts, a gmatrix is required, which is the same as groups in the function gts. |
residual |
Matrix of insample residuals for all the aggregated and
disaggregated time series. The columns must be in the same order as
|
covariance |
Type of the covariance matrix to be used. Shrinking
towards a diagonal unequal variances ( |
nonnegative |
Logical. Should the reconciled forecasts be non-negative? |
algorithms |
Algorithm used to compute inverse of the matrices. |
keep |
Return a gts object or the reconciled forecasts at the bottom level. |
parallel |
Logical. Import parallel package to allow parallel processing. |
num.cores |
Numeric. Specify how many cores are going to be used. |
control.nn |
A list of control parameters to be passed on to the block principal pivoting algorithm. See 'Details'. |
The control.nn
argument is a list that can supply any of the following components:
ptype
Permutation method to be used: "fixed"
or "random"
. Defaults to "fixed"
.
par
The number of full exchange rules that may be tried. Defaults to 10.
gtol
The tolerance of the convergence criteria. Defaults to sqrt(.Machine$double.eps)
.
Return the reconciled gts
object or forecasts at the bottom
level.
Shanika L Wickramasuriya
Wickramasuriya, S. L., Athanasopoulos, G., & Hyndman, R. J. (2019). Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization. Journal of the American Statistical Association, 114(526), 804–819. https://robjhyndman.com/working-papers/mint/
Wickramasuriya, S. L., Turlach, B. A., & Hyndman, R. J. (to appear). Optimal non-negative forecast reconciliation. Statistics and Computing. https://robjhyndman.com/publications/nnmint/
Hyndman, R. J., Lee, A., & Wang, E. (2016). Fast computation of reconciled forecasts for hierarchical and grouped time series. Computational Statistics and Data Analysis, 97, 16–32. https://robjhyndman.com/publications/hgts/
hts
, gts
,
forecast.gts
, combinef
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # hts example
## Not run:
h <- 12
ally <- aggts(htseg1)
n <- nrow(ally)
p <- ncol(ally)
allf <- matrix(NA, nrow = h, ncol = p)
res <- matrix(NA, nrow = n, ncol = p)
for(i in 1:p)
{
fit <- auto.arima(ally[, i])
allf[, i] <- forecast(fit, h = h)$mean
res[, i] <- na.omit(ally[, i] - fitted(fit))
}
allf <- ts(allf, start = 51)
y.f <- MinT(allf, get_nodes(htseg1), residual = res, covariance = "shr",
keep = "gts", algorithms = "lu")
plot(y.f)
y.f_cg <- MinT(allf, get_nodes(htseg1), residual = res, covariance = "shr",
keep = "all", algorithms = "cg")
## End(Not run)
## Not run:
h <- 12
ally <- abs(aggts(htseg2))
allf <- matrix(NA, nrow = h, ncol = ncol(ally))
res <- matrix(NA, nrow = nrow(ally), ncol = ncol(ally))
for(i in 1:ncol(ally)) {
fit <- auto.arima(ally[, i], lambda = 0, biasadj = TRUE)
allf[,i] <- forecast(fit, h = h)$mean
res[,i] <- na.omit(ally[, i] - fitted(fit))
}
b.f <- MinT(allf, get_nodes(htseg2), residual = res, covariance = "shr",
keep = "bottom", algorithms = "lu")
b.nnf <- MinT(allf, get_nodes(htseg2), residual = res, covariance = "shr",
keep = "bottom", algorithms = "lu", nonnegative = TRUE, parallel = TRUE)
## End(Not run)
# gts example
## Not run:
abc <- ts(5 + matrix(sort(rnorm(200)), ncol = 4, nrow = 50))
g <- rbind(c(1,1,2,2), c(1,2,1,2))
y <- gts(abc, groups = g)
h <- 12
ally <- aggts(y)
n <- nrow(ally)
p <- ncol(ally)
allf <- matrix(NA,nrow = h,ncol = ncol(ally))
res <- matrix(NA, nrow = n, ncol = p)
for(i in 1:p)
{
fit <- auto.arima(ally[, i])
allf[, i] <- forecast(fit, h = h)$mean
res[, i] <- na.omit(ally[, i] - fitted(fit))
}
allf <- ts(allf, start = 51)
y.f <- MinT(allf, groups = get_groups(y), residual = res, covariance = "shr",
keep = "gts", algorithms = "lu")
plot(y.f)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.