[R] proportional test on epicalc library vs. Jerrold H. Zar.
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon May 5 22:30:49 CEST 2008
José Ignacio Bustos Melo wrote:
> Hi everyone,
>
> I'm working with the Epical library, specicatly using the power test in
> proportions. I think this test is not working like in the book:
> Biostatistical Analysis (4th Edition): Jerrold H. Zar
>
> In the example 23.25. (I attach this Pic) It's not the same answer.
> Using the follow command don't give the same answer.
>
> library(epicalc)
> power.for.2p(0.75, 0.50, 50, 45, alpha = 0.05)
>
> with this command the Power = 0.6402. But in the Book we find Power=0.72.
>
> ¿what it's the correct answer?...¿Zar or Chongsuvivatwong?
>
> Thank guys!
>
Hmm, these formulas are all asymptotic formulas relying on an
approximation with the normal distribution, and they will differ for
finite n. Zar's formula appears to be closer to power.prop.test in
standard R (if you put 47.5 subjects in both groups).
The difference seems to disappear with larger n, so I doubt that there
is anything actually wrong with the epicalc formula, and for all I know,
it might even be more accurate than the others.
In fact...
> pv <- replicate(1e5, {n1 <- rbinom(1,45, .75); n2 <- rbinom(1,50,.50)
; prop.test(c(n1,n2), c(45,50))$p.value})
> sum(pv < .05)
[1] 64725
which does suggest a true power closer to .64 than to .72.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list