Re: [R] Formula of power.t.test

About this list Date view Thread view Subject view Author view Attachment view

From: Uwe Ligges (ligges@statistik.uni-dortmund.de)
Date: Thu 13 May 2004 - 16:52:41 EST


Message-id: <40A31B39.5010404@statistik.uni-dortmund.de>

Xiaorong Chen wrote:

> Dear Sir or Madam,
>
> What is the formula for power.t.test(delta=delta, sd=segma, sig.level=0.05,
> power=0.8, type="one.sample", alternative="one.sided")$n?

See the code of power.t.test by just typing the name of that function
into the console:

   power.t.test

and you'll easily see that the code collapses in your case to:

   tsample <- 1
   tside <- 1
   p.body <- quote({
     nu <- (n - 1) * tsample
     pt(qt(sig.level/tside, nu, lower = FALSE),
       nu, ncp = sqrt(n/tsample) * delta/sd, lower = FALSE)
   })
   n <- uniroot(function(n) eval(p.body) - power, c(2, 1e+07))$root

Uwe Ligges

> Thank you very much for the help!
>
> Best,
>
> Xiaorong
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:09 EST