Running examples in ‘logitr-Ex.R’ failed
The error most likely occurred in:

> ### Name: logitr
> ### Title: The main function for estimating logit models
> ### Aliases: logitr
> ### Keywords: logit logitr mixed mnl mxl willingness-to-pay wtp
> 
> ### ** Examples
> 
> # For more detailed examples, visit
> # https://jhelvy.github.io/logitr/articles/
> 
> library(logitr)
> 
> # Estimate a MNL model in the Preference space
> mnl_pref <- logitr(
+   data    = yogurt,
+   outcome = "choice",
+   obsID   = "obsID",
+   pars    = c("price", "feat", "brand")
+ )
Running model...
Done!
> 
> # Estimate a MNL model in the WTP space, using a 5-run multistart
> mnl_wtp <- logitr(
+   data           = yogurt,
+   outcome        = "choice",
+   obsID          = "obsID",
+   pars           = c("feat", "brand"),
+   scalePar       = "price",
+   numMultiStarts = 5
+ )
Running multistart...
  Random starting point iterations: 5
  Number of cores: 15

 *** caught segfault ***
address 0x110, cause 'invalid permissions'

 *** caught segfault ***
address 0x110, cause 'invalid permissions'

 *** caught segfault ***
address 0x110, cause 'invalid permissions'

 *** caught segfault ***

Traceback:
 1: mi$logitFuncs$getMnlV(pars, d$X, d$scalePar)

Traceback:
 2: eval_f(x0, ...)
 1:  3: mi$logitFuncs$getMnlV(pars, d$X, d$scalePar)nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective, 
Traceback:
    mi = mi, opts = mi$options)
 1: 
address 0x110, cause 'invalid permissions'
mi$logitFuncs$getMnlV(pars, d$X, d$scalePar) 4:  2: eval_f(x0, ...)

 2: doTryCatch(return(expr), name, parentenv, handler) 3: 
 *** caught segfault ***
nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective, address 0x110, cause 'invalid permissions'
    mi = mi, opts = mi$options)
 4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)eval_f(x0, ...)
 3: 
 7: tryCatch({    result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective, nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,         mi = mi, opts = mi$options)}, error = function(e) {})
 8:     mi = mi, opts = mi$options)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)

 7:  4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)system.time({
tryCatch({    result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,         mi = mi, opts = mi$options)    model <- mi$model    result <- NULL}, error = function(e) {})
 8: system.time({ 7: tryCatch({    result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,         mi = mi, opts = mi$options)}, error = function(e) {})
 8:     model <- mi$model
Traceback:
 1: system.time({    model <- mi$model    result <- NULL    tryCatch({        result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,             mi = mi, opts = mi$options)    }, error = function(e) {    })    if (!is.null(result)) {mi$logitFuncs$getMnlV(pars, d$X, d$scalePar)
 2:     result <- NULLeval_f(x0, ...)
 3:     tryCatch({        model$fail <- FALSE
Traceback:
        model$coefficients <- result$solution 1: nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,         result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,         model$logLik <- as.numeric(-1 * result$objective)            mi = mi, opts = mi$options)mi$logitFuncs$getMnlV(pars, d$X, d$scalePar)    }, error = function(e) {
 2: eval_f(x0, ...)        model$iterations <- result$iterations        model$status <- result$status        model$message <- result$message    }})

    mi = mi, opts = mi$options) 9:  3: 
    })nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,  4:     mi = mi, opts = mi$options)    tryCatch({    if (!is.null(result)) {
 4: doTryCatch(return(expr), name, parentenv, handler)        model$fail <- FALSE        model$coefficients <- result$solution        result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,         model$logLik <- as.numeric(-1 * result$objective)        model$iterations <- result$iterations
doTryCatch(return(expr), name, parentenv, handler)
 5:  5: tryCatchOne(expr, names, parentenv, handlers[[1L]])FUN(X[[i]], ...)            mi = mi, opts = mi$options)
        model$status <- result$statustryCatchOne(expr, names, parentenv, handlers[[1L]])        model$message <- result$message
    }})10:  6:     }, error = function(e) {
lapply(X = S, FUN = FUN, ...) 6: 
11: doTryCatch(return(expr), name, parentenv, handler)
12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13: tryCatchList(expr, classes, parentenv, handlers)
tryCatchList(expr, classes, parentenv, handlers)
    }) 7: 
14: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {tryCatchList(expr, classes, parentenv, handlers)tryCatch({
        if (identical(call[[1L]], quote(doTryCatch)))     if (!is.null(result)) { 7:     result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective, tryCatch({    result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective,         model$fail <- FALSE            call <- sys.call(-4L)        model$coefficients <- result$solution        model$logLik <- as.numeric(-1 * result$objective)        model$iterations <- result$iterations 9:         dcall <- deparse(call, nlines = 1L)        mi = mi, opts = mi$options)        mi = mi, opts = mi$options)        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        sm <- strsplit(conditionMessage(e), "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")FUN(X[[i]], ...)        model$status <- result$status
}, error = function(e) {})
 8: system.time({    model <- mi$model    result <- NULL    tryCatch({10:         model$message <- result$message        if (is.na(w)) lapply(X = S, FUN = FUN, ...)
}, error = function(e) {        result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective, })
 8: system.time({    model <- mi$model    result <- NULL            mi = mi, opts = mi$options)            w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],     tryCatch({11:     }, error = function(e) {                type = "b")        if (w > LONG)     }doTryCatch(return(expr), name, parentenv, handler)            prefix <- paste0(prefix, "\n  ")    }
        result <- nloptr::nloptr(x0 = mi$model$startVals, eval_f = mi$evalFuncs$objective, 12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
            mi = mi, opts = mi$options)13:     })})
 9: FUN(X[[i]], ...)
    if (!is.null(result)) {tryCatchList(expr, classes, parentenv, handlers)    }, error = function(e) {    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }        model$fail <- FALSE
    })        model$coefficients <- result$solution        model$logLik <- as.numeric(-1 * result$objective)        model$iterations <- result$iterations        model$status <- result$status        model$message <- result$message14:     }    invisible(structure(msg, class = "try-error", condition = e))10:     if (!is.null(result)) {tryCatch(expr, error = function(e) {lapply(X = S, FUN = FUN, ...)})    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call, nlines = 1L)})

 9: FUN(X[[i]], ...)11:         model$fail <- FALSE
        prefix <- paste("Error in", dcall, ": ")doTryCatch(return(expr), name, parentenv, handler)15:         LONG <- 75L
12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13:         sm <- strsplit(conditionMessage(e), "\n")[[1L]]tryCatchList(expr, classes, parentenv, handlers)

try(lapply(X = S, FUN = FUN, ...), silent = TRUE)        model$coefficients <- result$solution10:         w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        model$logLik <- as.numeric(-1 * result$objective)lapply(X = S, FUN = FUN, ...)
        model$iterations <- result$iterations
11: doTryCatch(return(expr), name, parentenv, handler)
        model$status <- result$status14: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch))) 16: 12: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))tryCatchOne(expr, names, parentenv, handlers[[1L]])        if (is.na(w))         model$message <- result$message
            call <- sys.call(-4L)        dcall <- deparse(call, nlines = 1L)        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        sm <- strsplit(conditionMessage(e), "\n")[[1L]]            w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L], 13: tryCatchList(expr, classes, parentenv, handlers)
14: tryCatch(expr, error = function(e) {                type = "b")        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")    call <- conditionCall(e)        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)         if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }            prefix <- paste0(prefix, "\n  ")
17: FUN(X[[i]], ...)
18: lapply(seq_len(cores), inner.do)    if (!is.null(call)) {    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    }
    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call, nlines = 1L)        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L})
    .Internal(seterrmessage(msg[1L])) 9: 19: parallel::mclapply(miList, runModel, mc.cores = numCores)    }FUN(X[[i]], ...)
    invisible(structure(msg, class = "try-error", condition = e))})    if (!silent && isTRUE(getOption("show.error.messages"))) {
15: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
16: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))

20:         cat(msg, file = outFile)10: lapply(X = S, FUN = FUN, ...)
11: doTryCatch(return(expr), name, parentenv, handler)
withCallingHandlers(expr, warning = function(w) if (inherits(w, 12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13:     classes)) tryInvokeRestart("muffleWarning"))
tryCatchList(expr, classes, parentenv, handlers)17:         sm <- strsplit(conditionMessage(e), "\n")[[1L]]        .Internal(printDeferredWarnings())21: suppressWarnings(parallel::mclapply(miList, runModel, mc.cores = numCores))
22: withCallingHandlers(expr, message = function(c) if (inherits(c,     classes)) tryInvokeRestart("muffleMessage"))
23:     }
    invisible(structure(msg, class = "try-error", condition = e))        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")})        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG) suppressMessages(suppressWarnings(parallel::mclapply(miList, FUN(X[[i]], ...)
    runModel, mc.cores = numCores)))
24: 14:             prefix <- paste0(prefix, "\n  ")15: 
runMultistart(modelInputs)
25: logitr(data = yogurt, outcome = "choice", obsID = "obsID", pars = c("feat", tryCatch(expr, error = function(e) {try(lapply(X = S, FUN = FUN, ...), silent = TRUE)18:     }lapply(seq_len(cores), inner.do)    "brand"), scalePar = "price", numMultiStarts = 5)

    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call, nlines = 1L)19:         prefix <- paste("Error in", dcall, ": ")parallel::mclapply(miList, runModel, mc.cores = numCores)
20: withCallingHandlers(expr, warning = function(w) if (inherits(w, 
An irrecoverable exception occurred. R is aborting now ...
16:     classes)) tryInvokeRestart("muffleWarning"))        LONG <- 75L
        sm <- strsplit(conditionMessage(e), "\n")[[1L]]21:     else prefix <- "Error : "sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
17: FUN(X[[i]], ...)suppressWarnings(parallel::mclapply(miList, runModel, mc.cores = numCores))        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")    msg <- paste0(prefix, conditionMessage(e), "\n")
    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {18: lapply(seq_len(cores), inner.do)
19: parallel::mclapply(miList, runModel, mc.cores = numCores)
20: 
        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }withCallingHandlers(expr, warning = function(w) if (inherits(w,     classes)) tryInvokeRestart("muffleWarning"))
    invisible(structure(msg, class = "try-error", condition = e))        if (is.na(w)) 22: withCallingHandlers(expr, message = function(c) if (inherits(c,     classes)) tryInvokeRestart("muffleMessage"))
23: suppressMessages(suppressWarnings(parallel::mclapply(miList, 21: })    runModel, mc.cores = numCores)))
24: runMultistart(modelInputs)

25: logitr(data = yogurt, outcome = "choice", obsID = "obsID", pars = c("feat",     "brand"), scalePar = "price", numMultiStarts = 5)            w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG) 15: 
            prefix <- paste0(prefix, "\n  ")suppressWarnings(parallel::mclapply(miList, runModel, mc.cores = numCores))    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {An irrecoverable exception occurred. R is aborting now ...
        cat(msg, file = outFile)try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
16:         .Internal(printDeferredWarnings())    }
    invisible(structure(msg, class = "try-error", condition = e))})
15: 22: withCallingHandlers(expr, message = function(c) if (inherits(c,     classes)) tryInvokeRestart("muffleMessage"))
23: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
17: FUN(X[[i]], ...)
18: lapply(seq_len(cores), inner.do)
19: parallel::mclapply(miList, runModel, mc.cores = numCores)
suppressMessages(suppressWarnings(parallel::mclapply(miList, try(lapply(X = S, FUN = FUN, ...), silent = TRUE)    runModel, mc.cores = numCores)))
16: 
24: runMultistart(modelInputs)20: 
sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))withCallingHandlers(expr, warning = function(w) if (inherits(w,     classes)) tryInvokeRestart("muffleWarning"))
21: suppressWarnings(parallel::mclapply(miList, runModel, mc.cores = numCores))
22: withCallingHandlers(expr, message = function(c) if (inherits(c,     classes)) tryInvokeRestart("muffleMessage"))
23: 
25: logitr(data = yogurt, outcome = "choice", obsID = "obsID", pars = c("feat",     "brand"), scalePar = "price", numMultiStarts = 5)
suppressMessages(suppressWarnings(parallel::mclapply(miList, An irrecoverable exception occurred. R is aborting now ...
    runModel, mc.cores = numCores)))17: FUN(X[[i]], ...)
18: lapply(seq_len(cores), inner.do)
19: parallel::mclapply(miList, runModel, mc.cores = numCores)
20: withCallingHandlers(expr, warning = function(w) if (inherits(w,     classes)) tryInvokeRestart("muffleWarning"))
24: runMultistart(modelInputs)
25: logitr(data = yogurt, outcome = "choice", obsID = "obsID", pars = c("feat",     "brand"), scalePar = "price", numMultiStarts = 5)

21: suppressWarnings(parallel::mclapply(miList, runModel, mc.cores = numCores))
22: withCallingHandlers(expr, message = function(c) if (inherits(c,     classes)) tryInvokeRestart("muffleMessage"))
23: suppressMessages(suppressWarnings(parallel::mclapply(miList,     runModel, mc.cores = numCores)))
24: runMultistart(modelInputs)
25: logitr(data = yogurt, outcome = "choice", obsID = "obsID", pars = c("feat",     "brand"), scalePar = "price", numMultiStarts = 5)
An irrecoverable exception occurred. R is aborting now ...
An irrecoverable exception occurred. R is aborting now ...
Error in names(x) <- value : 
  'names' attribute [3] must be the same length as the vector [0]
Calls: logitr -> getMultistartSummary -> colnames<-
Execution halted