R/BAGofT_multi.R

Defines functions BAGofT_multi

################################################################
#The function to calculate the mean of chi-square statistics
 # from multiple splits.
################################################################

# nsplits: number of splits


BAGofT_multi <- function(testModel, parFun,
                   data,  nsplits, ne){
  spliDat <- list()
  for (j in c(1:nsplits)){
    spliDat[[j]] <- BAGofT_sin(testModel = testModel,
                               parFun = parFun,
                               datset = data,
                               ne = ne)

  }
  # pvalues from multiple splits
  pvdat <- unlist(lapply(c(1:nsplits), function(x) spliDat[[x]]$p.value))

  return( list( meanPv = mean(pvdat),
                medianPv = stats::median(pvdat),
                minPv = min(pvdat),
                spliDat = spliDat )  )
}

Try the BAGofT package in your browser

Any scripts or data that you put into this service are public.

BAGofT documentation built on Sept. 15, 2021, 1:07 a.m.