comb OLS Electricity

1 - Comb OLS

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])
## [1] "arima"   "ets"     "nnet"    "dampedt" "dotm"
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)
start <- proc.time()[3]
obj <- ahead::comb_OLS(data)
print(proc.time()[3] - start)
## elapsed 
##   0.002
print(class(obj))
## [1] "foreccomb_res" "comb_OLS"
print(obj$Accuracy_Test)
##                 ME     RMSE      MAE        MPE     MAPE
## Test set -40.07742 671.5214 536.0331 -0.2470512 1.841961
print(obj$Weights)
## [1]  0.02152869 -0.20646266  0.20992792 -1.04349858  1.97991049
# check
print(mean(predict(obj, test_pred) - test_obs))
## [1] 40.07742
plot(obj)

2 - Comb Ridge

start <- proc.time()[3]
obj <- ahead::comb_Ridge(data)
print(proc.time()[3] - start)
## elapsed 
##   0.003
print(obj$Weights)
## [1]    95.81502  -582.80574   685.98452 -2745.54330  5530.43579
print(class(obj))
## [1] "foreccomb_res" "comb_Ridge"
print(obj$Accuracy_Test)
##                ME     RMSE      MAE       MPE     MAPE
## Test set -46.9685 672.4224 532.7352 -0.263655 1.827328
# check 
print(mean(predict(obj, test_pred) - test_obs))
## [1] 46.9685
plot(obj)