Fit and forecast using caret+dynrmf
library(ahead)
library(forecast)
myfitfunc <- function(x, y) ahead::fit_func(x, y, method = "glmnet")
(obj1 <- ahead::dynrmf(USAccDeaths, h=20L, level=99))
## Point Forecast Lo 99 Hi 99
## Jan 1979 8247.686 7097.078 9398.294
## Feb 1979 7362.924 6212.316 8513.532
## Mar 1979 7687.229 6536.621 8837.837
## Apr 1979 8073.679 6923.071 9224.287
## May 1979 8707.181 7556.573 9857.789
## Jun 1979 9057.569 7906.961 10208.177
## Jul 1979 9735.000 8584.393 10885.608
## Aug 1979 9530.808 8380.200 10681.416
## Sep 1979 9008.646 7858.038 10159.254
## Oct 1979 8842.809 7692.201 9993.417
## Nov 1979 8571.219 7420.611 9721.827
## Dec 1979 8855.324 7704.716 10005.932
## Jan 1980 8377.531 7226.923 9528.139
## Feb 1980 7700.809 6550.201 8851.417
## Mar 1980 7718.974 6568.366 8869.582
## Apr 1980 7992.722 6842.114 9143.330
## May 1980 8442.950 7292.342 9593.558
## Jun 1980 8764.246 7613.638 9914.854
## Jul 1980 9227.023 8076.416 10377.631
## Aug 1980 9225.213 8074.605 10375.821
(obj2 <- ahead::dynrmf(USAccDeaths, fit_func = myfitfunc, predict_func = ahead::predict_func, h=20L, level=99))
## Loading required package: lattice
## glmnet
##
## 60 samples
## 3 predictor
##
## No pre-processing
## Resampling: Rolling Forecasting Origin Resampling (10 held-out with no fixed window)
## Summary of sample sizes: 10, 11, 12, 13, 14, 15, ...
## Resampling results across tuning parameters:
##
## alpha lambda RMSE Rsquared MAE
## 0.100 0.0006941739 0.5122709 0.8358795 0.4183879
## 0.100 0.0032220699 0.5122709 0.8358795 0.4183879
## 0.100 0.0149555236 0.5118254 0.8360817 0.4175054
## 0.100 0.0694173913 0.5122442 0.8353406 0.4157414
## 0.100 0.3222069884 0.5421835 0.8135049 0.4290090
## 0.325 0.0006941739 0.5124592 0.8367432 0.4186208
## 0.325 0.0032220699 0.5124592 0.8367432 0.4186208
## 0.325 0.0149555236 0.5124025 0.8389486 0.4180482
## 0.325 0.0694173913 0.5160884 0.8443188 0.4184223
## 0.325 0.3222069884 0.5579605 0.8331106 0.4413218
## 0.550 0.0006941739 0.5126591 0.8372040 0.4188718
## 0.550 0.0032220699 0.5126536 0.8372263 0.4188592
## 0.550 0.0149555236 0.5131014 0.8417733 0.4186649
## 0.550 0.0694173913 0.5206184 0.8515997 0.4208158
## 0.550 0.3222069884 0.5791056 0.8571081 0.4640557
## 0.775 0.0006941739 0.5127529 0.8374880 0.4189854
## 0.775 0.0032220699 0.5127664 0.8378484 0.4189569
## 0.775 0.0149555236 0.5137188 0.8444945 0.4190831
## 0.775 0.0694173913 0.5244526 0.8569988 0.4237475
## 0.775 0.3222069884 0.6060372 0.8779967 0.4906426
## 1.000 0.0006941739 0.5128106 0.8376175 0.4190546
## 1.000 0.0032220699 0.5128880 0.8385027 0.4190576
## 1.000 0.0149555236 0.5144611 0.8471345 0.4195163
## 1.000 0.0694173913 0.5274020 0.8624336 0.4260166
## 1.000 0.3222069884 0.6293602 0.8835106 0.5115017
##
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were alpha = 0.1 and lambda = 0.01495552.
## Point Forecast Lo 99 Hi 99
## Jan 1979 8226.504 7078.503 9374.506
## Feb 1979 7310.188 6162.187 8458.189
## Mar 1979 7652.958 6504.957 8800.959
## Apr 1979 8061.904 6913.903 9209.905
## May 1979 8719.391 7571.390 9867.392
## Jun 1979 9080.080 7932.079 10228.082
## Jul 1979 9778.292 8630.291 10926.293
## Aug 1979 9562.742 8414.740 10710.743
## Sep 1979 9015.270 7867.269 10163.272
## Oct 1979 8843.025 7695.024 9991.027
## Nov 1979 8564.907 7416.906 9712.909
## Dec 1979 8862.101 7714.100 10010.102
## Jan 1980 8355.486 7207.484 9503.487
## Feb 1980 7628.428 6480.427 8776.430
## Mar 1980 7655.038 6507.037 8803.039
## Apr 1980 7961.499 6813.498 9109.500
## May 1980 8449.506 7301.504 9597.507
## Jun 1980 8792.145 7644.143 9940.146
## Jul 1980 9283.498 8135.497 10431.499
## Aug 1980 9275.256 8127.255 10423.257