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:
#
# 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.
#
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:
# # 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. #
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
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
METADATA