R/fdrBH.R

Defines functions fdrBH

Documented in fdrBH

#' FDR threshold based on the Benjamini-Hochberg algorithm
#'
#' @param p a vector of p-values
#' @param q False Discovery Rate level
#'
#' @return p-value threshold based on independence or positive dependence
#' @export
#' @seealso \code{\link{which.cp}}
#' @examples
#' fdrBH(seq(0.01,0.1,0.01),q=0.1)
fdrBH = function(p,q){
  p = sort(p)
  V = length(p)
  I = 1:V
  cVID = 1
  # cVN = sum(1/I)
  pID = ifelse(all(p>I/V*q/cVID),0,max(p[p<=I/V*q/cVID]))
  # pN = max(p[p<=I/V*q/cVN])
  return(pID)
}

Try the mSTEM package in your browser

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

mSTEM documentation built on Oct. 2, 2019, 5:03 p.m.