[R] Z test and proportions

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Tue Jun 17 18:56:51 CEST 2008


Michael Pearmain wrote:
> Yes my mistake,
>
> I looked at the pwr.2p2n.test but i cannot place both n's and both p
> values to determine the sig value
> e,g *pwr.2p2n.test(h = , n1 = , n2 = , sig.level = , power = )
>
> or am i missing someting obvious?
>
> *
Not quite obvious, but h is the effect size and is a function of p1 &
p2, after arcsine transformation. The documentation for the pwr package
is a bit short on information on _which_ arcsine transformation that is,
though. As far as I can see, it is 2*asin(sqrt(p)), since

> pwr.2p2n.test(2*(asin(sqrt(.5))-asin(sqrt(.7))),n1=200,n2=200)

     difference of proportion power calculation for binomial
distribution (arcsine transformation)

              h = 0.4115168
             n1 = 200
             n2 = 200
      sig.level = 0.05
          power = 0.984427
    alternative = two.sided

 NOTE: different sample sizes

> power.prop.test(p1=.5,p2=.7,n=200)

     Two-sample comparison of proportions power calculation

              n = 200
             p1 = 0.5
             p2 = 0.7
      sig.level = 0.05
          power = 0.9849271
    alternative = two.sided

 NOTE: n is number in *each* group



> *i did the sam ein SPSS using a macro and the following code:
>
> COMPUTE n1 = Control_MAX .
> COMPUTE n2 = Exposed_max.
> COMPUTE x1 = Control.
> COMPUTE x2 = Exposed.
>
> COMPUTE p1 = x1/n1.
> COMPUTE p2 = x2/n2.
> COMPUTE phat = (x1 + x2) / (n1 + n2).
> COMPUTE SE_phat = SQRT(phat * (1 - phat) * ((1/n1) + (1/n2))).
> COMPUTE z = (p1 - p2) /SE_phat.
> COMPUTE SIGz_2TL = 2 * (1 - CDFNORM(ABS(z))).
> COMPUTE SIGz_LTL = CDFNORM(Z).
> COMPUTE SIGz_UTL = 1 - CDFNORM(Z).
> COMPUTE SIG_Level = ABS(1-(1-CDFNORM(z))*2).
> Compute p1p = p1*100.
> Compute p2p = p2*100.
> compute diff = p2p-p1p.
> EXE.
> Var lab p1p "Control Group %".
> Var lab p2p "Exposed Group %".
>
>
>
> *
>
>
> On Tue, Jun 17, 2008 at 5:13 PM, Peter Dalgaard
> <P.Dalgaard at biostat.ku.dk <mailto:P.Dalgaard at biostat.ku.dk>> wrote:
>
>     Michael Pearmain wrote:
>     > Hi All,
>     >
>     > I have a table based on ordial data and i want to compare
>     proportions and
>     > i've seen in the pwr package i can use
>     > power.prop.test
>     >
>     > however i want to find out what the sig. value is based on
>     n1,n2,p1,p2 and
>     > this package doesn't contain this..
>     > Does anyone know of a package that does or is it a case of
>     writting a
>     > function specifically for this?
>     >
>     >
>     I think your wired got crossed somewhere:
>
>     power.prop.test is not from the pwr package; however, pwr does
>     contain pwr.2p2n.test, which looks like it does exactly what you want!
>
>
>     > Many thanks in advance
>     >
>     >       [[alternative HTML version deleted]]
>     >
>     > ______________________________________________
>     > R-help at r-project.org <mailto:R-help at r-project.org> mailing list
>     > https://stat.ethz.ch/mailman/listinfo/r-help
>     > PLEASE do read the posting guide
>     http://www.R-project.org/posting-guide.html
>     > and provide commented, minimal, self-contained, reproducible code.
>     >
>
>
>     --
>       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
>     <mailto:p.dalgaard at biostat.ku.dk>)              FAX: (+45) 35327907
>
>
>
>
>
> -- 
> Michael Pearmain
> Senior Statistical Analyst
>
>
> 1st Floor, 180 Great Portland St. London W1W 5QZ
> t +44 (0) 2032191684
> mpearmain at google.com <mailto:mpearmain at google.com>
> mpearmain at doubleclick.com <mailto:mpearmain at doubleclick.com>
>
>
> Doubleclick is a part of the Google group of companies 


-- 
   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