R/I2C2.mcCI.R

Defines functions I2C2.mcCI

Documented in I2C2.mcCI

#' @title Compute the Confidence Interval
#' @description Computing the confidence interval of I2C2 via multicore computing.
#'
#' @param ... arguments passed to \code{\link{I2C2.rsample}}
#' @param rseed Seed number
#' @param R The bootstrap repetition size
#' @param mc.cores Number of Cores
#' @param ci 100*ci\% The level of the Confidence Interval
#'
#' @export
#' @return List of the lambdas and then the confidence interval
#' @importFrom stats quantile
#' @importFrom parallel mclapply
I2C2.mcCI <- function(...,
                      rseed = 1234, R = 100,
                      mc.cores = 1, ci = 0.95){

  ##	set up the number of multicores
  ##	Set a random seed

  set.seed(rseed)

  lambda <- parallel::mclapply(
    1:R,
    function(s){
      l = I2C2.rsample(s + rseed, ...)
      return(l)
    }, mc.cores = mc.cores)

  lambda = as.vector(unlist(lambda))
  result <- list(lambda = lambda)
  result$CI <- quantile( result$lambda, c( (1 - ci)/2, ci + (1 - ci)/2) )
  return(result)
}
neuroconductor-devel/I2C2 documentation built on May 3, 2021, 12:33 p.m.