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(fpp)

print(ahead::loocvridge2f(fpp::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"
#> 
#> $residuals
#> Time Series:
#> Start = 2002 
#> End = 2040 
#> Frequency = 1 
#>           Quotes   TV.advert
#> 2002  1.40368643  1.33052782
#> 2003 -1.08056990 -1.14582835
#> 2004 -1.23343504 -1.15469695
#> 2005  1.40368643  1.33052782
#> 2006 -2.58725990 -2.26486335
#> 2007 -3.07477874 -1.76651025
#> 2008 -1.31677412 -1.06553020
#> 2009  0.65681006  0.07019039
#> 2010  0.33076863 -0.40143292
#> 2011  0.51993723  0.22434076
#> 2012  0.10053432 -0.17249791
#> 2013  0.95770684  0.35761548
#> 2014  0.26825909 -0.01668861
#> 2015 -0.12839403 -0.42852687
#> 2016 -1.17137522 -0.76232506
#> 2017  0.19770654  0.96971721
#> 2018  1.62259434  1.31981494
#> 2019 -0.14704277  0.17362676
#> 2020 -0.07045343 -0.05730098
#> 2021 -1.17072203 -0.66882907
#> 2022 -2.89887258 -1.53863637
#> 2023 -0.62736155 -0.06504866
#> 2024  0.96560231  0.19518092
#> 2025 -0.09354593 -0.06951135
#> 2026  0.15915097  1.22257588
#> 2027  0.29875209  0.25719228
#> 2028 -1.31329880 -0.69076345
#> 2029  2.48926902  1.54309187
#> 2030  1.91175656  0.91165371
#> 2031  2.04130891  1.23352769
#> 2032 -0.29759583 -0.05351566
#> 2033 -1.22025180 -0.56162404
#> 2034 -0.95856611 -0.54609232
#> 2035  0.20717781  0.29095534
#> 2036 -0.70462371 -1.15899926
#> 2037  2.26007518  1.40841386
#> 2038  2.95319223  1.69957104
#> 2039  0.89317411  0.77051186
#> 2040 -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"
print(ahead::loocvridge2f(fpp::usconsumption))
#> $mean
#>         consumption    income
#> 2011 Q1   0.7373376 0.9197108
#> 2011 Q2   0.7523869 0.7436787
#> 2011 Q3   0.7537811 0.8142475
#> 2011 Q4   0.7563826 0.7913050
#> 2012 Q1   0.7568367 0.8009631
#> 
#> $lower
#>         consumption     income
#> 2011 Q1  -0.5227315 -0.7844227
#> 2011 Q2  -0.5076823 -0.9604548
#> 2011 Q3  -0.5062880 -0.8898860
#> 2011 Q4  -0.5036865 -0.9128285
#> 2012 Q1  -0.5032325 -0.9031703
#> 
#> $upper
#>         consumption   income
#> 2011 Q1    1.997407 2.623844
#> 2011 Q2    2.012456 2.447812
#> 2011 Q3    2.013850 2.518381
#> 2011 Q4    2.016452 2.495438
#> 2012 Q1    2.016906 2.505097
#> 
#> $sims
#> NULL
#> 
#> $x
#>         consumption       income
#> 1970 Q1  0.61227692  0.496540045
#> 1970 Q2  0.45492979  1.736459591
#> 1970 Q3  0.87467302  1.344880981
#> 1970 Q4 -0.27251439 -0.328145953
#> 1971 Q1  1.89218699  1.965432327
#> 1971 Q2  0.91337819  1.490757133
#> 1971 Q3  0.79285790  0.442927733
#> 1971 Q4  1.64999566  1.050230993
#> 1972 Q1  1.32724825  0.629713564
#> 1972 Q2  1.88990506  0.934207242
#> 1972 Q3  1.53272416  2.024456496
#> 1972 Q4  2.31705777  3.901784825
#> 1973 Q1  1.81385569  1.129195652
#> 1973 Q2 -0.05055772  0.981487307
#> 1973 Q3  0.35966722  0.503626895
#> 1973 Q4 -0.29331546  1.211474571
#> 1974 Q1 -0.87877094 -1.546943855
#> 1974 Q2  0.34672003 -0.860297695
#> 1974 Q3  0.41195356  0.310671244
#> 1974 Q4 -1.47820468 -0.452458059
#> 1975 Q1  0.83735987 -0.393048299
#> 1975 Q2  1.65397369  4.564235521
#> 1975 Q3  1.41431884 -1.359432036
#> 1975 Q4  1.05310993  1.006575406
#> 1976 Q1  1.97774749  1.462092078
#> 1976 Q2  0.91507218  0.819999864
#> 1976 Q3  1.05074607  0.896376224
#> 1976 Q4  1.29519619  0.715996597
#> 1977 Q1  1.13545889  0.082385052
#> 1977 Q2  0.55153240  1.131054305
#> 1977 Q3  0.95015960  1.490114704
#> 1977 Q4  1.49616150  1.995499552
#> 1978 Q1  0.58229978  0.614904129
#> 1978 Q2  2.11467168  1.141343133
#> 1978 Q3  0.41869886  0.808026906
#> 1978 Q4  0.80276430  0.782540078
#> 1979 Q1  0.50412878  1.087249832
#> 1979 Q2 -0.05855113 -0.700631545
#> 1979 Q3  0.97755597  0.568900915
#> 1979 Q4  0.26591209  0.797134552
#> 1980 Q1 -0.17368425  0.279831351
#> 1980 Q2 -2.29656300 -1.409415369
#> 1980 Q3  1.06691983  1.024445050
#> 1980 Q4  1.32441742  2.043130338
#> 1981 Q1  0.54583283 -0.229300048
#> 1981 Q2  0.00000000  0.013772840
#> 1981 Q3  0.40482184  2.193050433
#> 1981 Q4 -0.75874883  0.201893379
#> 1982 Q1  0.64399814  0.116463988
#> 1982 Q2  0.35685950  0.698172650
#> 1982 Q3  0.76412375  0.436938581
#> 1982 Q4  1.80788661  0.351269015
#> 1983 Q1  0.97593734  0.784231599
#> 1983 Q2  1.96559809  0.726007440
#> 1983 Q3  1.75134970  1.489909944
#> 1983 Q4  1.57374005  2.042140999
#> 1984 Q1  0.85322727  2.163513516
#> 1984 Q2  1.42002574  1.707008683
#> 1984 Q3  0.76950200  1.545359737
#> 1984 Q4  1.30747803  0.946974902
#> 1985 Q1  1.68128155 -0.246259445
#> 1985 Q2  0.90791081  1.966841071
#> 1985 Q3  1.88085044 -0.620830801
#> 1985 Q4  0.21986403  1.030018787
#> 1986 Q1  0.83153359  1.183355120
#> 1986 Q2  1.05966370  1.128116143
#> 1986 Q3  1.73244172  0.523753063
#> 1986 Q4  0.60006243  0.059897054
#> 1987 Q1 -0.15228800  0.611885129
#> 1987 Q2  1.32935729 -1.090188910
#> 1987 Q3  1.11041685  1.772266694
#> 1987 Q4  0.24012547  1.410476141
#> 1988 Q1  1.65692852  1.248862406
#> 1988 Q2  0.72306031  0.934536046
#> 1988 Q3  0.78681412  0.766858588
#> 1988 Q4  1.17068014  0.896061766
#> 1989 Q1  0.36522624  1.130999186
#> 1989 Q2  0.44694325 -0.411533933
#> 1989 Q3  1.03134287  0.645197097
#> 1989 Q4  0.48794531  0.762948357
#> 1990 Q1  0.78786794  0.750360325
#> 1990 Q2  0.32958888  0.655150176
#> 1990 Q3  0.37909401  0.072718052
#> 1990 Q4 -0.78228237 -0.676795704
#> 1991 Q1 -0.28358087  0.307585359
#> 1991 Q2  0.75819378  0.755588074
#> 1991 Q3  0.38256742  0.211957150
#> 1991 Q4 -0.04493204  0.649885878
#> 1992 Q1  1.70442848  1.497981581
#> 1992 Q2  0.59103346  0.763512573
#> 1992 Q3  1.09931218  0.506330196
#> 1992 Q4  1.21261583  1.412562187
#> 1993 Q1  0.40511535 -1.477541558
#> 1993 Q2  0.95540152  1.543168336
#> 1993 Q3  1.07908089  0.212590891
#> 1993 Q4  0.88609934  1.463027070
#> 1994 Q1  1.10781585 -0.400479849
#> 1994 Q2  0.73801073  1.691849180
#> 1994 Q3  0.79832641  0.732048430
#> 1994 Q4  0.98235581  1.317421015
#> 1995 Q1  0.11670364  0.646210704
#> 1995 Q2  0.81643944  0.009071803
#> 1995 Q3  0.89012327  0.745603285
#> 1995 Q4  0.70025668  0.591013847
#> 1996 Q1  0.90999511  1.059530012
#> 1996 Q2  1.12517415  1.068869375
#> 1996 Q3  0.59749105  0.847813936
#> 1996 Q4  0.81104981  0.547321447
#> 1997 Q1  1.00231479  0.890373141
#> 1997 Q2  0.40370845  0.748012589
#> 1997 Q3  1.68561876  1.138248868
#> 1997 Q4  1.13779625  1.379965421
#> 1998 Q1  0.98935016  2.248544314
#> 1998 Q2  1.70668759  1.417721496
#> 1998 Q3  1.31690105  1.045312610
#> 1998 Q4  1.52238359  0.730112366
#> 1999 Q1  0.98149855  0.675449171
#> 1999 Q2  1.56147049  0.228461748
#> 1999 Q3  1.19479035  0.644917550
#> 1999 Q4  1.40026421  1.555650840
#> 2000 Q1  1.50504064  2.079917327
#> 2000 Q2  0.93588274  1.019653998
#> 2000 Q3  0.97432184  1.055609188
#> 2000 Q4  0.88064976  0.149548646
#> 2001 Q1  0.39868539  0.748024500
#> 2001 Q2  0.37651229 -0.274110069
#> 2001 Q3  0.43918859  2.514669298
#> 2001 Q4  1.55369100 -1.173044414
#> 2002 Q1  0.34382689  2.659477606
#> 2002 Q2  0.50665404  0.549165469
#> 2002 Q3  0.67571194 -0.343744371
#> 2002 Q4  0.35472465  0.236234260
#> 2003 Q1  0.50387273  0.367138124
#> 2003 Q2  0.98555573  1.501775306
#> 2003 Q3  1.33766670  1.390030780
#> 2003 Q4  0.54254673  0.573803177
#> 2004 Q1  0.88074795  0.443164179
#> 2004 Q2  0.44397949  0.983686803
#> 2004 Q3  0.87037870  0.666082163
#> 2004 Q4  1.07395152  1.388903698
#> 2005 Q1  0.79393888 -1.225522766
#> 2005 Q2  0.98477889  0.701673549
#> 2005 Q3  0.75627802  0.594778066
#> 2005 Q4  0.24819787  0.545328307
#> 2006 Q1  1.01902713  1.855678610
#> 2006 Q2  0.60048219  0.882341774
#> 2006 Q3  0.59799998  0.479144681
#> 2006 Q4  0.92584113  1.302357376
#> 2007 Q1  0.55424125  0.451389832
#> 2007 Q2  0.38257957  0.149334878
#> 2007 Q3  0.43929546  0.392083863
#> 2007 Q4  0.29465872  0.548559897
#> 2008 Q1 -0.25266521  1.430770981
#> 2008 Q2 -0.03553182  1.973964634
#> 2008 Q3 -0.97177447 -2.308604067
#> 2008 Q4 -1.31350400 -0.057706851
#> 2009 Q1 -0.38748400 -0.969060881
#> 2009 Q2 -0.47008302  0.063290188
#> 2009 Q3  0.57400096 -1.392556217
#> 2009 Q4  0.10932885 -0.144713401
#> 2010 Q1  0.67101795  1.187165135
#> 2010 Q2  0.71771819  1.354354721
#> 2010 Q3  0.65314326  0.561169813
#> 2010 Q4  0.87535215  0.371057940
#> 
#> $level
#> [1] 95
#> 
#> $method
#> [1] "ridge2"
#> 
#> $residuals
#> Time Series:
#> Start = 1970 
#> End = 2132 
#> Frequency = 1 
#>        consumption      income
#> 1970 -0.2331614550  0.94156006
#> 1971  0.2192118592  1.08168224
#> 1972 -1.0954381614 -1.02642996
#> 1973  1.5124038826  1.49931520
#> 1974 -0.3771393349  0.35732173
#> 1975 -0.0506865853 -0.23372287
#> 1976  0.9239219899  0.17436919
#> 1977  0.1578510125 -0.48683640
#> 1978  0.9404233021 -0.12299569
#> 1979  0.2977338655  0.79642872
#> 1980  1.1947866905  2.96031507
#> 1981  0.3044181569  0.26005568
#> 1982 -1.3008845581 -0.18633757
#> 1983 -0.1439701144  0.35862704
#> 1984 -0.9357053427  0.60269964
#> 1985 -1.2955477147 -1.43790038
#> 1986  0.2916830364 -1.34684520
#> 1987 -0.0358179935 -0.57314256
#> 1988 -2.0945905363 -1.18308986
#> 1989  0.6918511853  0.02765288
#> 1990  1.0242529803  3.54923451
#> 1991  0.1681801533 -1.52636860
#> 1992  0.4041925684 -0.38227968
#> 1993  1.0811575182  0.55824591
#> 1994 -0.4308721073 -0.37515259
#> 1995  0.2182298131  0.02846275
#> 1996  0.3969873869 -0.19405305
#> 1997  0.1785764797 -0.94879976
#> 1998 -0.2133463786  0.06409528
#> 1999  0.2708208867  0.95192925
#> 2000  0.6369843631  1.29214881
#> 2001 -0.5235894228 -0.31006703
#> 2002  1.4129191679  0.40595296
#> 2003 -0.9498691939 -0.47480336
#> 2004  0.1505858209  0.23512913
#> 2005 -0.2733546751  0.25585749
#> 2006 -0.7164724886 -1.21955132
#> 2007  0.6099715558 -0.12751255
#> 2008 -0.5354542028 -0.13371536
#> 2009 -0.7823102270 -0.15858911
#> 2010 -2.8045414131 -1.69687295
#> 2011  1.2395178705  1.68017698
#> 2012  0.4213970217  1.13563857
#> 2013 -0.4883326449 -1.01445500
#> 2014 -0.5783212443 -0.85934103
#> 2015 -0.0851304264  1.65844402
#> 2016 -1.4058816648  0.12970813
#> 2017  0.2901616584  0.23821417
#> 2018 -0.2902795770 -0.16464311
#> 2019  0.1220420227 -0.10084294
#> 2020  1.0897223303 -0.51381341
#> 2021 -0.0944498302 -0.50353755
#> 2022  1.1156798734 -0.17037056
#> 2023  0.5348497048  0.19974137
#> 2024  0.3413574446  0.92719510
#> 2025 -0.2869998070  1.19851380
#> 2026  0.5829315611  1.30195451
#> 2027 -0.2957809447  0.57731081
#> 2028  0.5236007542  0.39244175
#> 2029  0.6669382649 -1.24591558
#> 2030  0.0225730325  0.63436639
#> 2031  1.0260844738 -1.13199389
#> 2032 -0.6565399212 -0.43889013
#> 2033  0.2529006085  0.85501634
#> 2034  0.2596928119  0.40608088
#> 2035  0.8356698597 -0.37461846
#> 2036 -0.4807541752 -1.17144107
#> 2037 -0.7812418809 -0.24131632
#> 2038  0.8288399690 -1.28111801
#> 2039  0.4480169178  0.45685259
#> 2040 -0.6952722392  0.68748579
#> 2041  1.0995886217  1.03001803
#> 2042 -0.4683733788 -0.16305901
#> 2043  0.0400805474  0.03849011
#> 2044  0.4007495488  0.06919595
#> 2045 -0.5849810399  0.17650881
#> 2046 -0.1666540429 -0.81393245
#> 2047  0.5010081587 -0.21423203
#> 2048 -0.3514900073 -0.17681505
#> 2049  0.1123784390  0.13719603
#> 2050 -0.4404046425 -0.17345656
#> 2051 -0.2581478848 -0.45904373
#> 2052 -1.3579772508 -1.43857351
#> 2053 -0.5103275184  0.09191941
#> 2054  0.2740377581  0.56186316
#> 2055 -0.3740235474 -0.60242996
#> 2056 -0.6393802004 -0.09312940
#> 2057  1.1754762572  1.24039448
#> 2058 -0.6177548032 -0.33466345
#> 2059  0.3939523863 -0.18259096
#> 2060  0.3788025719  0.42455670
#> 2061 -0.5635331385 -2.39617352
#> 2062  0.5724267884  0.54626978
#> 2063  0.2161635095 -0.47653111
#> 2064  0.1184998238  0.43778190
#> 2065  0.2766679524 -1.06689977
#> 2066  0.0420418617  0.56614619
#> 2067  0.0236804018  0.24989731
#> 2068  0.2125295749  0.48187149
#> 2069 -0.7512590281 -0.13892159
#> 2070  0.2403268368 -0.36878845
#> 2071  0.2139342604 -0.20266609
#> 2072 -0.1079008757 -0.27808290
#> 2073  0.1879040963  0.24265480
#> 2074  0.2953406378  0.24832487
#> 2075 -0.3334405505 -0.07702869
#> 2076  0.1098370901 -0.11878787
#> 2077  0.2583077034  0.02226017
#> 2078 -0.4705105337 -0.14564093
#> 2079  1.0335035262  0.58225446
#> 2080 -0.0653746871  0.26340373
#> 2081  0.0534659027  1.37272032
#> 2082  0.8092517747  0.94351439
#> 2083  0.1049494266 -0.05876061
#> 2084  0.4952813338 -0.26265381
#> 2085 -0.0658124656 -0.44181534
#> 2086  0.7342593334 -0.68717464
#> 2087  0.2470336223 -0.56638120
#> 2088  0.4981539600  0.55231831
#> 2089  0.4493371036  1.09079178
#> 2090 -0.1761869235  0.11693572
#> 2091  0.1346075806  0.20289467
#> 2092  0.0235560235 -0.71864073
#> 2093 -0.3115078723 -0.20592188
#> 2094 -0.2741446687 -0.82640027
#> 2095 -0.0913023803  1.70369581
#> 2096  0.8827823993 -1.16083732
#> 2097 -0.3636698347  1.24113047
#> 2098 -0.1277978244  0.67917001
#> 2099 -0.0007782507 -1.04785675
#> 2100 -0.2411645608 -0.70610284
#> 2101 -0.0888971987 -0.35021777
#> 2102  0.3410270697  0.73207046
#> 2103  0.4630962693  0.66515211
#> 2104 -0.4861568985 -0.40419002
#> 2105  0.1934661935 -0.27854487
#> 2106 -0.3039635158  0.07223429
#> 2107  0.2234105933  0.15749362
#> 2108  0.2915324118  0.51498276
#> 2109 -0.1150330390 -2.05234634
#> 2110  0.4728083725 -0.41632113
#> 2111 -0.0781809229 -0.31801165
#> 2112 -0.4882969879 -0.29370905
#> 2113  0.3975571281  1.34795984
#> 2114 -0.2984017519  0.25345526
#> 2115 -0.1016146655 -0.17787652
#> 2116  0.2435324690  0.51072488
#> 2117 -0.2892450783 -0.29816422
#> 2118 -0.2852898034 -0.62858127
#> 2119 -0.1471096634 -0.36000792
#> 2120 -0.3413694729 -0.16913638
#> 2121 -0.8873848342  0.88988298
#> 2122 -0.4484411727  2.12477862
#> 2123 -1.4252970242 -2.13808348
#> 2124 -1.2475691203 -0.61689217
#> 2125 -0.5989010146 -0.52353888
#> 2126 -0.7214447804 -0.53868023
#> 2127  0.1575240776 -1.54020389
#> 2128 -0.3265300272 -1.19775618
#> 2129  0.1902912192  0.50323524
#> 2130 -0.0140597983  0.74918149
#> 2131 -0.1032639558 -0.02089401
#> 2132  0.1688024258 -0.43104378
#> 
#> $coefficients
#>     consumption      income
#> x1  0.102077302  0.12949577
#> x2  0.006601867 -0.02957051
#> h1  0.092473613  0.04771835
#> h2 -0.053810426 -0.20499353
#> h3 -0.014413797 -0.05815312
#> h4  0.099574873  0.03766025
#> h5 -0.136362528  0.05021583
#> 
#> $loocv
#> [1] 0.6183515
#> 
#> $weighted_loocv
#> [1] -2.493598e-17
#> 
#> $loocv_per_series
#> consumption      income 
#>   0.4371489   0.7995541 
#> 
#> attr(,"class")
#> [1] "mtsforecast"

#foo <- function(xx) ahead::loocvridge2f(fpp::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(fpp::insurance, lambda_1=10^opt$par[1], lambda_2=10^opt$par[2]))