R/pval.R

Defines functions mediate_pval

mediate_pval <- function(x, xhat){
  if(is.null(xhat)){
    stop("xhat is null")
  }
  if(is.na(xhat)){
    stop("xhat is NA")
  }
  ## Compute p-values
  if(xhat == 0){
    out <- 1
  } else {
    out <- 2 * min(sum(x > 0), sum(x < 0)) / length(x)
  }
  return(min(out, 1))
}
SharonLutz/UmediationThread documentation built on Oct. 30, 2019, 11:53 p.m.