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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: turboem
> ### Title: A suite of acceleration schemes for fixed-point iterations
> ### Aliases: turboem
> ### Keywords: optimization, EM algorithm, MM algorithm, fixed-point
> ###   iteration
> 
> ### ** Examples
> 
> ###########################################################################
> # Also see the vignette by typing:
> #  vignette("turboEM")
> #
> # EM algorithm for Poisson mixture estimation 
> 
> fixptfn <- function(p,y) {
+ # The fixed point mapping giving a single E and M step of the EM algorithm
+ # 
+ pnew <- rep(NA,3)
+ i <- 0:(length(y)-1)
+ zi <- p[1]*exp(-p[2])*p[2]^i / (p[1]*exp(-p[2])*p[2]^i + (1 - p[1])*exp(-p[3])*p[3]^i)
+ pnew[1] <- sum(y*zi)/sum(y)
+ pnew[2] <- sum(y*i*zi)/sum(y*zi)
+ pnew[3] <- sum(y*i*(1-zi))/sum(y*(1-zi))
+ p <- pnew
+ return(pnew)
+ }
> 
> objfn <- function(p,y) {
+ # Objective function whose local minimum is a fixed point 
+ # negative log-likelihood of binary poisson mixture
+ i <- 0:(length(y)-1)
+ loglik <- y*log(p[1]*exp(-p[2])*p[2]^i/exp(lgamma(i+1)) + 
+ 		(1 - p[1])*exp(-p[3])*p[3]^i/exp(lgamma(i+1)))
+ return ( -sum(loglik) )
+ }
> 
> # Real data from Hasselblad (JASA 1969)
> poissmix.dat <- data.frame(death = 0:9, 
+ 	freq = c(162,267,271,185,111,61,27,8,3,1))
> y <- poissmix.dat$freq
> 
> # Use a preset seed so the example is reproducable. 
> require("setRNG")
Loading required package: setRNG
> old.seed <- setRNG(list(kind = "Mersenne-Twister", normal.kind = "Inversion",
+     seed = 54321))
> 
> p0 <- c(runif(1),runif(2,0,4))  # random starting value
> 
> # Basic EM algorithm, SQUAREM, and parabolic EM, with default settings
> res1 <- turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn, 
+ 	method = c("EM", "squarem", "pem"))
> 
> # To apply the dynamic ECME (decme) acceleration scheme, 
> # we need to include a boundary function
> boundary <- function(par, dr) {
+ 	lower <- c(0, 0, 0)
+ 	upper <- c(1, 10000, 10000)
+ 	low1 <- max(pmin((lower-par)/dr, (upper-par)/dr))
+ 	upp1 <- min(pmax((lower-par)/dr, (upper-par)/dr))
+ 	return(c(low1, upp1))
+ }
> res2 <- turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn, 
+ 	boundary = boundary, method = c("EM", "squarem", "pem", "decme"))
> 
> # change some of the algorithm-specific default specifications (control.method), 
> # as well as the global control parameters (control.run)
> res3 <- turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn, 
+   boundary = boundary, method = c("em", "squarem", "squarem", "decme", "qn", "qn"), 
+ 	control.method = list(list(), list(K = 2), list(K = 3), 
+ 		list(version = "v3"), list(qn = 1), list(qn = 2)),
+ 	control.run = list(tol = 1e-12, stoptype = "maxtime", maxtime = 1))
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
turboEM
 --- call from context --- 
NULL
 --- call from argument --- 
if (class(p) == "try-error" | any(is.nan(unlist(p))) | any(!is.numeric(p))) stop("Error in function evaluation \n")
 --- R stacktrace ---
where 1: mainfun(input, ctrl = ctrl.alg, fixptfn = fixptfn, objfn = objfn, 
    pconstr = pconstr, project = project, iter = iter, fpeval = fpeval, 
    objfeval = objfeval, boundary = boundary, ...)
where 2: accelerate(par = par, fixptfn = fixptfn, objfn = objfn, boundary = boundary, 
    method = method[j], pconstr = pconstr, project = project, 
    ..., control = modifyList(control.run, control.method[[j]]))
where 3: eval(xpr, envir = envir)
where 4: eval(xpr, envir = envir)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, classes, parentenv, handlers)
where 8: tryCatch(eval(xpr, envir = envir), error = function(e) e)
where 9: doTryCatch(return(expr), name, parentenv, handler)
where 10: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 11: tryCatchList(expr, classes, parentenv, handlers)
where 12: tryCatch({
    repeat {
        args <- nextElem(it)
        if (obj$verbose) {
            cat(sprintf("evaluation # %d:\n", i))
            print(args)
        }
        for (a in names(args)) assign(a, args[[a]], pos = envir, 
            inherits = FALSE)
        r <- tryCatch(eval(xpr, envir = envir), error = function(e) e)
        if (obj$verbose) {
            cat("result of evaluating expression:\n")
            print(r)
        }
        tryCatch(accumulator(list(r), i), error = function(e) {
            cat("error calling combine function:\n")
            print(e)
            NULL
        })
        i <- i + 1
    }
}, error = function(e) {
    if (!identical(conditionMessage(e), "StopIteration")) 
        stop(simpleError(conditionMessage(e), expr))
})
where 13: e$fun(obj, substitute(ex), parent.frame(), e$data)
where 14: foreach(j = seq_along(method), .packages = "turboEM", .errorhandling = "pass") %do% 
    accelerate(par = par, fixptfn = fixptfn, objfn = objfn, boundary = boundary, 
        method = method[j], pconstr = pconstr, project = project, 
        ..., control = modifyList(control.run, control.method[[j]]))
where 15: turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn, boundary = boundary, 
    method = c("em", "squarem", "squarem", "decme", "qn", "qn"), 
    control.method = list(list(), list(K = 2), list(K = 3), list(version = "v3"), 
        list(qn = 1), list(qn = 2)), control.run = list(tol = 1e-12, 
        stoptype = "maxtime", maxtime = 1))

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
 --- function search by body ---
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1