Title: | (Geometric) Forecast Combination Methods |
---|---|
Description: | Provides eigenvector-based (geometric) forecast combination methods; also includes simple approaches (simple average, median, trimmed and winsorized mean, inverse rank method) and regression-based combination. Tools for data pre-processing are available in order to deal with common problems in forecast combination (missingness, collinearity). |
Authors: | Christoph E. Weiss, Gernot R. Roetzer |
Maintainer: | Christoph E. Weiss <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-11-28 06:45:54 UTC |
Source: | CRAN |
Computes the fit for all the available forecast combination methods on the provided dataset with respect to the loss criterion. Returns the best fit method.
auto_combine(x, criterion = "RMSE", param_list = NULL)
auto_combine(x, criterion = "RMSE", param_list = NULL)
x |
An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set. |
criterion |
Specifies loss criterion. Set criterion to either 'RMSE' (default), 'MAE', or 'MAPE'. |
param_list |
Can contain additional parameters for the different combination methods (see example below). |
The function auto_combine
allows to quickly apply all the different forecast combination methods onto the provided time series
data and selects the method with the best fit.
The user can choose from 3 different loss criteria for the best-fit evaluation:
root mean square error (criterion='RMSE'
), mean absolute error (criterion='MAE'
), and
mean absolute percentage error (criterion='MAPE'
).
In case the user does not want to optimize over the parameters of some of the combination methods,
auto_combine
allows to specify the parameter values for these methods explicitly (see Examples).
The best-fit results are stored in an object of class 'foreccomb_res', for which separate plot and summary functions are provided.
Returns an object of class foreccomb_res
that represents the results for the best-fit forecast combination method:
Method |
Returns the best-fit forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the best-fit combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) # Evaluating all the forecast combination methods and returning the best. # If necessary, it uses the built-in automated parameter optimisation methods # for the different methods. best_combination<-auto_combine(data, criterion = "MAPE") # Same as above, but now we restrict the parameter ntop_pred for the method comb_EIG3 to be 3. param_list<-list() param_list$comb_EIG3$ntop_pred<-3 best_combination_restricted<-auto_combine(data, criterion = "MAPE", param_list = param_list)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) # Evaluating all the forecast combination methods and returning the best. # If necessary, it uses the built-in automated parameter optimisation methods # for the different methods. best_combination<-auto_combine(data, criterion = "MAPE") # Same as above, but now we restrict the parameter ntop_pred for the method comb_EIG3 to be 3. param_list<-list() param_list$comb_EIG3$ntop_pred<-3 best_combination_restricted<-auto_combine(data, criterion = "MAPE", param_list = param_list)
Computes forecast combination weights according to the approach by Bates and Granger (1969) and produces forecasts for the test set, if provided.
comb_BG(x)
comb_BG(x)
x |
An object of class |
In their seminal paper, Bates and Granger (1969) introduce the idea of combining forecasts. Their approach builds on portfolio diversification theory and uses the diagonal elements of the estimated mean squared prediction error matrix in order to compute combination weights:
where is the estimated mean squared prediction error of the i-th model.
The combined forecast is then obtained by:
Their approach ignores correlation between forecast models due to difficulties in precisely estimating the covariance matrix.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Bates, J. M., and Granger, C. W. (1969). The Combination of Forecasts. Journal of the Operational Research Society, 20(4), 451–468.
Timmermann, A. (2006). Forecast Combinations. In: Elliott, G., Granger, C. W. J., and Timmermann, A. (Eds.), Handbook of Economic Forecasting, 1, 135–196.
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_BG(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_BG(data)
Computes forecast combination weights using constrained least squares (CLS) regression.
comb_CLS(x)
comb_CLS(x)
x |
An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set. |
The function is a wrapper around the constrained least squares (CLS) forecast combination implementation of the ForecastCombinations package.
Compared to the ordinary least squares forecast combination
method, CLS forecast combination has the additional
requirement that the weights, , sum up to 1 and that there is no intercept. That is,
the combinations of
comb_CLS
are affine combinations.
This method was first introduced by Granger and Ramanathan (1984). The general appeal of the method is its ease of interpretation (the weights can be interpreted as percentages) and often produces better forecasts than the OLS method when the individual forecasts are highly correlated. A disadvantage is that if one or more individual forecasts are biased, this bias is not corrected through the forecast combination due to the lack of an intercept.
In addition to the version presented by Granger and Ramanathan (1984), this variant of the method adds the restriction that combination weights must be non-negative, which has been found to be almost always outperform unconstrained OLS by Aksu and Gunter (1992) and was combined with the condition of forcing the weights to sum up to one by Nowotarski et al. (2014), who conclude that even though the method provides a suboptimal solution in-sample, it almost always produces better forecasts than unrestricted OLS out-of-sample.
The results are stored in an object of class 'foreccomb_res', for which separate plot and summary functions are provided.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the best-fit forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Aksu, C., and Gunter, S. I. (1992). An Empirical Analysis of the Accuracy of SA, OLS, ERLS and NRLS Combination Forecasts. International Journal of Forecasting, 8(1), 27–43.
Granger, C., and Ramanathan, R. (1984). Improved Methods Of Combining Forecasts. Journal of Forecasting, 3(2), 197–204.
Nowotarski, J., Raviv, E., Tr\"uck, S., and Weron, R. (2014). An Empirical Comparison of Alternative Schemes for Combining Electricity Spot Price Forecasts. Energy Economics, 46, 395–412.
Forecast_comb
,
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_CLS(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_CLS(data)
Computes forecast combination weights according to the standard eigenvector approach by Hsiao and Wan (2014) and produces forecasts for the test set, if provided.
comb_EIG1(x)
comb_EIG1(x)
x |
An object of class |
The standard eigenvector approach retrieves combination weights from the sample estimated mean squared prediction error matrix
as follows:
Suppose is the variable of interest, there are
not perfectly collinear predictors,
,
is the (positive definite)
mean squared prediction error matrix of
and
is an
vector of
.
The
positive eigenvalues are then arranged in increasing order
, and
is defined as the eigenvector corresponding to
. The combination weights
are then
chosen corresponding to the minimum of
, denoted as
, where
, as:
The combined forecast is then obtained by:
The difference to extant methods that minimize the population mean squared prediction error (e.g., Newbold and Granger, 1974) is the normalization function. While
previous approaches optimize MSPE under the constraint of , Hsiao and Wan (2014) show that this is dominated by
using
as constraint in the optimization problem.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Hsiao, C., and Wan, S. K. (2014). Is There An Optimal Forecast Combination? Journal of Econometrics, 178(2), 294–309.
Newbold, P., and Granger, C. W. J. (1974). Experience with Forecasting Univariate Time Series and the Combination of Forecasts. Journal of the Royal Statistical Society, Series A, 137(2), 131–165.
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
comb_NG
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG1(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG1(data)
Computes forecast combination weights according to the bias-corrected eigenvector approach by Hsiao and Wan (2014) and produces forecasts for the test set, if provided.
comb_EIG2(x)
comb_EIG2(x)
x |
An object of class |
The bias-corrected eigenvector approach builds on the idea that if one or more of the predictive models yield biased predictions,
the accuracy of the standard eigenvector approach can be improved by eliminating the bias. The optimization procedure to
obtain combination weights coincides with the standard eigenvector approach
, except
that it is applied to the centered MSPE matrix after extracting the bias (by subtracting the column means of the MSPE).
The combination weights are calculated as:
where and
are defined analogously to
and
in the
standard eigenvector approach
, with the only difference that they correspond to the spectral decomposition of the
centered MSPE matrix rather than the uncentered one.
The combined forecast is then obtained by:
where is the intercept for bias correction. If the actual
series and the forecasts are stationary, the expectations can be approximated by the time series means, i.e. the intercept is obtained
by subtracting the weighted sum of column means of the MSPE matrix from the mean of the actual series. Forecast combination methods
including intercepts therefore usually require stationarity.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Intercept |
Returns the intercept (bias correction). |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Hsiao, C., and Wan, S. K. (2014). Is There An Optimal Forecast Combination? Journal of Econometrics, 178(2), 294–309.
comb_EIG1
,
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG2(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG2(data)
Computes forecast combination weights according to the trimmed eigenvector approach by Hsiao and Wan (2014) and produces forecasts for the test set, if provided.
comb_EIG3(x, ntop_pred = NULL, criterion = "RMSE")
comb_EIG3(x, ntop_pred = NULL, criterion = "RMSE")
x |
An object of class |
ntop_pred |
Specifies the number of retained predictors. If |
criterion |
If |
The underlying methodology of the trimmed eigenvector approach by Hsiao and Wan (2014) is the same as their standard eigenvector approach
.
The only difference is that the trimmed eigenvector approach pre-selects the models that serve as input for the forecast combination, only a subset of the available
forecast models is retained, while the models with the worst performance are discarded.
The number of retained forecast models is controlled via ntop_pred
. The user can choose whether to select this number, or leave the selection
to the inbuilt optimization algorithm (in that case ntop_pred = NULL
). If the optimization algorithm should select the best number of
retained models, the user must select the optimization criterion
: MAE, MAPE, or RMSE. After this trimming step, the weights and the combined
forecast are computed in the same way as in the standard eigenvector approach
.
The trimmed eigenvector approach takes note of the eigenvector approaches' property to treat and
symmetrically,
which bears the risk that the (non-trimmed) eigenvector approaches' performance could be severely impaired by one or a few models that
produce forecasts much worse than the average.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Top_Predictors |
Number of retained predictors. |
Ranking |
Ranking of the predictors that determines which models are removed in the trimming step. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Hsiao, C., and Wan, S. K. (2014). Is There An Optimal Forecast Combination? Journal of Econometrics, 178(2), 294–309.
comb_EIG1
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## Number of retained models selected by the user: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG3(data, ntop_pred = 2, criterion = NULL) ## Number of retained models selected by algorithm: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG3(data, ntop_pred = NULL, criterion = "RMSE")
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## Number of retained models selected by the user: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG3(data, ntop_pred = 2, criterion = NULL) ## Number of retained models selected by algorithm: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG3(data, ntop_pred = NULL, criterion = "RMSE")
Computes forecast combination weights according to the trimmed bias-corrected eigenvector approach by Hsiao and Wan (2014) and produces forecasts for the test set, if provided.
comb_EIG4(x, ntop_pred = NULL, criterion = "RMSE")
comb_EIG4(x, ntop_pred = NULL, criterion = "RMSE")
x |
An object of class |
ntop_pred |
Specifies the number of retained predictors. If |
criterion |
If |
The underlying methodology of the trimmed bias-corrected eigenvector approach by Hsiao and Wan (2014) is the same as their
bias-corrected eigenvector approach
. The only difference is that the bias-corrected trimmed eigenvector approach
pre-selects the models that serve as input for the forecast combination, only a subset of the available forecast models is retained,
while the models with the worst performance are discarded.
The number of retained forecast models is controlled via ntop_pred
. The user can choose whether to select this number, or leave the selection
to the inbuilt optimization algorithm (in that case ntop_pred = NULL
). If the optimization algorithm should select the best number of
retained models, the user must select the optimization criterion
: MAE, MAPE, or RMSE. After this trimming step, the weights, the intercept and the
combined forecast are computed in the same way as in the bias-corrected eigenvector approach
.
The bias-corrected trimmed eigenvector approach combines the strengths of the bias-corrected eigenvector approach
and the trimmed eigenvector approach
.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Intercept |
Returns the intercept (bias correction). |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Top_Predictors |
Number of retained predictors. |
Ranking |
Ranking of the predictors that determines which models are removed in the trimming step. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Hsiao, C., and Wan, S. K. (2014). Is There An Optimal Forecast Combination? Journal of Econometrics, 178(2), 294–309.
comb_EIG2
comb_EIG3
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## Number of retained models selected by the user: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG4(data, ntop_pred = 2, criterion = NULL) ## Number of retained models selected by algorithm: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG4(data, ntop_pred = NULL, criterion = "RMSE")
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## Number of retained models selected by the user: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG4(data, ntop_pred = 2, criterion = NULL) ## Number of retained models selected by algorithm: data<-foreccomb(train_o, train_p, test_o, test_p) comb_EIG4(data, ntop_pred = NULL, criterion = "RMSE")
Computes forecast combination weights according to the inverse rank approach by Aiolfi and Timmermann (2006) and produces forecasts for the test set, if provided.
comb_InvW(x)
comb_InvW(x)
x |
An object of class |
In the inverse rank approach by Aiolfi and Timmermann (2006), the combination weights are inversely proportional to the forecast model's rank, :
The combined forecast is then obtained by:
This is a robust variant of the Bates/Granger (1969) approach and also ignores correlations across forecast errors.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Aiolfi, M., amd Timmermann, A. (2006). Persistence in Forecasting Performance and Conditional Combination Strategies. Journal of Econometrics, 135(1), 31–53.
Bates, J. M., and Granger, C. W. (1969). The Combination of Forecasts. Journal of the Operational Research Society, 20(4), 451–468.
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
comb_BG
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_InvW(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_InvW(data)
Computes forecast combination weights using least absolute deviation (LAD) regression.
comb_LAD(x)
comb_LAD(x)
x |
An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set. |
The function is a wrapper around the least absolute deviation (LAD) forecast combination implementation of the ForecastCombinations package.
The defining property of comb_LAD
is that it does not minimize the squared error loss like comb_OLS
and
comb_CLS
, but the absolute values of the errors. This makes the method more robust to outliers – comb_LAD
tends to penalize models, which have high errors for some observations, less harshly than the least squares methods would.
Optimal forecast combinations under general loss functions are discussed by Elliott and Timmermann (2004). The LAD method is described in more detail, and used in an empirical context, by Nowotarksi et al. (2014).
The results are stored in an object of class 'foreccomb_res', for which separate plot and summary functions are provided.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the best-fit forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Intercept |
Returns the intercept of the linear regression. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Elliott, G., and Timmermann, A. (2004). Optimal Forecast Combinations Under General Loss Functions and Forecast Error Distributions. Journal of Econometrics, 122(1), 47–79.
Nowotarski, J., Raviv, E., Tr\"uck, S., and Weron, R. (2014). An Empirical Comparison of Alternative Schemes for Combining Electricity Spot Price Forecasts. Energy Economics, 46, 395–412.
Forecast_comb
,
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_LAD(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_LAD(data)
Computes a ‘combined forecast’ from a pool of individual model forecasts using their median at each point in time.
comb_MED(x)
comb_MED(x)
x |
An object of class |
Suppose is the variable of interest, there are
not perfectly collinear predictors,
. For each point in time, the median method gives
a weight of 1 to the median forecast and a weight of 0 to all other forecasts, the combined forecast is obtained by:
The median method is an appealing simple, rank-based combination method that has been proposed by authors such as Armstrong (1989), McNees (1992), Hendry and Clements (2004), Stock and Watson (2004), and Timmermann (2006). It is more robust to outliers than the simple average approach.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Armstrong, J. S. (1989). Combining Forecasts: The End of the Beginning or the Beginning of the End?. International Journal of Forecasting, 5(4), 585–588.
Hendry, D. F., and Clements, M. P. (2004). Pooling of Forecasts. The Econometrics Journal, 7(1), 1–31.
McNees, S. K. (1992). The Uses and Abuses of 'Consensus' Forecasts. Journal of Forecasting, 11(8), 703–710.
Stock, J. H., and Watson, M. W. (2004). Combination Forecasts of Output Growth in a Seven-Country Data Set. Journal of Forecasting, 23(6), 405–430.
Timmermann, A. (2006). Forecast Combinations. In: Elliott, G., Granger, C. W. J., and Timmermann, A. (Eds.), Handbook of Economic Forecasting, 1, 135–196.
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
comb_SA
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_MED(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_MED(data)
Computes forecast combination weights according to the approach by Newbold and Granger (1974) and produces forecasts for the test set, if provided.
comb_NG(x)
comb_NG(x)
x |
An object of class |
Building on early research by Bates and Granger (1969), the methodology of Newbold and Granger (1974) also extracts the combination weights from the estimated mean squared prediction error matrix.
Suppose is the variable of interest, there are
not perfectly collinear predictors,
,
is the (positive definite)
mean squared prediction error matrix of
and
is an
vector of
.
Their approach is a constrained minimization of the mean squared prediction error using the normalization condition .
This yields the following combination weights:
The combined forecast is then obtained by:
While the method dates back to Newbold and Granger (1974), the variant of the method used here does not impose the prior restriction that
is diagonal. This approach, called
VC
in Hsiao and Wan (2014), is a generalization of the original method.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Bates, J. M., and Granger, C. W. (1969). The Combination of Forecasts. Journal of the Operational Research Society, 20(4), 451–468.
Hsiao, C., and Wan, S. K. (2014). Is There An Optimal Forecast Combination? Journal of Econometrics, 178(2), 294–309.
Newbold, P., and Granger, C. W. J. (1974). Experience with Forecasting Univariate Time Series and the Combination of Forecasts. Journal of the Royal Statistical Society, Series A, 137(2), 131–165.
comb_BG
,
comb_EIG1
,
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_NG(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_NG(data)
Computes forecast combination weights using ordinary least squares (OLS) regression.
comb_OLS(x)
comb_OLS(x)
x |
An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set. |
The function is a wrapper around the ordinary least squares (OLS) forecast combination implementation of the ForecastCombinations package.
The OLS combination method (Granger and Ramanathan (1984)) uses ordinary least squares to
estimate the weights, , as well as an intercept,
, for the combination of
the forecasts.
Suppose that there are not perfectly collinear predictors
,
then the forecast combination for one data point can be represented as:
An appealing feature of the method is its bias correction through the intercept – even if one or more of the individual
predictors are biased, the resulting combined forecast is unbiased. A disadvantage of the method is that it places no
restriction on the combination weights (i.e., they do not add up to 1 and can be negative), which can make interpretation
hard. Another issue, documented in Nowotarski et al. (2014), is the method's unstable behavior
when predictors are highly correlated (which is the norm in forecast combination): Minor fluctuations in the sample
can cause major shifts of the coefficient vector (‘bouncing betas’) – often causing poor out-of-sample performance.
This issue is addressed by the comb_LAD
method that is more robust to outliers.
The results are stored in an object of class 'foreccomb_res', for which separate plot and summary functions are provided.
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the best-fit forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Intercept |
Returns the intercept of the linear regression. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Granger, C., and Ramanathan, R. (1984). Improved Methods Of Combining Forecasts. Journal of Forecasting, 3(2), 197–204.
Nowotarski, J., Raviv, E., Tr\"uck, S., and Weron, R. (2014). An Empirical Comparison of Alternative Schemes for Combining Electricity Spot Price Forecasts. Energy Economics, 46, 395–412.
Forecast_comb
,
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_OLS(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_OLS(data)
Computes forecast combination weights using simple average and produces forecasts for the test set, if provided.
comb_SA(x)
comb_SA(x)
x |
An object of class |
Suppose is the variable of interest, there are
not perfectly collinear predictors,
. The simple average gives equal weights to all predictors:
The combined forecast is then obtained by:
It is well-documented that simple average is a robust combination method that is hard to beat (e.g., Stock and Watson, 2004; Timmermann, 2006). This is often associated with the importance of parameter estimation error in sophisticated techniques – a problem that simple averaging avoids. However, simple averaging may not be a suitable combination method when some of the predictors are biased (Palm and Zellner, 1992).
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Palm, F. C., and Zellner, A. (1992). To Combine or not to Combine? Issues of Combining Forecasts. Journal of Forecasting, 11(8), 687–701.
Stock, J. H., and Watson, M. W. (2004). Combination Forecasts of Output Growth in a Seven-Country Data Set. Journal of Forecasting, 23(6), 405–430.
Timmermann, A. (2006). Forecast Combinations. In: Elliott, G., Granger, C. W. J., and Timmermann, A. (Eds.), Handbook of Economic Forecasting, 1, 135–196.
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_SA(data)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) comb_SA(data)
Computes a ‘combined forecast’ from a pool of individual model forecasts using trimmed mean at each point in time.
comb_TA(x, trim_factor = NULL, criterion = "RMSE")
comb_TA(x, trim_factor = NULL, criterion = "RMSE")
x |
An object of class |
trim_factor |
numeric. Must be between 0 (simple average) and 0.5 (median). |
criterion |
If |
Suppose is the variable of interest, there are
not perfectly collinear predictors,
. For each point in time, the order forecasts are
computed:
Using a trim factor (i.e., the top/bottom
are trimmed) the combined forecast is calculated as:
The trimmed mean is an interpolation between the simple average and the median. It is an appealing simple, rank-based combination method that is less sensitive to outliers than the simple average approach, and has been proposed by authors such as Armstrong (2001), Stock and Watson (2004), and Jose and Winkler (2008).
This method allows the user to select (by specifying
trim_factor
), or to leave the selection to
an optimization algorithm – in which case the optimization criterion has to be selected (one of "MAE", "MAPE", or "RMSE").
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Trim Factor |
Returns the trim factor, |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Armstrong, J. S. (2001). Combining Forecasts. In: Armstrong, J. S. (Ed.), Principles of Forecasting. Springer, Boston, MA, 417–439.
Jose, V. R. R., and Winkler, R. L. (2008). Simple Robust Averages of Forecasts: Some Empirical Results. International Journal of Forecasting, 24(1), 163–169.
Stock, J. H., and Watson, M. W. (2004). Combination Forecasts of Output Growth in a Seven-Country Data Set. Journal of Forecasting, 23(6), 405–430.
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
comb_SA
,
comb_MED
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## User-selected trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, trim_factor=0.1) ## Algorithm-optimized trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, criterion="RMSE")
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## User-selected trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, trim_factor=0.1) ## Algorithm-optimized trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, criterion="RMSE")
Computes a ‘combined forecast’ from a pool of individual model forecasts using winsorized mean at each point in time.
comb_WA(x, trim_factor = NULL, criterion = "RMSE")
comb_WA(x, trim_factor = NULL, criterion = "RMSE")
x |
An object of class |
trim_factor |
numeric. Must be between 0 and 0.5. |
criterion |
If |
Suppose is the variable of interest, there are
not perfectly collinear predictors,
. For each point in time, the order forecasts are
computed:
Using a trim factor (i.e., the top/bottom
are winsorized), and setting
,
the combined forecast is calculated as (Jose and Winkler, 2008):
Like the trimmed mean, the winsorized mean is a robust statistic that is less sensitive to outliers than the simple average. It is less extreme about handling outliers than the trimmed mean and preferred by Jose and Winkler (2008) for this reason.
This method allows the user to select (by specifying
trim_factor
), or to leave the selection to
an optimization algorithm – in which case the optimization criterion has to be selected (one of "MAE", "MAPE", or "RMSE").
Returns an object of class foreccomb_res
with the following components:
Method |
Returns the used forecast combination method. |
Models |
Returns the individual input models that were used for the forecast combinations. |
Weights |
Returns the combination weights obtained by applying the combination method to the training set. |
Trim Factor |
Returns the trim factor, |
Fitted |
Returns the fitted values of the combination method for the training set. |
Accuracy_Train |
Returns range of summary measures of the forecast accuracy for the training set. |
Forecasts_Test |
Returns forecasts produced by the combination method for the test set. Only returned if input included a forecast matrix for the test set. |
Accuracy_Test |
Returns range of summary measures of the forecast accuracy for the test set. Only returned if input included a forecast matrix and a vector of actual values for the test set. |
Input_Data |
Returns the data forwarded to the method. |
Christoph E. Weiss and Gernot R. Roetzer
Jose, V. R. R., and Winkler, R. L. (2008). Simple Robust Averages of Forecasts: Some Empirical Results. International Journal of Forecasting, 24(1), 163–169.
winsor.mean
,
foreccomb
,
plot.foreccomb_res
,
summary.foreccomb_res
,
comb_SA
,
comb_TA
,
accuracy
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## User-selected trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, trim_factor=0.1) ## Algorithm-optimized trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, criterion="RMSE")
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## User-selected trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, trim_factor=0.1) ## Algorithm-optimized trim factor: data<-foreccomb(train_o, train_p, test_o, test_p) comb_TA(data, criterion="RMSE")
Computes (time-varying) dispersion measures for the cross section of individual model forecasts that are the input of forecast combination.
cs_dispersion(x, measure = "SD", plot = FALSE)
cs_dispersion(x, measure = "SD", plot = FALSE)
x |
An object of class |
measure |
Cross-sectional dispersion measure, one of: |
plot |
logical. If |
The available measures of scale are defined as in Davison (2003). Let denote the i-th order statistic of the sample, then:
Previous research in the forecast combination literature has documented that regression-based combination methods tend to have relative advantage when one or more individual model forecasts are better than the rest, while eigenvector-based methods tend to have relative advantage when individual model forecasts are in the same ball park.
Returns a vector of the evolution of cross-sectional dispersion over the sample period (using the selected dispersion measure)
Davison, A. C. (2003). Statistical Models. Cambridge University Press.
Hsiao, C., and Wan, S. K. (2014). Is There An Optimal Forecast Combination? Journal of Econometrics, 178(2), 294–309.
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) cs_dispersion(data, measure = "IQR")
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) cs_dispersion(data, measure = "IQR")
Structures cross-sectional input data (individual model forecasts) for forecast combination. Stores data as S3 class
foreccomb
that serves as input to the forecast combination techniques. Handles missing value imputation (optional) and resolves
problems due to perfect collinearity.
foreccomb(observed_vector, prediction_matrix, newobs = NULL, newpreds = NULL, byrow = FALSE, na.impute = TRUE, criterion = "RMSE")
foreccomb(observed_vector, prediction_matrix, newobs = NULL, newpreds = NULL, byrow = FALSE, na.impute = TRUE, criterion = "RMSE")
observed_vector |
A vector or univariate time series; contains ‘actual values’ for training set. |
prediction_matrix |
A matrix or multivariate time series; contains individual model forecasts for training set. |
newobs |
A vector or univariate time series; contains ‘actual values’ if a test set is used (optional). |
newpreds |
A matrix or multivariate time series; contains individual model forecasts if a test set is used (optional). Does not
require specification of |
byrow |
logical. The default ( |
na.impute |
logical. The default ( |
criterion |
One of |
The function imports the column names of the prediction matrix (if byrow = FALSE
, otherwise the row names) as model names;
if no column names are specified, generic model names are created.
The missing value imputation algorithm is a modified version of the EM algorithm for imputation that is applicable to time series data - accounting for correlation between the forecasting models and time structure of the series itself. A smooth spline is fitted to each of the time series at each iteration. The degrees of freedom of each spline are chosen by cross-validation.
Forecast combination relies on the lack of perfect collinearity. The test for this condition checks if prediction_matrix
is full
rank. In the presence of perfect collinearity, the iterative algorithm identifies the subset of forecasting models that are causing
linear dependence and removes the one among them that has the lowest accuracy (according to a selected criterion, default is RMSE).
This procedure is repeated until the revised prediction matrix is full rank.
Returns an object of class foreccomb
.
Christoph E. Weiss, Gernot R. Roetzer
Junger, W. L., Ponce de Leon, A., and Santos, N. (2003). Missing Data Imputation in Multivariate Time Series via EM Algorithm. Cadernos do IME, 15, 8–21.
Dempster, A., Laird, N., and Rubin D. (1977). Maximum Likelihood from Incomplete Data via the EM Algorithm. Journal of the Royal Statistical Society, Series B, 39(1), 1–38.
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## Example with a training set only: foreccomb(train_o, train_p) ## Example with a training set and future individual forecasts: foreccomb(train_o, train_p, newpreds=test_p) ## Example with a training set and a full test set: foreccomb(train_o, train_p, test_o, test_p) ## Example with forecast models being stored in rows: preds_row <- matrix(rnorm(1000, 1), 10, 100) train_p_row <- preds_row[,1:80] foreccomb(train_o, train_p_row, byrow = TRUE) ## Example with NA imputation: train_p_na <- train_p train_p_na[2,3] <- NA foreccomb(train_o, train_p_na, na.impute = TRUE) ## Example with perfect collinearity: train_p[,2] <- 0.8*train_p[,1] + 0.4*train_p[,8] foreccomb(train_o, train_p, criterion="RMSE")
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] ## Example with a training set only: foreccomb(train_o, train_p) ## Example with a training set and future individual forecasts: foreccomb(train_o, train_p, newpreds=test_p) ## Example with a training set and a full test set: foreccomb(train_o, train_p, test_o, test_p) ## Example with forecast models being stored in rows: preds_row <- matrix(rnorm(1000, 1), 10, 100) train_p_row <- preds_row[,1:80] foreccomb(train_o, train_p_row, byrow = TRUE) ## Example with NA imputation: train_p_na <- train_p train_p_na[2,3] <- NA foreccomb(train_o, train_p_na, na.impute = TRUE) ## Example with perfect collinearity: train_p[,2] <- 0.8*train_p[,1] + 0.4*train_p[,8] foreccomb(train_o, train_p, criterion="RMSE")
Produces plots for the results of a forecast combination method. Either
an actual vs. fitted plot (which = 1
) or a barplot of the combination weights
(which = 2
).
## S3 method for class 'foreccomb_res' plot(x, which = 1, ...)
## S3 method for class 'foreccomb_res' plot(x, which = 1, ...)
x |
An object of class 'foreccomb_res'. |
which |
Type of plot: 1 = actual vs. fitted, 2 = combination weights. |
... |
Other arguments passing to |
A plot for the foreccomb_res class.
Christoph E. Weiss and Gernot R. Roetzer
foreccomb
,
summary.foreccomb_res
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) fit <- comb_EIG1(data) plot(fit)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) fit <- comb_EIG1(data) plot(fit)
summary
method for class ‘foreccomb_res’. Includes information about combination method,
combination weights assigned to the individual forecast models, as well as an accuracy evaluation of the combined
forecast.
## S3 method for class 'foreccomb_res' summary(object, ...) ## S3 method for class 'foreccomb_res_summary' print(x, ...)
## S3 method for class 'foreccomb_res' summary(object, ...) ## S3 method for class 'foreccomb_res_summary' print(x, ...)
object |
An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set. |
... |
potential further arguments (require by generic) |
x |
An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set. |
Christoph E. Weiss and Gernot R. Roetzer
foreccomb
,
plot.foreccomb_res
,
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) fit<-comb_BG(data) summary(fit)
obs <- rnorm(100) preds <- matrix(rnorm(1000, 1), 100, 10) train_o<-obs[1:80] train_p<-preds[1:80,] test_o<-obs[81:100] test_p<-preds[81:100,] data<-foreccomb(train_o, train_p, test_o, test_p) fit<-comb_BG(data) summary(fit)