aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2017-03-29 09:14:33 +1100
committerJustin Bedo <cu@cua0.org>2017-03-29 09:14:33 +1100
commit32f0a614798f42d0ff51a325ba183aaa85030b24 (patch)
tree077f7c9c9d4f2edc6bf22ff647bbba3030d301db
parent7af01d594acaf949ef1d4bbe22142b45345b8b20 (diff)
Correct p-values
-rw-r--r--R/pmt.R4
1 files changed, 3 insertions, 1 deletions
diff --git a/R/pmt.R b/R/pmt.R
index 5921638..927fd9e 100644
--- a/R/pmt.R
+++ b/R/pmt.R
@@ -54,7 +54,9 @@ pmt <- function(a, b, two.sided=T, signed=F) {
t1 <- mapply(function(xa, mu, rho) { i <- 0:xa; logsumexp(i * log(2 * mu) - lfactorial(i) - i * log(1 + rho))}, a, mu, rho)
t2 <- mapply(function(xb, mu, rho) { j <- xb:(xb*100); logsumexp(j * log(2 * mu * rho) - lfactorial(j) - j * log(1 + rho))}, b, mu, rho)
- ps <- (2*mu-t1-t2) / log(10)
+ ps <- (2*mu-t1-t2)
+ ps <- ps - log1p(ps)
+ ps <- ps / log(10)
if(!two.sided) ps[msk] <- NA
else if(signed) ps <- ps * (1-2*msk)
ps