2020# ' @param seed an value specifying if and how the random number generator should
2121# ' be initialized (\sQuote{seeded}). Either NULL or an integer that will be used in a
2222# ' call to set.seed before simulating the response vectors.
23+ # ' @param solver either \dQuote{nlortr} or \dQuote{solnp}.
2324# ' @param trace whether to show the progress bar. The user is expected to have
2425# ' set up appropriate handlers for this using the \dQuote{progressr} package.
2526# ' @param ... not used.
5657# '
5758tsbacktest.tsissm.autospec <- function (object , start = floor(length(object $ y )/ 2 ), end = length(object $ y ),
5859 h = 1 , estimate_every = 1 , rolling = FALSE , weights_scheme = c(" AIC" ," BIC" ," U" ), weights = NULL ,
59- seed = NULL , trace = FALSE , ... )
60+ seed = NULL , solver = " nloptr " , trace = FALSE , ... )
6061{
6162 if (object $ top_n > 1 ) {
6263 top_n <- object $ top_n
@@ -67,9 +68,10 @@ tsbacktest.tsissm.autospec <- function(object, start = floor(length(object$y)/2)
6768 weights_scheme <- " U"
6869 }
6970 out <- .backtest_ensemble(object , start = start , end = end , h = h , estimate_every = estimate_every , rolling = rolling , weights_scheme = weights_scheme ,
70- weights = weights , seed = seed , trace = trace )
71+ weights = weights , seed = seed , solver = solver , trace = trace )
7172 } else {
72- out <- .backtest_top(object , start = start , end = end , h = h , estimate_every = estimate_every , rolling = rolling , seed = seed , trace = trace )
73+ out <- .backtest_top(object , start = start , end = end , h = h , estimate_every = estimate_every , rolling = rolling , seed = seed , solver = solver ,
74+ trace = trace )
7375 }
7476 return (out )
7577}
@@ -78,7 +80,7 @@ tsbacktest.tsissm.autospec <- function(object, start = floor(length(object$y)/2)
7880# ' @rdname tsbacktest
7981# ' @export
8082tsbacktest.tsissm.spec <- function (object , start = floor(length(object $ target $ y_orig )/ 2 ), end = length(object $ target $ y_orig ),
81- h = 1 , estimate_every = 1 , rolling = FALSE , seed = NULL , trace = FALSE , ... )
83+ h = 1 , estimate_every = 1 , rolling = FALSE , seed = NULL , solver = " nloptr " , trace = FALSE , ... )
8284{
8385 parameter <- b <- forecast_dates <- NULL
8486 data <- xts(object $ target $ y_orig , object $ target $ index )
@@ -150,7 +152,7 @@ tsbacktest.tsissm.spec <- function(object, start = floor(length(object$target$y_
150152 sampling = object $ target $ sampling , sample_n = object $ variance $ sample_n ,
151153 init_garch = object $ variance $ init_variance , garch_order = object $ variance $ order ,
152154 variance = object $ variance $ type , distribution = object $ distribution $ type )
153- mod <- try(estimate(spec , scores = FALSE ), silent = TRUE )
155+ mod <- try(estimate(spec , solver = solver , scores = FALSE ), silent = TRUE )
154156 model_coef <- coef(mod )
155157 log_lik <- as.numeric(logLik(mod ))
156158 aic <- as.numeric(AIC(mod ))
@@ -240,7 +242,8 @@ tsbacktest.tsissm.spec <- function(object, start = floor(length(object$target$y_
240242}
241243
242244.backtest_top <- function (object , start = floor(length(object $ y )/ 2 ), end = length(object $ y ), h = 1 ,
243- estimate_every = 1 , rolling = FALSE , seed = NULL , trace = FALSE , ... )
245+ estimate_every = 1 , rolling = FALSE , seed = NULL , solver = " nloptr" ,
246+ trace = FALSE , ... )
244247{
245248 parameter <- b <- forecast_dates <- NULL
246249 data <- object $ y
@@ -302,7 +305,7 @@ tsbacktest.tsissm.spec <- function(object, start = floor(length(object$target$y_
302305 sampling = object $ sampling , sample_n = object $ sample_n ,
303306 init_garch = object $ init_garch , garch_order = object $ garch_order ,
304307 variance = object $ variance , distribution = object $ distribution , top_n = 1 )
305- mod <- try(estimate(spec , trace = FALSE ), silent = TRUE )
308+ mod <- try(estimate(spec , solver = solver , trace = FALSE ), silent = TRUE )
306309 model_coef <- coef(mod )
307310 log_lik <- as.numeric(logLik(mod ))
308311 aic <- as.numeric(AIC(mod ))
@@ -391,7 +394,7 @@ tsbacktest.tsissm.spec <- function(object, start = floor(length(object$target$y_
391394
392395.backtest_ensemble <- function (object , start = floor(length(object $ y )/ 2 ), end = length(object $ y ),
393396 h = 1 , estimate_every = 1 , rolling = FALSE , weights_scheme = c(" U" ," AIC" ," BIC" ), weights = NULL ,
394- seed = NULL , trace = FALSE , ... )
397+ seed = NULL , solver = " nloptr " , trace = FALSE , ... )
395398{
396399 if (weights_scheme == " U" ) {
397400 wfun <- function (x ) {
@@ -467,7 +470,7 @@ tsbacktest.tsissm.spec <- function(object, start = floor(length(object$target$y_
467470 sampling = object $ sampling , sample_n = object $ sample_n ,
468471 init_garch = object $ init_garch , garch_order = object $ garch_order ,
469472 variance = object $ variance , distribution = object $ distribution , top_n = top_n )
470- mod <- try(estimate(spec , trace = FALSE ), silent = TRUE )
473+ mod <- try(estimate(spec , solver = solver , trace = FALSE ), silent = TRUE )
471474 w <- wfun(mod )
472475 L <- index_table [[i ]]
473476 M <- split(L , by = " filter_date" )
0 commit comments