LOOCV for Random Vector functional link network model with 2 regularization parameters

loocvridge2f(
  y,
  xreg = NULL,
  h = 5,
  level = 95,
  lags = 1,
  nb_hidden = 5,
  nodes_sim = c("sobol", "halton", "unif"),
  activ = c("relu", "sigmoid", "tanh", "leakyrelu", "elu", "linear"),
  a = 0.01,
  lambda_1 = 0.1,
  lambda_2 = 0.1,
  dropout = 0,
  type_forecast = c("recursive", "direct"),
  type_pi = c("gaussian", "bootstrap", "blockbootstrap", "movingblockbootstrap",
    "rvinecopula", "splitconformal"),
  block_length = NULL,
  margins = c("gaussian", "empirical", "student"),
  seed = 1,
  B = 100L,
  type_aggregation = c("mean", "median"),
  centers = NULL,
  type_clustering = c("kmeans", "hclust"),
  ym = NULL,
  cl = 1L,
  show_progress = TRUE,
  ...
)

Arguments

y

A multivariate time series of class ts (preferred) or a matrix

xreg

External regressors. A data.frame (preferred) or a matrix

h

Forecasting horizon

level

Confidence level for prediction intervals

lags

Number of lags

nb_hidden

Number of nodes in hidden layer

nodes_sim

Type of simulation for nodes in the hidden layer

activ

Activation function

a

Hyperparameter for activation function "leakyrelu", "elu"

lambda_1

Regularization parameter for original predictors

lambda_2

Regularization parameter for transformed predictors

dropout

dropout regularization parameter (dropping nodes in hidden layer)

type_forecast

Recursive or direct forecast

type_pi

Type of prediction interval currently "gaussian", "bootstrap", "blockbootstrap", "movingblockbootstrap", "splitconformal" (very experimental right now), "rvinecopula" (with Gaussian margins for now, Student-t coming soon)

block_length

Length of block for circular or moving block bootstrap

margins

Distribution of margins: "gaussian", "empirical", "student" (postponed or never) for type_pi == "rvinecopula"

seed

Reproducibility seed for random stuff

B

Number of bootstrap replications or number of simulations (yes, 'B' is unfortunate)

type_aggregation

Type of aggregation, ONLY for bootstrapping; either "mean" or "median"

centers

Number of clusters for type_clustering

type_clustering

"kmeans" (K-Means clustering) or "hclust" (Hierarchical clustering)

ym

Univariate time series (stats::ts) of yield to maturities with frequency = frequency(y) and start = tsp(y)[2] + 1 / frequency(y). Default is NULL.

cl

An integer; the number of clusters for parallel execution, for bootstrap

show_progress

A boolean; show progress bar for bootstrapping? Default is TRUE.

...

Additional parameters to be passed to kmeans or hclust

Value

An object of class "mtsforecast"; a list containing the following elements:

method

The name of the forecasting method as a character string

mean

Point forecasts for the time series

lower

Lower bound for prediction interval

upper

Upper bound for prediction interval

sims

Model simulations for bootstrapping (basic, or block)

x

The original time series

residuals

Residuals from the fitted model

coefficients

Regression coefficients for type_pi == 'gaussian' for now

References

Moudiki, T., Planchet, F., & Cousin, A. (2018). Multiple time series forecasting using quasi-randomized functional link neural networks. Risks, 6(1), 22.

Author

T. Moudiki

Examples


require(fpp2)

print(ahead::loocvridge2f(fpp2::insurance))
#> $mean
#>            Quotes TV.advert
#> May 2005 14.76393  8.947782
#> Jun 2005 14.61841  8.862613
#> Jul 2005 14.56234  8.841193
#> Aug 2005 14.49305  8.809091
#> Sep 2005 14.43100  8.781208
#> 
#> $lower
#>            Quotes TV.advert
#> May 2005 11.96618  7.011446
#> Jun 2005 11.82066  6.926276
#> Jul 2005 11.76459  6.904857
#> Aug 2005 11.69530  6.872755
#> Sep 2005 11.63325  6.844872
#> 
#> $upper
#>            Quotes TV.advert
#> May 2005 17.56168  10.88412
#> Jun 2005 17.41616  10.79895
#> Jul 2005 17.36009  10.77753
#> Aug 2005 17.29080  10.74543
#> Sep 2005 17.22875  10.71754
#> 
#> $sims
#> NULL
#> 
#> $x
#>            Quotes TV.advert
#> Jan 2002 12.97065  7.212725
#> Feb 2002 15.38714  9.443570
#> Mar 2002 13.22957  7.534250
#> Apr 2002 12.97065  7.212725
#> May 2002 15.38714  9.443570
#> Jun 2002 11.72288  6.415215
#> Jul 2002 10.06177  5.806990
#> Aug 2002 10.82279  6.203600
#> Sep 2002 13.28707  7.586430
#> Oct 2002 14.57832  8.004935
#> Nov 2002 15.60542  8.834980
#> Dec 2002 15.93515  8.957255
#> Jan 2003 16.99486  9.532990
#> Feb 2003 16.87821  9.392950
#> Mar 2003 16.45128  8.918560
#> Apr 2003 15.28118  8.374120
#> May 2003 15.88901  9.844505
#> Jun 2003 15.67747  9.849390
#> Jul 2003 13.28780  8.402730
#> Aug 2003 12.64484  7.920675
#> Sep 2003 11.82771  7.436085
#> Oct 2003  9.69184  6.340490
#> Nov 2003 10.30415  6.939995
#> Dec 2003 11.38253  6.977100
#> Jan 2004 12.95149  8.010201
#> Feb 2004 13.63092  9.565460
#> Mar 2004  9.12098  6.272510
#> Apr 2004  8.39468  5.707495
#> May 2004 12.30076  7.963540
#> Jun 2004 13.84831  8.494221
#> Jul 2004 15.96246  9.789085
#> Aug 2004 14.19738  8.692825
#> Sep 2004 12.85922  8.057230
#> Oct 2004 12.08837  7.588995
#> Nov 2004 12.93375  8.244881
#> Dec 2004 11.72235  6.675540
#> Jan 2005 15.47126  9.219604
#> Feb 2005 18.43898 10.963800
#> Mar 2005 17.49186 10.456290
#> Apr 2005 14.49168  8.728600
#> 
#> $level
#> [1] 95
#> 
#> $method
#> [1] "ridge2"
#> 
#> $fitted
#>             Quotes TV.advert
#> Jan 2002 13.983454  8.113042
#> Feb 2002 14.310140  8.680078
#> Mar 2002 14.204085  8.367422
#> Apr 2002 13.983454  8.113042
#> May 2002 14.310140  8.680078
#> Jun 2002 13.136549  7.573500
#> Jul 2002 12.139564  7.269130
#> Aug 2002 12.630260  7.516240
#> Sep 2002 14.247551  8.406368
#> Oct 2002 15.085483  8.610639
#> Nov 2002 15.834616  9.129753
#> Dec 2002 16.037153  9.175375
#> Jan 2003 16.609951  9.409639
#> Feb 2003 16.579674  9.347087
#> Mar 2003 16.452555  9.136445
#> Apr 2003 15.691303  8.874788
#> May 2003 14.054876  8.529575
#> Jun 2003 13.434843  8.229103
#> Jul 2003 12.715293  7.977976
#> Aug 2003 12.998432  8.104914
#> Sep 2003 12.590713  7.879126
#> Oct 2003 10.931512  7.005044
#> Nov 2003 10.416928  6.781919
#> Dec 2003 13.045036  8.079712
#> Jan 2004 13.471769  8.342884
#> Feb 2004  8.822228  6.015318
#> Mar 2004  9.707979  6.398258
#> Apr 2004  9.811491  6.420448
#> May 2004 11.936553  7.582567
#> Jun 2004 13.921151  8.555557
#> Jul 2004 14.494976  8.746341
#> Aug 2004 14.079472  8.618854
#> Sep 2004 13.046936  8.135087
#> Oct 2004 12.726572  7.953926
#> Nov 2004 12.426974  7.834539
#> Dec 2004 13.211185  7.811190
#> Jan 2005 15.485788  9.264229
#> Feb 2005 16.598686  9.685778
#> Mar 2005 16.037908  9.448414
#> 
#> $residuals
#>               Quotes   TV.advert
#> Jan 2002  1.40368643  1.33052782
#> Feb 2002 -1.08056990 -1.14582835
#> Mar 2002 -1.23343504 -1.15469695
#> Apr 2002  1.40368643  1.33052782
#> May 2002 -2.58725990 -2.26486335
#> Jun 2002 -3.07477874 -1.76651025
#> Jul 2002 -1.31677412 -1.06553020
#> Aug 2002  0.65681006  0.07019039
#> Sep 2002  0.33076863 -0.40143292
#> Oct 2002  0.51993723  0.22434076
#> Nov 2002  0.10053432 -0.17249791
#> Dec 2002  0.95770684  0.35761548
#> Jan 2003  0.26825909 -0.01668861
#> Feb 2003 -0.12839403 -0.42852687
#> Mar 2003 -1.17137522 -0.76232506
#> Apr 2003  0.19770654  0.96971721
#> May 2003  1.62259434  1.31981494
#> Jun 2003 -0.14704277  0.17362676
#> Jul 2003 -0.07045343 -0.05730098
#> Aug 2003 -1.17072203 -0.66882907
#> Sep 2003 -2.89887258 -1.53863637
#> Oct 2003 -0.62736155 -0.06504866
#> Nov 2003  0.96560231  0.19518092
#> Dec 2003 -0.09354593 -0.06951135
#> Jan 2004  0.15915097  1.22257588
#> Feb 2004  0.29875209  0.25719228
#> Mar 2004 -1.31329880 -0.69076345
#> Apr 2004  2.48926902  1.54309187
#> May 2004  1.91175656  0.91165371
#> Jun 2004  2.04130891  1.23352769
#> Jul 2004 -0.29759583 -0.05351566
#> Aug 2004 -1.22025180 -0.56162404
#> Sep 2004 -0.95856611 -0.54609232
#> Oct 2004  0.20717781  0.29095534
#> Nov 2004 -0.70462371 -1.15899926
#> Dec 2004  2.26007518  1.40841386
#> Jan 2005  2.95319223  1.69957104
#> Feb 2005  0.89317411  0.77051186
#> Mar 2005 -1.54622760 -0.71981400
#> 
#> $coefficients
#>        Quotes   TV.advert
#> x1  0.4358443  0.18606264
#> x2  0.1361999  0.08192973
#> h1  0.2311472 -0.09036149
#> h2 -1.2318730 -0.60953989
#> h3 -0.1129694 -0.08956715
#> h4  0.4033300  0.15098381
#> h5 -0.4866789 -0.25350343
#> 
#> $loocv
#> [1] 1.924173
#> 
#> $weighted_loocv
#> [1] 3.601775e-17
#> 
#> $loocv_per_series
#>    Quotes TV.advert 
#>  2.601976  1.246370 
#> 
#> attr(,"class")
#> [1] "mtsforecast"

#foo <- function(xx) ahead::loocvridge2f(fpp2::insurance, lambda_1=10^xx[1], lambda_2=10^xx[2])
#(opt <- stats::nlminb(objective=foo, lower=c(-10,-10), upper=c(10,10), start=c(0, 0)))
#print(ahead::loocvridge2f(fpp2::insurance, lambda_1=10^opt$par[1], lambda_2=10^opt$par[2]))