* using log directory ‘/data/gannet/ripley/R/packages/tests-LENGTH1/mcGlobaloptim.Rcheck’ * using R Under development (unstable) (2022-04-26 r82260) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using option ‘--no-stop-on-test-error’ * checking for file ‘mcGlobaloptim/DESCRIPTION’ ... OK * this is package ‘mcGlobaloptim’ version ‘0.1’ * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘mcGlobaloptim’ can be installed ... OK * checking package directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [6s/14s] NOTE call_localoptim: no visible global function definition for ‘optim’ call_localoptim: no visible global function definition for ‘nlminb’ call_localoptim: no visible global function definition for ‘txtProgressBar’ call_localoptim: no visible global function definition for ‘setTxtProgressBar’ call_localoptim : : no visible global function definition for ‘optim’ call_localoptim : : no visible global function definition for ‘nlminb’ multiStartoptim: no visible global function definition for ‘median’ Undefined global functions or variables: median nlminb optim setTxtProgressBar txtProgressBar Consider adding importFrom("stats", "median", "nlminb", "optim") importFrom("utils", "setTxtProgressBar", "txtProgressBar") to your NAMESPACE file. * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... ERROR Running examples in ‘mcGlobaloptim-Ex.R’ failed The error most likely occurred in: > ### Name: multiStartoptim > ### Title: Multistart global optimization using Monte Carlo and Quasi Monte > ### Carlo simulation. > ### Aliases: multiStartoptim > > ### ** Examples > > ### Example from optim : > # "wild" function, global minimum at about -15.81515 > fw <- function (x) + { + 10*sin(0.3*x)*sin(1.3*x^2) + 0.00001*x^4 + 0.2*x+80 + } > plot(fw, -50, 50, n = 1000, main = "optim() minimising 'wild function'") > (minfw <- multiStartoptim(objectivefn = fw, lower = -40, + upper = 40, method = "nlminb", nbtrials = 500, + typerunif = "sobol", verb = TRUE)) | | | 0% | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 9% | |======= | 10% | |======= | 11% | |======== | 11% | |======== | 12% | |========= | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============ | 18% | |============= | 18% | |============= | 19% | |============== | 19% | |============== | 20% | |============== | 21% | |=============== | 21% | |=============== | 22% | |================ | 22% | |================ | 23% | |================= | 24% | |================= | 25% | |================== | 25% | |================== | 26% | |=================== | 27% | |=================== | 28% | |==================== | 28% | |==================== | 29% | |===================== | 29% | |===================== | 30% | |===================== | 31% | |====================== | 31% | |====================== | 32% | |======================= | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 38% | |=========================== | 39% | |============================ | 39% | |============================ | 40% | |============================ | 41% | |============================= | 41% | |============================= | 42% | |============================== | 42% | |============================== | 43% | |=============================== | 44% | |=============================== | 45% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================= | 48% | |================================== | 48% | |================================== | 49% | |=================================== | 49% | |=================================== | 50% | |=================================== | 51% | |==================================== | 51% | |==================================== | 52% | |===================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |======================================== | 58% | |========================================= | 58% | |========================================= | 59% | |========================================== | 59% | |========================================== | 60% | |========================================== | 61% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 62% | |============================================ | 63% | |============================================= | 64% | |============================================= | 65% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |=============================================== | 68% | |================================================ | 68% | |================================================ | 69% | |================================================= | 69% | |================================================= | 70% | |================================================= | 71% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |====================================================== | 78% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 79% | |======================================================== | 80% | |======================================================== | 81% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 82% | |========================================================== | 83% | |=========================================================== | 84% | |=========================================================== | 85% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================= | 88% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 89% | |=============================================================== | 90% | |=============================================================== | 91% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |==================================================================== | 98% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 99% | |======================================================================| 100% $res $res$par [1] -15.81515 $res$objective [1] 67.46773 $res$convergence [1] 0 $res$iterations [1] 5 $res$evaluations function gradient 9 8 $res$message [1] "both X-convergence and relative convergence (5)" $iteration_no [1] 1 2 3 7 8 15 73 131 466 $startingparams_sequence [1] 29.4074334 9.4074334 -30.5925666 -0.5925666 -5.5925666 -15.5925666 [7] -17.4675666 -15.2800666 -14.8113166 $foundparams_sequence [1] 28.303752 10.609181 -29.597542 -1.190591 -4.532845 -16.117845 -15.967215 [8] -15.661611 -15.815151 $objective_val_sequence [1] 84.04052 81.84853 76.56611 76.39410 69.31956 67.52682 67.48679 67.47030 [9] 67.46773 > points(minfw$res$par, minfw$res$objective, pch = 8, lwd = 2, col = "red", cex = 2) > > ### Calibrating the Nelson-Siegel-Svensson model (from Gilli, Schumann (2010)) : > # Nelson - Siegel - Svensson model > NSS2 <- function(betaV, mats) + { + gam1 <- mats / betaV [5] + gam2 <- mats / betaV [6] + aux1 <- 1 - exp (- gam1) + aux2 <- 1 - exp (- gam2) + betaV[1] + betaV[2] * (aux1 / gam1) + + betaV[3] * (aux1 / gam1 + aux1 - 1) + + betaV[4] * (aux2 / gam2 + aux2 - 1) + } > > betaTRUE <- c(5, -2 ,5, -5 ,1 ,3) > mats <- c(1 ,3 ,6 ,9 ,12 ,15 ,18 ,21 ,24 ,30 ,36 ,48 ,60 ,72 ,84 , + 96,108 ,120)/ 12 > yM <- NSS2 (betaTRUE, mats) > dataList <- list ( yM = yM, mats = mats, model = NSS2) > plot (mats, yM, xlab = " maturities in years ", ylab =" yields in pct. ") > > # define objective function > OF <- function (betaV, dataList) { + mats <- dataList$mats + yM <- dataList$yM + model <- dataList$model + y <- model(betaV, mats) + aux <- y - yM + crossprod(aux) + } > > settings <- list (min = c( 0, -15, -30, -30 ,0 ,3), + max = c (15, 30, 30, 30 ,3 ,6), d = 6) > NSStest <- multiStartoptim(objectivefn = OF, data = dataList, + lower = settings$min, + upper = settings$max, + method = "nlminb", + nbtrials = 50, typerunif = "torus") ----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref --- : --- package (from environment) --- mcGlobaloptim --- call from context --- multiStartoptim(objectivefn = OF, data = dataList, lower = settings$min, upper = settings$max, method = "nlminb", nbtrials = 50, typerunif = "torus") --- call from argument --- nbpar != length(upper) || lower > upper --- R stacktrace --- where 1: multiStartoptim(objectivefn = OF, data = dataList, lower = settings$min, upper = settings$max, method = "nlminb", nbtrials = 50, typerunif = "torus") --- value of length: 6 type: logical --- [1] FALSE FALSE FALSE FALSE FALSE FALSE --- function from context --- function (start0 = NULL, objectivefn, gradient = NULL, ..., hessian = NULL, lower = -Inf, upper = Inf, control = list(), method = c("L-BFGS-B", "Nelder-Mead", "nlminb"), nbtrials = NULL, typerunif = c("runifbase", "runifantithetics", "sobol", "torus", "niederreiterlodisp"), localsearch = c("exhaustive", "median"), verb = FALSE, nbclusters = NULL) { if (missing(objectivefn)) stop("Objective function must be provided") nbpar <- length(lower) if (nbpar != length(upper) || lower > upper) stop("parameter lower must be lower than parameter upper componentwise, and they must have the same length") if (missing(method) || !(method %in% c("L-BFGS-B", "Nelder-Mead", "nlminb"))) { warning("optimization method is missing or inadequate, default is set to nlminb") themethod <- "nlminb" } else { themethod <- match.arg(method) } if (missing(nbclusters) || is.null(nbclusters) || nbclusters <= 1) { if (missing(start0) && (missing(nbtrials) || nbtrials <= 0)) stop("When nbtrials is missing or equal to 0, starting parameters 'start0' should be provided") if (missing(nbtrials) || is.null(nbtrials) || nbtrials <= 0) { if (!missing(typerunif)) warning("unused argument typerunif") if (missing(hessian) && themethod %in% c("L-BFGS-B", "Nelder-Mead")) hessian <- FALSE return(call_localoptim(start0 = start0, objectivefn = objectivefn, gradient = gradient, ..., hessian = hessian, lower = lower, upper = upper, control = control, themethod = themethod, nbtrials = nbtrials, verb = verb, cl = NULL)) } else { if (!missing(start0)) warning("starting value is unused when nbtrials is provided") if (missing(typerunif) || !(typerunif %in% c("runifbase", "runifantithetics", "sobol", "torus", "niederreiterlodisp"))) { warning("typerunif is either missing or inadequate, and was set to default 'runifbase'") typerunif <- "runifbase" } else { typerunif <- match.arg(typerunif) } if (!is.finite(lower) || !is.finite(upper)) stop("Both the lower and upper bounds for parameters should be provided and finite") localsearch <- match.arg(localsearch) if (length(localsearch) == 0) localsearch <- "exhaustive" if (localsearch == "exhaustive") { start0 <- rUnif(nbtrials = nbtrials, nbpar = nbpar, lower = lower, upper = upper, method = typerunif) } if (localsearch == "median") { if (nbpar == 1) { U <- rUnif(nbtrials = nbtrials, nbpar = nbpar, lower = lower, upper = upper, method = typerunif) fwU <- objectivefn(U, ...) start0 <- U[fwU < median(fwU)] nbtrials <- length(start0) } else { U <- rUnif(nbtrials = nbtrials, nbpar = nbpar, lower = lower, upper = upper, method = typerunif) fwU <- apply(U, 1, function(x) objectivefn(x, ...)) start0 <- U[fwU < median(fwU), ] nbtrials <- dim(start0)[1] } } if (missing(hessian) && themethod %in% c("L-BFGS-B", "Nelder-Mead")) hessian <- FALSE return(call_localoptim(start0 = start0, objectivefn = objectivefn, gradient = gradient, ..., hessian = hessian, lower = lower, upper = upper, control = control, themethod = themethod, nbtrials = nbtrials, verb = verb, cl = NULL)) } } else { if (nbclusters < 0 || floor(nbclusters) != nbclusters || is.array(nbclusters) || !is.numeric(nbclusters)) stop("nbclusters must be a positive integer") if (missing(lower) || missing(upper)) stop("lower and upper are missing and must be provided") if (!is.finite(lower) || !is.finite(upper)) stop("Both the lower and upper bounds for parameters should be provided and finite") if (verb) warning("argument verb is unused in parallel computation") if (missing(nbtrials) || is.null(nbtrials) || nbtrials <= 0) { warning("nbtrials is not provided (or negative), default is set to 50") nbtrials <- 50 } if (missing(typerunif) || !(typerunif %in% c("runifbase", "runifantithetics", "sobol", "torus", "niederreiterlodisp"))) { warning("typerunif is either missing or inadequate, and was set to default 'runifbase'") typerunif <- "runifbase" } else { typerunif <- match.arg(typerunif) } localsearch <- match.arg(localsearch) if (length(localsearch) == 0) localsearch <- "exhaustive" if (localsearch == "exhaustive") { start0 <- rUnif(nbtrials = nbtrials, nbpar = nbpar, lower = lower, upper = upper, method = typerunif) } if (localsearch == "median") { if (nbpar == 1) { U <- rUnif(nbtrials = nbtrials, nbpar = nbpar, lower = lower, upper = upper, method = typerunif) fwU <- objectivefn(U, ...) start0 <- U[fwU < median(fwU)] nbtrials <- length(start0) } else { U <- rUnif(nbtrials = nbtrials, nbpar = nbpar, lower = lower, upper = upper, method = typerunif) fwU <- apply(U, 1, function(x) objectivefn(x, ...)) start0 <- U[fwU < median(fwU), ] nbtrials <- dim(start0)[1] } } if (missing(hessian) && themethod %in% c("L-BFGS-B", "Nelder-Mead")) hessian <- FALSE packageStartupMessage("Processing...", appendLF = FALSE) cat("\n") return(call_localoptim(start0 = start0, objectivefn = objectivefn, gradient = gradient, ..., hessian = hessian, lower = lower, upper = upper, control = control, themethod = themethod, nbtrials = nbtrials, verb = verb, cl = nbclusters)) } } --- function search by body --- Function multiStartoptim in namespace mcGlobaloptim has this body. ----------- END OF FAILURE REPORT -------------- Fatal error: length > 1 in coercion to logical * checking PDF version of manual ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE Status: 1 ERROR, 1 NOTE See ‘/data/gannet/ripley/R/packages/tests-LENGTH1/mcGlobaloptim.Rcheck/00check.log’ for details. Command exited with non-zero status 1 Time 1:28.33, 28.00 + 5.67