Title: | Forecast Linear Augmented Projection |
---|---|
Description: | The Forecast Linear Augmented Projection (flap) method reduces forecast variance by adjusting the forecasts of multivariate time series to be consistent with the forecasts of linear combinations (components) of the series by projecting all forecasts onto the space where the linear constraints are satisfied. The forecast variance can be reduced monotonically by including more components. For a given number of components, the flap method achieves maximum forecast variance reduction among linear projections. |
Authors: | Yangzhuoran Fin Yang [aut, cre] |
Maintainer: | Yangzhuoran Fin Yang <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0.9000 |
Built: | 2024-11-17 05:10:41 UTC |
Source: | https://github.com/finyang/flap |
Reduces forecast variance by adjusting the forecasts of multivariate time series to be consistent with the forecasts of linear combinations (components) of the series by projecting all forecasts onto the space where the linear constraints are satisfied.
flap(fc, fc_comp, Phi, res, res_comp, p = seq_len(ncol(fc_comp)))
flap(fc, fc_comp, Phi, res, res_comp, p = seq_len(ncol(fc_comp)))
fc |
An |
fc_comp |
An |
Phi |
A |
res |
A |
res_comp |
A |
p |
The number of components to use in the projection. The default is trying all the possible number of components capped at the number provided in the forecast. |
A list of class flap
with each element containing a by
matrix of projected forecast of the original series for the corresponding
number of components
p
.
# Generate example data # T = 70, m = 20 train <- matrix(rnorm(70 * 20),ncol = 20) # Obtain the forecast and the residual of the original series mdl <- apply(train, 2, forecast::ets) fc <- vapply(mdl, function(mdl) forecast::forecast(mdl, h=12)$mean, FUN.VALUE = numeric(12)) res <- vapply(mdl, residuals, FUN.VALUE = numeric(70)) # Obtain components and their forecasts and residuals pca <- stats::prcomp(train, center = FALSE, scale. = FALSE) mdl_comp <- apply(pca$x, 2, forecast::ets) fc_comp <- vapply(mdl_comp, function(mdl) forecast::forecast(mdl, h=12)$mean, FUN.VALUE = numeric(12)) res_comp <- vapply(mdl_comp, residuals, FUN.VALUE = numeric(nrow(pca$x))) Phi <- t(pca$rotation) # flap! flap(fc, fc_comp, Phi, res, res_comp)
# Generate example data # T = 70, m = 20 train <- matrix(rnorm(70 * 20),ncol = 20) # Obtain the forecast and the residual of the original series mdl <- apply(train, 2, forecast::ets) fc <- vapply(mdl, function(mdl) forecast::forecast(mdl, h=12)$mean, FUN.VALUE = numeric(12)) res <- vapply(mdl, residuals, FUN.VALUE = numeric(70)) # Obtain components and their forecasts and residuals pca <- stats::prcomp(train, center = FALSE, scale. = FALSE) mdl_comp <- apply(pca$x, 2, forecast::ets) fc_comp <- vapply(mdl_comp, function(mdl) forecast::forecast(mdl, h=12)$mean, FUN.VALUE = numeric(12)) res_comp <- vapply(mdl_comp, residuals, FUN.VALUE = numeric(nrow(pca$x))) Phi <- t(pca$rotation) # flap! flap(fc, fc_comp, Phi, res, res_comp)