[R] t_test and power

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Aug 27 17:34:53 CEST 2001


Malerba Giovanni <bobo at medgen.univr.it> writes:

> Hi all,
> I would like to estimate the sample size I need to perform some
> studies. I 'll will compare 2 groups (A and B) for several quantitative
> traits. I saw that R has power.t.test() function to compute the
> estimation. My concern is that I know that N_group_A = 3 * N_group_B in
> terms of size (and not N_group_A = N_group_B). Is there a way, using R, to
> estimate the sample size I need, given that I know the ratio between size of group
> A and group B?
> Thank you,
> Giovanni Malerba

There's no trivial way, but it wouldn't be hard to modify the existing
power.t.test to do it. The crucial bit is

    p.body <- quote({
        nu <- (n - 1) * tsample
        pt(qt(sig.level/tside, nu, lower = FALSE), nu, ncp = sqrt(n/tsample) * 
            delta/sd, lower = FALSE)
    })

for your purposes, nu should be (n-1+3*n-1) == (4*n - 2)
and the noncentrality in the ncp argument is sqrt(1/(1/n+1/(3*n)))*delta/sd
== sqrt(3*n/4)*delta/sd

(Make sure you check this on paper first. It is terribly easy to get
it slightly wrong in an email.)

For reasonably large groups, the exact calculation of degrees of
freedom is unimportant, and it should work to increase the delta by a
factor of sqrt(3/2) and get a conservative estimate of n (which will
be the number in the smaller group then).


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list