R/maxPvaluePaired.R

Defines functions maxPvaluePaired

Documented in maxPvaluePaired

maxPvaluePaired <-
function(Mat, N, int, beta, delta, doublePvalue){
  
  index <- 1
  prob <- rep(NA, length(int))
  Tbls <- which(Mat==1, arr.ind = TRUE) - 1
  for (probVal in int) {
    prob[index] <- sum(trinom(Tbls[ , 1], Tbls[ , 2], N, p12=probVal, p21=probVal, delta=delta))
    index <- index + 1
  }
  prob <- signif((1+doublePvalue)*prob + beta, 12) #Remove rounding errors and double probabilities if applicable
  
  # Cutoff probabilities at 1 (only relevant if beta != 0) #
  prob[!is.na(prob) & prob > 1] <- 1
  
  np <- int[which(prob==max(prob, na.rm=TRUE))]
  pvalue <- max(prob, na.rm=TRUE)
  
  return(list(prob=prob, pvalue=pvalue, np=np))
}

Try the Exact package in your browser

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

Exact documentation built on Sept. 26, 2022, 1:05 a.m.