[R] Power of test
Ethan Johnsons
ethan.johnsons at gmail.com
Fri Oct 27 16:58:47 CEST 2006
Thank you so mcuh for the explanation, Chuck & Peter.
Two quick questions,please.
It states that delta = True difference in means. When the true diff
is unkown, can you use the expected diff for delta.
If you want to know the n (number of observations) off of power.t.test
to have i.e. 80% power, how do you calculate? Is there a way to do it
in R, or use algebra?
power.t.test(n = NULL, delta = NULL, sd = 1, sig.level = 0.05,
power = NULL,
type = c("two.sample", "one.sample", "paired"),
alternative = c("two.sided", "one.sided"),
strict = FALSE)
Thank you,
ej
On 27 Oct 2006 16:37:08 +0200, Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote:
> "Ethan Johnsons" <ethan.johnsons at gmail.com> writes:
>
> > What would be the R formulae for a two-sided test?
> >
> > I have a formula for a one-sided test:
> >
> > powertest <- function(a,m0,m1,n,s){
> > t1 = -qnorm(1-a)
> > num = abs(m0-m1) * sqrt(n)
> > t2 = num/s
> > pow = pnorm(t1 + t2)
> > }
> >
> > Would you pls let me know if you know of?
>
> (Notice that power.t.test does this more accurately)
>
> For practical purposes, just halve a. Perfectionists may want you to
> add pnorm(t1 - t2), so that the total power becomes a when t2 == 0.
>
> BTW: -qnorm(1-a)==qnorm(a)
>
> --
> 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