Skip to content

Instantly share code, notes, and snippets.

@viraltux
Last active July 7, 2017 12:48
Embed
What would you like to do?
#Combining P-Values via Naive Bayes
bpv <- function(pv){
#Bayesian Probability
bp <- function(p){
if (any(p>1/exp(1))) stop('All p-values musts be lower that 1/e')
1 / (1 + 1/(-exp(1)*p*log(p)))
}
#Naive Bayes
nb <- function(p){
prod(p)/(prod(p)+prod(1-p))
}
#Retrieving bayesian p-value
optimize(function(x) (bp(x)-nb(bp(pv)))^2, c(0,0.5))$minimum
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment