Hi. I believe that mantelhaen.test is giving the wrong p-value when I call it with a one-sided alternative and exact=F, and I think I know why. First, the example: > Nitrous = array(c(32,210,8,26,18,21,3,3,7,75,0,10),c(2,2,3)) # # Data are from Conover, "Nonparametric Statistics", 3rd Ed, p. 197, # re-arranged to make a lower-tail test the issue of relevance: we # want to see if pregnant nurses exposed to nitrous oxide have higher # rates of miscarriage, stratifying on the type of nurse. # > dimnames(Nitrous) = list(c("Exposed","NotExposed"), c("FullTerm","Miscarriage"),c("DentalAsst","OperRoomNurse","OutpatientNurse")) # # Now consider this: # mantelhaen.test (Nitrous, exact=T, alternative="less")$p.value [1] 0.1958908 # mantelhaen.test (Nitrous, exact=F, alternative="less")$p.value [1] 0.8009925 I believe the problem lies in the lines if (!exact) { ... DELTA <- abs(sum(x[1, 1, ] - s.x[1, ] * s.y[1, ]/n)) ... if (alternative == "two.sided") PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE) else { z <- sign(DELTA) * sqrt(STATISTIC) ... By the time we get to the assignment of z, DELTA is already the result of a call to abs(), so its sign is always 1. I got good results with something like this: if (!exact) { ... DELTA <- sum(x[1, 1, ] - s.x[1, ] * s.y[1, ]/n) sign.DELTA <- sign (DELTA) DELTA <- abs (DELTA) ... if (alternative == "two.sided") PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE) else { z <- sign.DELTA * sqrt(STATISTIC) I hope this is of interest, Sam Buttrey

Changed in 2.12.2 patched

*** Bug 14689 has been marked as a duplicate of this bug. ***