FAQ/Rfishp - CBU statistics Wiki

Revision 1 as of 2008-04-25 11:41:43

Clear message
location: FAQ / Rfishp

R code for combining p-values using Fisher's method

pfish <- function(p) {

t <- prod(p)
x <- -log(prod(p))
n <- length(p)
v <- c(1:n-1)
a <- t*(x^v)/factorial(v)
pf <- sum(a)
return(pf)
}

Running this inputting a list of pvalues on vector pvals

pvals <- c(0.1,0.01,0.01,0.7,0.3,0.1)
pl <- NA
pl <- length(pvals)
{ if (is.na(pl)) { res <- "There was an empty array of p-values"}
else
res <- pfish(pvals) }
print(res)

we get

[1] 0.002148704