CRAN Package Check Results for Package misaem

Last updated on 2019-11-26 00:51:58 CET.

Flavor Version Tinstall Tcheck Ttotal Status Flags
r-devel-linux-x86_64-debian-clang 0.9.1 2.59 26.58 29.17 ERROR
r-devel-linux-x86_64-debian-gcc 0.9.1 2.23 21.72 23.95 ERROR
r-devel-linux-x86_64-fedora-clang 0.9.1 245.84 OK
r-devel-linux-x86_64-fedora-gcc 0.9.1 243.06 OK
r-devel-windows-ix86+x86_64 0.9.1 10.00 230.00 240.00 OK
r-devel-windows-ix86+x86_64-gcc8 0.9.1 9.00 203.00 212.00 OK
r-patched-linux-x86_64 0.9.1 2.09 213.92 216.01 OK
r-patched-solaris-x86 0.9.1 297.30 OK
r-release-linux-x86_64 0.9.1 2.24 212.07 214.31 OK
r-release-windows-ix86+x86_64 0.9.1 8.00 206.00 214.00 OK
r-release-osx-x86_64 0.9.1 OK
r-oldrel-windows-ix86+x86_64 0.9.1 3.00 263.00 266.00 OK
r-oldrel-osx-x86_64 0.9.1 OK

Check Details

Version: 0.9.1
Check: examples
Result: ERROR
    Running examples in 'misaem-Ex.R' failed
    The error most likely occurred in:
    
    > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
    > ### Name: miss.saem
    > ### Title: miss.saem
    > ### Aliases: miss.saem
    >
    > ### ** Examples
    >
    > # Generate dataset
    > N <- 100 # number of subjects
    > p <- 3 # number of explanatory variables
    > mu.star <- rep(0,p) # mean of the explanatory variables
    > Sigma.star <- diag(rep(1,p)) # covariance
    > beta.star <- c(1, 1, 0) # coefficients
    > beta0.star <- 0 # intercept
    > beta.true = c(beta0.star,beta.star)
    > X.complete <- matrix(rnorm(N*p), nrow=N)%*%chol(Sigma.star) +
    + matrix(rep(mu.star,N), nrow=N, byrow = TRUE)
    > p1 <- 1/(1+exp(-X.complete%*%beta.star-beta0.star))
    > y <- as.numeric(runif(N)<p1)
    > # Generate missingness
    > p.miss <- 0.10
    > patterns <- runif(N*p)<p.miss #missing completely at random
    > X.obs <- X.complete
    > X.obs[patterns] <- NA
    >
    > # SAEM
    > list.saem = miss.saem(X.obs,y)
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    misaem
     --- call from context ---
    miss.saem(X.obs, y)
     --- call from argument ---
    if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
    }
     --- R stacktrace ---
    where 1: miss.saem(X.obs, y)
    
     --- value of length: 2 type: logical ---
    [1] FALSE FALSE
     --- function from context ---
    function (X.obs, y, pos_var = 1:ncol(X.obs), maxruns = 500, tol_em = 1e-07,
     nmcmc = 2, tau = 1, k1 = 50, seed = 200, print_iter = TRUE,
     var_cal = FALSE, ll_obs_cal = FALSE)
    {
     set.seed(seed)
     if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
     }
     if (sum(sapply(X.obs, is.numeric)) < ncol(X.obs)) {
     stop("Error: the variables should be numeric.")
     }
     if (sum(y == 1) + sum(y == 0) < nrow(X.obs)) {
     stop("Error: y must be coded by 0 or 1, and there is no missing data in y.")
     }
     if (sum(pos_var %in% 1:ncol(X.obs)) < length(pos_var)) {
     stop("Error: index of selected variables must be in the range of covariates.")
     }
     if (length(unique(pos_var)) != length(pos_var)) {
     stop("Error: index of selected variables must not be repeated.")
     }
     p = ncol(X.obs)
     if (any(apply(is.na(X.obs), 1, sum) == p)) {
     i_allNA = which(apply(is.na(X.obs), 1, sum) == p)
     X.obs = X.obs[-i_allNA, ]
     y = y[-i_allNA]
     }
     if (any((is.na(y)) == TRUE)) {
     i_YNA = which(is.na(y) == TRUE)
     X.obs = X.obs[-i_YNA, ]
     y = y[-i_YNA]
     }
     n = length(y)
     rindic = as.matrix(is.na(X.obs))
     if (sum(rindic) > 0) {
     whichcolmissing = (1:ncol(rindic))[apply(rindic, 2, sum) >
     0]
     missingcols = length(whichcolmissing)
     }
     if (sum(rindic) == 0) {
     missingcols = 0
     }
     ptm <- Sys.time()
     if (missingcols > 0) {
     k = 0
     cstop = 0.1
     seqbeta = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     seqbeta_avg = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     X.mean = X.obs
     for (i in 1:ncol(X.mean)) {
     X.mean[is.na(X.mean[, i]), i] <- mean(X.mean[, i],
     na.rm = TRUE)
     }
     X.sim <- X.mean
     mu = apply(X.mean, 2, mean)
     Sigma = var(X.mean) * (n - 1)/n
     beta = rep(0, p + 1)
     beta[c(1, pos_var + 1)] = glm(y ~ X.mean[, pos_var],
     family = binomial(link = "logit"))$coef
     while ((cstop > tol_em) * (k < maxruns) | (k < 20)) {
     k = k + 1
     beta.old = beta
     if (k < k1) {
     gamma <- 1
     }
     else {
     gamma <- 1/(k - (k1 - 1))^tau
     }
     S.inv <- solve(Sigma)
     for (i in (1:n)) {
     jna <- which(is.na(X.obs[i, ]))
     njna <- length(jna)
     if (njna > 0) {
     xi <- X.sim[i, ]
     Oi <- solve(S.inv[jna, jna])
     mi <- mu[jna]
     lobs <- beta[1]
     if (njna < p) {
     jobs <- setdiff(1:p, jna)
     mi <- mi - (xi[jobs] - mu[jobs]) %*% S.inv[jobs,
     jna] %*% Oi
     lobs <- lobs + sum(xi[jobs] * beta[jobs +
     1])
     }
     cobs <- exp(lobs)
     if (cobs == 0) {
     cobs = .Machine$double.xmin
     }
     if (cobs == Inf) {
     cobs = .Machine$double.xmax
     }
     xina <- xi[jna]
     betana <- beta[jna + 1]
     for (m in (1:nmcmc)) {
     xina.c <- mi + rnorm(njna) %*% chol(Oi)
     if (y[i] == 1)
     alpha <- (1 + exp(-sum(xina * betana))/cobs)/(1 +
     exp(-sum(xina.c * betana))/cobs)
     else alpha <- (1 + exp(sum(xina * betana)) *
     cobs)/(1 + exp(sum(xina.c * betana)) *
     cobs)
     if (runif(1) < alpha) {
     xina <- xina.c
     }
     }
     X.sim[i, jna] <- xina
     }
     }
     beta_new = rep(0, p + 1)
     beta_new[c(1, pos_var + 1)] = glm(y ~ X.sim[, pos_var],
     family = binomial(link = "logit"))$coef
     beta <- (1 - gamma) * beta + gamma * beta_new
     cstop = sum((beta - beta.old)^2)
     mu <- (1 - gamma) * mu + gamma * colMeans(X.sim)
     Sigma <- (1 - gamma) * Sigma + gamma * cov(X.sim)
     seqbeta[, k] = beta.old
     if (k == 1) {
     seqbeta_avg[, k] = beta.old
     }
     else {
     seqbeta_avg[, k] = 1/k * rowSums(seqbeta[, 1:k])
     }
     if (print_iter == TRUE & k%%10 == 0) {
     cat(sprintf("iteration = %i ", k))
     cat(sprintf("beta ="), beta, "\n")
     cat(sprintf("Distance from last iteration ="),
     cstop, "\n")
     }
     }
     var_obs = ll = std_obs = NULL
     if (var_cal == TRUE) {
     var_obs = louis_lr_saem(beta, mu, Sigma, y, X.obs,
     pos_var, rindic, whichcolmissing, mc.size = 1000)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     if (missingcols == 0) {
     X.obs = matrix(X.obs, nrow = n)
     data.complete <- data.frame(y = y, X.obs)
     model.complete <- glm(y ~ ., family = binomial(link = "logit"),
     data = data.complete)
     mu = apply(X.obs, 2, mean)
     Sigma = var(X.obs) * (n - 1)/n
     beta <- model.complete$coefficients
     var_obs = ll = ll1 = ll2 = std_obs = seqbeta_avg = seqbeta = NULL
     if (var_cal == TRUE) {
     P <- predict(model.complete, type = "response")
     W <- diag(P * (1 - P))
     X <- model.matrix(model.complete)
     var_obs <- solve(t(X) %*% W %*% X)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     time_run = Sys.time() - ptm
     return(list(mu = mu, sig2 = Sigma, beta = beta, time_run = time_run,
     seqbeta = seqbeta, seqbeta_avg = seqbeta_avg, ll = ll,
     var_obs = var_obs, std_obs = std_obs))
    }
    <bytecode: 0x2cb3df0>
    <environment: namespace:misaem>
     --- function search by body ---
    Function miss.saem in namespace misaem has this body.
     ----------- END OF FAILURE REPORT --------------
    Fatal error: the condition has length > 1
Flavor: r-devel-linux-x86_64-debian-clang

Version: 0.9.1
Check: re-building of vignette outputs
Result: WARN
    Error(s) in re-building vignettes:
     ...
    --- re-building 'misaem.Rmd' using rmarkdown
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    misaem
     --- call from context ---
    miss.saem(X.obs, y)
     --- call from argument ---
    if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
    }
     --- R stacktrace ---
    where 1: miss.saem(X.obs, y)
    where 2: eval(expr, envir, enclos)
    where 3: eval(expr, envir, enclos)
    where 4: withVisible(eval(expr, envir, enclos))
    where 5: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler,
     error = eHandler, message = mHandler)
    where 6: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir,
     enclos)), warning = wHandler, error = eHandler, message = mHandler))
    where 7: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr,
     envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
    where 8: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,
     debug = debug, last = i == length(out), use_try = stop_on_error !=
     2L, keep_warning = keep_warning, keep_message = keep_message,
     output_handler = output_handler, include_timing = include_timing)
    where 9: evaluate::evaluate(...)
    where 10: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),
     keep_message = !isFALSE(options$message), stop_on_error = if (options$error &&
     options$include) 0L else 2L, output_handler = knit_handlers(options$render,
     options))
    where 11: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,
     keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),
     stop_on_error = if (options$error && options$include) 0L else 2L,
     output_handler = knit_handlers(options$render, options)))
    where 12: block_exec(params)
    where 13: call_block(x)
    where 14: process_group.block(group)
    where 15: process_group(group)
    where 16: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),
     error = function(e) {
     setwd(wd)
     cat(res, sep = "\n", file = output %n% "")
     message("Quitting from lines ", paste(current_lines(i),
     collapse = "-"), " (", knit_concord$get("infile"),
     ") ")
     })
    where 17: process_file(text, output)
    where 18: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet,
     encoding = encoding)
    where 19: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(),
     ...)
    where 20: vweave_rmarkdown(...)
    where 21: engine$weave(file, quiet = quiet, encoding = enc)
    where 22: doTryCatch(return(expr), name, parentenv, handler)
    where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 24: tryCatchList(expr, classes, parentenv, handlers)
    where 25: tryCatch({
     engine$weave(file, quiet = quiet, encoding = enc)
     setwd(startdir)
     output <- find_vignette_product(name, by = "weave", engine = engine)
     if (!have.makefile && vignette_is_tex(output)) {
     texi2pdf(file = output, clean = FALSE, quiet = quiet)
     output <- find_vignette_product(name, by = "texi2pdf",
     engine = engine)
     }
     outputs <- c(outputs, output)
    }, error = function(e) {
     thisOK <<- FALSE
     fails <<- c(fails, file)
     message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s",
     file, conditionMessage(e)))
    })
    where 26: tools:::buildVignettes(dir = "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/misaem.Rcheck/vign_test/misaem",
     ser_elibs = "/tmp/RtmpSDrxSS/file501a1e4e9502.rds")
    
     --- value of length: 2 type: logical ---
    [1] FALSE FALSE
     --- function from context ---
    function (X.obs, y, pos_var = 1:ncol(X.obs), maxruns = 500, tol_em = 1e-07,
     nmcmc = 2, tau = 1, k1 = 50, seed = 200, print_iter = TRUE,
     var_cal = FALSE, ll_obs_cal = FALSE)
    {
     set.seed(seed)
     if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
     }
     if (sum(sapply(X.obs, is.numeric)) < ncol(X.obs)) {
     stop("Error: the variables should be numeric.")
     }
     if (sum(y == 1) + sum(y == 0) < nrow(X.obs)) {
     stop("Error: y must be coded by 0 or 1, and there is no missing data in y.")
     }
     if (sum(pos_var %in% 1:ncol(X.obs)) < length(pos_var)) {
     stop("Error: index of selected variables must be in the range of covariates.")
     }
     if (length(unique(pos_var)) != length(pos_var)) {
     stop("Error: index of selected variables must not be repeated.")
     }
     p = ncol(X.obs)
     if (any(apply(is.na(X.obs), 1, sum) == p)) {
     i_allNA = which(apply(is.na(X.obs), 1, sum) == p)
     X.obs = X.obs[-i_allNA, ]
     y = y[-i_allNA]
     }
     if (any((is.na(y)) == TRUE)) {
     i_YNA = which(is.na(y) == TRUE)
     X.obs = X.obs[-i_YNA, ]
     y = y[-i_YNA]
     }
     n = length(y)
     rindic = as.matrix(is.na(X.obs))
     if (sum(rindic) > 0) {
     whichcolmissing = (1:ncol(rindic))[apply(rindic, 2, sum) >
     0]
     missingcols = length(whichcolmissing)
     }
     if (sum(rindic) == 0) {
     missingcols = 0
     }
     ptm <- Sys.time()
     if (missingcols > 0) {
     k = 0
     cstop = 0.1
     seqbeta = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     seqbeta_avg = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     X.mean = X.obs
     for (i in 1:ncol(X.mean)) {
     X.mean[is.na(X.mean[, i]), i] <- mean(X.mean[, i],
     na.rm = TRUE)
     }
     X.sim <- X.mean
     mu = apply(X.mean, 2, mean)
     Sigma = var(X.mean) * (n - 1)/n
     beta = rep(0, p + 1)
     beta[c(1, pos_var + 1)] = glm(y ~ X.mean[, pos_var],
     family = binomial(link = "logit"))$coef
     while ((cstop > tol_em) * (k < maxruns) | (k < 20)) {
     k = k + 1
     beta.old = beta
     if (k < k1) {
     gamma <- 1
     }
     else {
     gamma <- 1/(k - (k1 - 1))^tau
     }
     S.inv <- solve(Sigma)
     for (i in (1:n)) {
     jna <- which(is.na(X.obs[i, ]))
     njna <- length(jna)
     if (njna > 0) {
     xi <- X.sim[i, ]
     Oi <- solve(S.inv[jna, jna])
     mi <- mu[jna]
     lobs <- beta[1]
     if (njna < p) {
     jobs <- setdiff(1:p, jna)
     mi <- mi - (xi[jobs] - mu[jobs]) %*% S.inv[jobs,
     jna] %*% Oi
     lobs <- lobs + sum(xi[jobs] * beta[jobs +
     1])
     }
     cobs <- exp(lobs)
     if (cobs == 0) {
     cobs = .Machine$double.xmin
     }
     if (cobs == Inf) {
     cobs = .Machine$double.xmax
     }
     xina <- xi[jna]
     betana <- beta[jna + 1]
     for (m in (1:nmcmc)) {
     xina.c <- mi + rnorm(njna) %*% chol(Oi)
     if (y[i] == 1)
     alpha <- (1 + exp(-sum(xina * betana))/cobs)/(1 +
     exp(-sum(xina.c * betana))/cobs)
     else alpha <- (1 + exp(sum(xina * betana)) *
     cobs)/(1 + exp(sum(xina.c * betana)) *
     cobs)
     if (runif(1) < alpha) {
     xina <- xina.c
     }
     }
     X.sim[i, jna] <- xina
     }
     }
     beta_new = rep(0, p + 1)
     beta_new[c(1, pos_var + 1)] = glm(y ~ X.sim[, pos_var],
     family = binomial(link = "logit"))$coef
     beta <- (1 - gamma) * beta + gamma * beta_new
     cstop = sum((beta - beta.old)^2)
     mu <- (1 - gamma) * mu + gamma * colMeans(X.sim)
     Sigma <- (1 - gamma) * Sigma + gamma * cov(X.sim)
     seqbeta[, k] = beta.old
     if (k == 1) {
     seqbeta_avg[, k] = beta.old
     }
     else {
     seqbeta_avg[, k] = 1/k * rowSums(seqbeta[, 1:k])
     }
     if (print_iter == TRUE & k%%10 == 0) {
     cat(sprintf("iteration = %i ", k))
     cat(sprintf("beta ="), beta, "\n")
     cat(sprintf("Distance from last iteration ="),
     cstop, "\n")
     }
     }
     var_obs = ll = std_obs = NULL
     if (var_cal == TRUE) {
     var_obs = louis_lr_saem(beta, mu, Sigma, y, X.obs,
     pos_var, rindic, whichcolmissing, mc.size = 1000)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     if (missingcols == 0) {
     X.obs = matrix(X.obs, nrow = n)
     data.complete <- data.frame(y = y, X.obs)
     model.complete <- glm(y ~ ., family = binomial(link = "logit"),
     data = data.complete)
     mu = apply(X.obs, 2, mean)
     Sigma = var(X.obs) * (n - 1)/n
     beta <- model.complete$coefficients
     var_obs = ll = ll1 = ll2 = std_obs = seqbeta_avg = seqbeta = NULL
     if (var_cal == TRUE) {
     P <- predict(model.complete, type = "response")
     W <- diag(P * (1 - P))
     X <- model.matrix(model.complete)
     var_obs <- solve(t(X) %*% W %*% X)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     time_run = Sys.time() - ptm
     return(list(mu = mu, sig2 = Sigma, beta = beta, time_run = time_run,
     seqbeta = seqbeta, seqbeta_avg = seqbeta_avg, ll = ll,
     var_obs = var_obs, std_obs = std_obs))
    }
    <bytecode: 0x4ae9188>
    <environment: namespace:misaem>
     --- function search by body ---
    Function miss.saem in namespace misaem has this body.
     ----------- END OF FAILURE REPORT --------------
    Fatal error: the condition has length > 1
Flavor: r-devel-linux-x86_64-debian-clang

Version: 0.9.1
Check: examples
Result: ERROR
    Running examples in ‘misaem-Ex.R’ failed
    The error most likely occurred in:
    
    > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
    > ### Name: miss.saem
    > ### Title: miss.saem
    > ### Aliases: miss.saem
    >
    > ### ** Examples
    >
    > # Generate dataset
    > N <- 100 # number of subjects
    > p <- 3 # number of explanatory variables
    > mu.star <- rep(0,p) # mean of the explanatory variables
    > Sigma.star <- diag(rep(1,p)) # covariance
    > beta.star <- c(1, 1, 0) # coefficients
    > beta0.star <- 0 # intercept
    > beta.true = c(beta0.star,beta.star)
    > X.complete <- matrix(rnorm(N*p), nrow=N)%*%chol(Sigma.star) +
    + matrix(rep(mu.star,N), nrow=N, byrow = TRUE)
    > p1 <- 1/(1+exp(-X.complete%*%beta.star-beta0.star))
    > y <- as.numeric(runif(N)<p1)
    > # Generate missingness
    > p.miss <- 0.10
    > patterns <- runif(N*p)<p.miss #missing completely at random
    > X.obs <- X.complete
    > X.obs[patterns] <- NA
    >
    > # SAEM
    > list.saem = miss.saem(X.obs,y)
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    misaem
     --- call from context ---
    miss.saem(X.obs, y)
     --- call from argument ---
    if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
    }
     --- R stacktrace ---
    where 1: miss.saem(X.obs, y)
    
     --- value of length: 2 type: logical ---
    [1] FALSE FALSE
     --- function from context ---
    function (X.obs, y, pos_var = 1:ncol(X.obs), maxruns = 500, tol_em = 1e-07,
     nmcmc = 2, tau = 1, k1 = 50, seed = 200, print_iter = TRUE,
     var_cal = FALSE, ll_obs_cal = FALSE)
    {
     set.seed(seed)
     if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
     }
     if (sum(sapply(X.obs, is.numeric)) < ncol(X.obs)) {
     stop("Error: the variables should be numeric.")
     }
     if (sum(y == 1) + sum(y == 0) < nrow(X.obs)) {
     stop("Error: y must be coded by 0 or 1, and there is no missing data in y.")
     }
     if (sum(pos_var %in% 1:ncol(X.obs)) < length(pos_var)) {
     stop("Error: index of selected variables must be in the range of covariates.")
     }
     if (length(unique(pos_var)) != length(pos_var)) {
     stop("Error: index of selected variables must not be repeated.")
     }
     p = ncol(X.obs)
     if (any(apply(is.na(X.obs), 1, sum) == p)) {
     i_allNA = which(apply(is.na(X.obs), 1, sum) == p)
     X.obs = X.obs[-i_allNA, ]
     y = y[-i_allNA]
     }
     if (any((is.na(y)) == TRUE)) {
     i_YNA = which(is.na(y) == TRUE)
     X.obs = X.obs[-i_YNA, ]
     y = y[-i_YNA]
     }
     n = length(y)
     rindic = as.matrix(is.na(X.obs))
     if (sum(rindic) > 0) {
     whichcolmissing = (1:ncol(rindic))[apply(rindic, 2, sum) >
     0]
     missingcols = length(whichcolmissing)
     }
     if (sum(rindic) == 0) {
     missingcols = 0
     }
     ptm <- Sys.time()
     if (missingcols > 0) {
     k = 0
     cstop = 0.1
     seqbeta = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     seqbeta_avg = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     X.mean = X.obs
     for (i in 1:ncol(X.mean)) {
     X.mean[is.na(X.mean[, i]), i] <- mean(X.mean[, i],
     na.rm = TRUE)
     }
     X.sim <- X.mean
     mu = apply(X.mean, 2, mean)
     Sigma = var(X.mean) * (n - 1)/n
     beta = rep(0, p + 1)
     beta[c(1, pos_var + 1)] = glm(y ~ X.mean[, pos_var],
     family = binomial(link = "logit"))$coef
     while ((cstop > tol_em) * (k < maxruns) | (k < 20)) {
     k = k + 1
     beta.old = beta
     if (k < k1) {
     gamma <- 1
     }
     else {
     gamma <- 1/(k - (k1 - 1))^tau
     }
     S.inv <- solve(Sigma)
     for (i in (1:n)) {
     jna <- which(is.na(X.obs[i, ]))
     njna <- length(jna)
     if (njna > 0) {
     xi <- X.sim[i, ]
     Oi <- solve(S.inv[jna, jna])
     mi <- mu[jna]
     lobs <- beta[1]
     if (njna < p) {
     jobs <- setdiff(1:p, jna)
     mi <- mi - (xi[jobs] - mu[jobs]) %*% S.inv[jobs,
     jna] %*% Oi
     lobs <- lobs + sum(xi[jobs] * beta[jobs +
     1])
     }
     cobs <- exp(lobs)
     if (cobs == 0) {
     cobs = .Machine$double.xmin
     }
     if (cobs == Inf) {
     cobs = .Machine$double.xmax
     }
     xina <- xi[jna]
     betana <- beta[jna + 1]
     for (m in (1:nmcmc)) {
     xina.c <- mi + rnorm(njna) %*% chol(Oi)
     if (y[i] == 1)
     alpha <- (1 + exp(-sum(xina * betana))/cobs)/(1 +
     exp(-sum(xina.c * betana))/cobs)
     else alpha <- (1 + exp(sum(xina * betana)) *
     cobs)/(1 + exp(sum(xina.c * betana)) *
     cobs)
     if (runif(1) < alpha) {
     xina <- xina.c
     }
     }
     X.sim[i, jna] <- xina
     }
     }
     beta_new = rep(0, p + 1)
     beta_new[c(1, pos_var + 1)] = glm(y ~ X.sim[, pos_var],
     family = binomial(link = "logit"))$coef
     beta <- (1 - gamma) * beta + gamma * beta_new
     cstop = sum((beta - beta.old)^2)
     mu <- (1 - gamma) * mu + gamma * colMeans(X.sim)
     Sigma <- (1 - gamma) * Sigma + gamma * cov(X.sim)
     seqbeta[, k] = beta.old
     if (k == 1) {
     seqbeta_avg[, k] = beta.old
     }
     else {
     seqbeta_avg[, k] = 1/k * rowSums(seqbeta[, 1:k])
     }
     if (print_iter == TRUE & k%%10 == 0) {
     cat(sprintf("iteration = %i ", k))
     cat(sprintf("beta ="), beta, "\n")
     cat(sprintf("Distance from last iteration ="),
     cstop, "\n")
     }
     }
     var_obs = ll = std_obs = NULL
     if (var_cal == TRUE) {
     var_obs = louis_lr_saem(beta, mu, Sigma, y, X.obs,
     pos_var, rindic, whichcolmissing, mc.size = 1000)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     if (missingcols == 0) {
     X.obs = matrix(X.obs, nrow = n)
     data.complete <- data.frame(y = y, X.obs)
     model.complete <- glm(y ~ ., family = binomial(link = "logit"),
     data = data.complete)
     mu = apply(X.obs, 2, mean)
     Sigma = var(X.obs) * (n - 1)/n
     beta <- model.complete$coefficients
     var_obs = ll = ll1 = ll2 = std_obs = seqbeta_avg = seqbeta = NULL
     if (var_cal == TRUE) {
     P <- predict(model.complete, type = "response")
     W <- diag(P * (1 - P))
     X <- model.matrix(model.complete)
     var_obs <- solve(t(X) %*% W %*% X)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     time_run = Sys.time() - ptm
     return(list(mu = mu, sig2 = Sigma, beta = beta, time_run = time_run,
     seqbeta = seqbeta, seqbeta_avg = seqbeta_avg, ll = ll,
     var_obs = var_obs, std_obs = std_obs))
    }
    <bytecode: 0x55f2d7f7d100>
    <environment: namespace:misaem>
     --- function search by body ---
    Function miss.saem in namespace misaem has this body.
     ----------- END OF FAILURE REPORT --------------
    Fatal error: the condition has length > 1
Flavor: r-devel-linux-x86_64-debian-gcc

Version: 0.9.1
Check: re-building of vignette outputs
Result: WARN
    Error(s) in re-building vignettes:
     ...
    --- re-building ‘misaem.Rmd’ using rmarkdown
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    misaem
     --- call from context ---
    miss.saem(X.obs, y)
     --- call from argument ---
    if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
    }
     --- R stacktrace ---
    where 1: miss.saem(X.obs, y)
    where 2: eval(expr, envir, enclos)
    where 3: eval(expr, envir, enclos)
    where 4: withVisible(eval(expr, envir, enclos))
    where 5: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler,
     error = eHandler, message = mHandler)
    where 6: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir,
     enclos)), warning = wHandler, error = eHandler, message = mHandler))
    where 7: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr,
     envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
    where 8: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,
     debug = debug, last = i == length(out), use_try = stop_on_error !=
     2L, keep_warning = keep_warning, keep_message = keep_message,
     output_handler = output_handler, include_timing = include_timing)
    where 9: evaluate::evaluate(...)
    where 10: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),
     keep_message = !isFALSE(options$message), stop_on_error = if (options$error &&
     options$include) 0L else 2L, output_handler = knit_handlers(options$render,
     options))
    where 11: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,
     keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),
     stop_on_error = if (options$error && options$include) 0L else 2L,
     output_handler = knit_handlers(options$render, options)))
    where 12: block_exec(params)
    where 13: call_block(x)
    where 14: process_group.block(group)
    where 15: process_group(group)
    where 16: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),
     error = function(e) {
     setwd(wd)
     cat(res, sep = "\n", file = output %n% "")
     message("Quitting from lines ", paste(current_lines(i),
     collapse = "-"), " (", knit_concord$get("infile"),
     ") ")
     })
    where 17: process_file(text, output)
    where 18: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet,
     encoding = encoding)
    where 19: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(),
     ...)
    where 20: vweave_rmarkdown(...)
    where 21: engine$weave(file, quiet = quiet, encoding = enc)
    where 22: doTryCatch(return(expr), name, parentenv, handler)
    where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 24: tryCatchList(expr, classes, parentenv, handlers)
    where 25: tryCatch({
     engine$weave(file, quiet = quiet, encoding = enc)
     setwd(startdir)
     output <- find_vignette_product(name, by = "weave", engine = engine)
     if (!have.makefile && vignette_is_tex(output)) {
     texi2pdf(file = output, clean = FALSE, quiet = quiet)
     output <- find_vignette_product(name, by = "texi2pdf",
     engine = engine)
     }
     outputs <- c(outputs, output)
    }, error = function(e) {
     thisOK <<- FALSE
     fails <<- c(fails, file)
     message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s",
     file, conditionMessage(e)))
    })
    where 26: tools:::buildVignettes(dir = "/home/hornik/tmp/R.check/r-devel-gcc/Work/PKGS/misaem.Rcheck/vign_test/misaem",
     ser_elibs = "/home/hornik/tmp/scratch/RtmpTouJLY/file3107186b2749.rds")
    
     --- value of length: 2 type: logical ---
    [1] FALSE FALSE
     --- function from context ---
    function (X.obs, y, pos_var = 1:ncol(X.obs), maxruns = 500, tol_em = 1e-07,
     nmcmc = 2, tau = 1, k1 = 50, seed = 200, print_iter = TRUE,
     var_cal = FALSE, ll_obs_cal = FALSE)
    {
     set.seed(seed)
     if (class(X.obs) == "data.frame") {
     X.obs <- as.matrix(X.obs)
     }
     if (sum(sapply(X.obs, is.numeric)) < ncol(X.obs)) {
     stop("Error: the variables should be numeric.")
     }
     if (sum(y == 1) + sum(y == 0) < nrow(X.obs)) {
     stop("Error: y must be coded by 0 or 1, and there is no missing data in y.")
     }
     if (sum(pos_var %in% 1:ncol(X.obs)) < length(pos_var)) {
     stop("Error: index of selected variables must be in the range of covariates.")
     }
     if (length(unique(pos_var)) != length(pos_var)) {
     stop("Error: index of selected variables must not be repeated.")
     }
     p = ncol(X.obs)
     if (any(apply(is.na(X.obs), 1, sum) == p)) {
     i_allNA = which(apply(is.na(X.obs), 1, sum) == p)
     X.obs = X.obs[-i_allNA, ]
     y = y[-i_allNA]
     }
     if (any((is.na(y)) == TRUE)) {
     i_YNA = which(is.na(y) == TRUE)
     X.obs = X.obs[-i_YNA, ]
     y = y[-i_YNA]
     }
     n = length(y)
     rindic = as.matrix(is.na(X.obs))
     if (sum(rindic) > 0) {
     whichcolmissing = (1:ncol(rindic))[apply(rindic, 2, sum) >
     0]
     missingcols = length(whichcolmissing)
     }
     if (sum(rindic) == 0) {
     missingcols = 0
     }
     ptm <- Sys.time()
     if (missingcols > 0) {
     k = 0
     cstop = 0.1
     seqbeta = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     seqbeta_avg = matrix(NA, nrow = ncol(X.obs) + 1, ncol = (maxruns +
     1))
     X.mean = X.obs
     for (i in 1:ncol(X.mean)) {
     X.mean[is.na(X.mean[, i]), i] <- mean(X.mean[, i],
     na.rm = TRUE)
     }
     X.sim <- X.mean
     mu = apply(X.mean, 2, mean)
     Sigma = var(X.mean) * (n - 1)/n
     beta = rep(0, p + 1)
     beta[c(1, pos_var + 1)] = glm(y ~ X.mean[, pos_var],
     family = binomial(link = "logit"))$coef
     while ((cstop > tol_em) * (k < maxruns) | (k < 20)) {
     k = k + 1
     beta.old = beta
     if (k < k1) {
     gamma <- 1
     }
     else {
     gamma <- 1/(k - (k1 - 1))^tau
     }
     S.inv <- solve(Sigma)
     for (i in (1:n)) {
     jna <- which(is.na(X.obs[i, ]))
     njna <- length(jna)
     if (njna > 0) {
     xi <- X.sim[i, ]
     Oi <- solve(S.inv[jna, jna])
     mi <- mu[jna]
     lobs <- beta[1]
     if (njna < p) {
     jobs <- setdiff(1:p, jna)
     mi <- mi - (xi[jobs] - mu[jobs]) %*% S.inv[jobs,
     jna] %*% Oi
     lobs <- lobs + sum(xi[jobs] * beta[jobs +
     1])
     }
     cobs <- exp(lobs)
     if (cobs == 0) {
     cobs = .Machine$double.xmin
     }
     if (cobs == Inf) {
     cobs = .Machine$double.xmax
     }
     xina <- xi[jna]
     betana <- beta[jna + 1]
     for (m in (1:nmcmc)) {
     xina.c <- mi + rnorm(njna) %*% chol(Oi)
     if (y[i] == 1)
     alpha <- (1 + exp(-sum(xina * betana))/cobs)/(1 +
     exp(-sum(xina.c * betana))/cobs)
     else alpha <- (1 + exp(sum(xina * betana)) *
     cobs)/(1 + exp(sum(xina.c * betana)) *
     cobs)
     if (runif(1) < alpha) {
     xina <- xina.c
     }
     }
     X.sim[i, jna] <- xina
     }
     }
     beta_new = rep(0, p + 1)
     beta_new[c(1, pos_var + 1)] = glm(y ~ X.sim[, pos_var],
     family = binomial(link = "logit"))$coef
     beta <- (1 - gamma) * beta + gamma * beta_new
     cstop = sum((beta - beta.old)^2)
     mu <- (1 - gamma) * mu + gamma * colMeans(X.sim)
     Sigma <- (1 - gamma) * Sigma + gamma * cov(X.sim)
     seqbeta[, k] = beta.old
     if (k == 1) {
     seqbeta_avg[, k] = beta.old
     }
     else {
     seqbeta_avg[, k] = 1/k * rowSums(seqbeta[, 1:k])
     }
     if (print_iter == TRUE & k%%10 == 0) {
     cat(sprintf("iteration = %i ", k))
     cat(sprintf("beta ="), beta, "\n")
     cat(sprintf("Distance from last iteration ="),
     cstop, "\n")
     }
     }
     var_obs = ll = std_obs = NULL
     if (var_cal == TRUE) {
     var_obs = louis_lr_saem(beta, mu, Sigma, y, X.obs,
     pos_var, rindic, whichcolmissing, mc.size = 1000)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     if (missingcols == 0) {
     X.obs = matrix(X.obs, nrow = n)
     data.complete <- data.frame(y = y, X.obs)
     model.complete <- glm(y ~ ., family = binomial(link = "logit"),
     data = data.complete)
     mu = apply(X.obs, 2, mean)
     Sigma = var(X.obs) * (n - 1)/n
     beta <- model.complete$coefficients
     var_obs = ll = ll1 = ll2 = std_obs = seqbeta_avg = seqbeta = NULL
     if (var_cal == TRUE) {
     P <- predict(model.complete, type = "response")
     W <- diag(P * (1 - P))
     X <- model.matrix(model.complete)
     var_obs <- solve(t(X) %*% W %*% X)
     std_obs <- sqrt(diag(var_obs))
     }
     if (ll_obs_cal == TRUE) {
     ll = likelihood_saem(beta, mu, Sigma, y, X.obs, rindic,
     whichcolmissing, mc.size = 1000)
     }
     }
     time_run = Sys.time() - ptm
     return(list(mu = mu, sig2 = Sigma, beta = beta, time_run = time_run,
     seqbeta = seqbeta, seqbeta_avg = seqbeta_avg, ll = ll,
     var_obs = var_obs, std_obs = std_obs))
    }
    <bytecode: 0x55b60619d7e0>
    <environment: namespace:misaem>
     --- function search by body ---
    Function miss.saem in namespace misaem has this body.
     ----------- END OF FAILURE REPORT --------------
    Fatal error: the condition has length > 1
Flavor: r-devel-linux-x86_64-debian-gcc