R/ComputePValueFromDistributionTable.r

Defines functions ComputePValueFromDistributionTable

Documented in ComputePValueFromDistributionTable

#' @title compute a p-value from the distribution table
#' @description
#' Computes the p-value of the score of an hypothesis, based on a distribution table

#' @param scoreOfHypothesis a score of hypothesis
#' @param distributionMatrix a distribution table presented as a matrix
#' @param totalWeights a matrix of total weights
#' @return a p-value


ComputePValueFromDistributionTable <- function(scoreOfHypothesis, distributionMatrix, totalWeights) {
    
    
    # Ensure distribution matrix has two columns
    distributionMatrix <- matrix(distributionMatrix, ncol = 2)
    
    pValue <- sum(distributionMatrix[distributionMatrix[, 1] >= scoreOfHypothesis, 2])/totalWeights
    
    return(pValue)
} 

Try the CausalR package in your browser

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

CausalR documentation built on Nov. 8, 2020, 5:25 p.m.