R/pvalue.R

Defines functions .calc_pvalue

.calc_pvalue <- function(perms, observed, alt) {
  B <- length(perms)
  
  switch(alt,
         (sum(perms <= observed) + 1) / (B + 1),
         (sum(perms >= observed) + 1) / (B + 1),
         (sum(abs(perms) >= abs(observed)) + 1) / (B + 1),
         stop("Alternative not matched.")
  )
}

Try the CarletonStats package in your browser

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

CarletonStats documentation built on Aug. 22, 2023, 5:06 p.m.