Computes forecast combination weights using GLMNET Regression (OLS) regression.

comb_GLMNET(x, custom_error = NULL)

Arguments

x

An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set.

Value

Returns an object of class ForecastComb::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.

Details

The function integrates the GLMNET Regression forecast combination implementation of the ForecastCombinations package into ForecastComb.

The results are stored in an object of class 'ForecastComb::foreccomb_res', for which separate plot and summary functions are provided.

See also

Forecast_comb, foreccomb, plot.ForecastComb::foreccomb_res, summary.ForecastComb::foreccomb_res, accuracy

Examples


library(ForecastComb)
#> Registered S3 methods overwritten by 'ForecastComb':
#>   method                      from 
#>   plot.foreccomb_res          ahead
#>   predict.foreccomb_res       ahead
#>   print.foreccomb_res_summary ahead
#>   summary.foreccomb_res       ahead
#> 
#> Attaching package: ‘ForecastComb’
#> The following object is masked from ‘package:ahead’:
#> 
#>     comb_OLS

data(electricity)

print(head(electricity))
#>             arima      ets     nnet  dampedt     dotm Actual
#> Jan 2007 36980.16 35692.31 37047.91 35540.66 36044.28  36420
#> Feb 2007 33587.29 33708.15 34523.56 33962.34 33821.69  32901
#> Mar 2007 36005.55 37366.20 36049.72 37317.91 37119.29  34595
#> Apr 2007 30925.25 30550.24 30721.91 30356.77 30350.95  29665
#> May 2007 30394.78 29167.64 29241.89 28766.40 28910.84  30154
#> Jun 2007 28938.14 29004.18 29211.91 29006.25 28229.28  28607

forecasting_methods <- colnames(electricity)[1:5]

train_obs <- electricity[1:84, "Actual"]
train_pred <- electricity[1:84, forecasting_methods]
test_obs <- electricity[85:123, "Actual"]
test_pred <- electricity[85:123, forecasting_methods]
data <- ForecastComb::foreccomb(train_obs, train_pred, test_obs, test_pred)

# obj <- ahead::comb_GLMNET(data))