Re: [R] Power of test
"Leeds, Mark (IED)" <[EMAIL PROTECTED]> writes: > I don't know if there is one but if you use the t.test with df greater than > 30, you will > Get answers very close to that for the normal because the tables get pretty > close after > df of 30. I guess to be safe you can use set df to some huge #. > Slightly awkward, you cannot set the df independently from n in power.t.test. You can still cheat it by increasing n and sd (by a factor of, say, 100 and 10 respectively). Anyways, the power function for z tests is pretty much the code Ethan started out with... > > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ethan Johnsons > Sent: Friday, October 27, 2006 4:50 PM > To: ONKELINX, Thierry > Cc: r-help@stat.math.ethz.ch; Peter Dalgaard > Subject: Re: [R] Power of test > > Can I please ask a quick question again on this? > > Is there a power test function for z-test? Obviuosly, ?power.z.test > does not give me anything. > > thx much > > ej > > On 10/27/06, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote: > > A quick answer to your questions: > > > > 1. Since nobody knows the "true" delta. I prefer to calculate the power for > > a range of deltas. Most of the time for a range spanning - 2 * expected > > delta up to 2 * expected delta. This gives an idea on how the power changes > > if delta changes. > > 2. ?power.t.test explains how to calculate n for a given power, delta, sd > > and sig.level. A quote from ?power.t.test: "Exactly one of the parameters > > 'n', 'delta', 'power', 'sd', and 'sig.level' must be passed as NULL, and > > that parameter is determined from the others." > > > > Cheers, > > > > Thierry > > > > -- > > -- > > > > ir. Thierry Onkelinx > > > > Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature > > and Forest > > > > Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, > > methodology and quality assurance > > > > Gaverstraat 4 > > > > 9500 Geraardsbergen > > > > Belgium > > > > tel. + 32 54/436 185 > > > > [EMAIL PROTECTED] > > > > www.inbo.be > > > > > > > > Do not put your faith in what statistics say until you have carefully > > considered what they do not say. ~William W. Watt > > > > A statistical analysis, properly conducted, is a delicate dissection > > of uncertainties, a surgery of suppositions. ~M.J.Moroney > > > > > > -Oorspronkelijk bericht- > > Van: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] Namens Ethan Johnsons > > Verzonden: vrijdag 27 oktober 2006 16:59 > > Aan: Peter Dalgaard > > CC: r-help@stat.math.ethz.ch > > Onderwerp: Re: [R] Power of test > > > > 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 <[EMAIL PROTECTED]> wrote: > > > "Ethan Johnsons" <[EMAIL PROTECTED]> 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
Re: [R] Power of test
I don't know if there is one but if you use the t.test with df greater than 30, you will Get answers very close to that for the normal because the tables get pretty close after df of 30. I guess to be safe you can use set df to some huge #. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ethan Johnsons Sent: Friday, October 27, 2006 4:50 PM To: ONKELINX, Thierry Cc: r-help@stat.math.ethz.ch; Peter Dalgaard Subject: Re: [R] Power of test Can I please ask a quick question again on this? Is there a power test function for z-test? Obviuosly, ?power.z.test does not give me anything. thx much ej On 10/27/06, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote: > A quick answer to your questions: > > 1. Since nobody knows the "true" delta. I prefer to calculate the power for a > range of deltas. Most of the time for a range spanning - 2 * expected delta > up to 2 * expected delta. This gives an idea on how the power changes if > delta changes. > 2. ?power.t.test explains how to calculate n for a given power, delta, sd and > sig.level. A quote from ?power.t.test: "Exactly one of the parameters 'n', > 'delta', 'power', 'sd', and 'sig.level' must be passed as NULL, and that > parameter is determined from the others." > > Cheers, > > Thierry > > -- > -- > > ir. Thierry Onkelinx > > Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature > and Forest > > Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, > methodology and quality assurance > > Gaverstraat 4 > > 9500 Geraardsbergen > > Belgium > > tel. + 32 54/436 185 > > [EMAIL PROTECTED] > > www.inbo.be > > > > Do not put your faith in what statistics say until you have carefully > considered what they do not say. ~William W. Watt > > A statistical analysis, properly conducted, is a delicate dissection > of uncertainties, a surgery of suppositions. ~M.J.Moroney > > > -Oorspronkelijk bericht- > Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Namens Ethan Johnsons > Verzonden: vrijdag 27 oktober 2006 16:59 > Aan: Peter Dalgaard > CC: r-help@stat.math.ethz.ch > Onderwerp: Re: [R] Power of test > > 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 <[EMAIL PROTECTED]> wrote: > > "Ethan Johnsons" <[EMAIL PROTECTED]> 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 > > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > > > > __ > R-help@stat.math.ethz.ch 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. > __ R-help@stat.math.ethz.ch 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. This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch 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.
Re: [R] Power of test
Can I please ask a quick question again on this? Is there a power test function for z-test? Obviuosly, ?power.z.test does not give me anything. thx much ej On 10/27/06, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote: > A quick answer to your questions: > > 1. Since nobody knows the "true" delta. I prefer to calculate the power for a > range of deltas. Most of the time for a range spanning - 2 * expected delta > up to 2 * expected delta. This gives an idea on how the power changes if > delta changes. > 2. ?power.t.test explains how to calculate n for a given power, delta, sd and > sig.level. A quote from ?power.t.test: "Exactly one of the parameters 'n', > 'delta', 'power', 'sd', and 'sig.level' must be passed as NULL, and that > parameter is determined from the others." > > Cheers, > > Thierry > > > > ir. Thierry Onkelinx > > Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and > Forest > > Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, > methodology and quality assurance > > Gaverstraat 4 > > 9500 Geraardsbergen > > Belgium > > tel. + 32 54/436 185 > > [EMAIL PROTECTED] > > www.inbo.be > > > > Do not put your faith in what statistics say until you have carefully > considered what they do not say. ~William W. Watt > > A statistical analysis, properly conducted, is a delicate dissection of > uncertainties, a surgery of suppositions. ~M.J.Moroney > > > -----Oorspronkelijk bericht- > Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Ethan Johnsons > Verzonden: vrijdag 27 oktober 2006 16:59 > Aan: Peter Dalgaard > CC: r-help@stat.math.ethz.ch > Onderwerp: Re: [R] Power of test > > 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 <[EMAIL PROTECTED]> wrote: > > "Ethan Johnsons" <[EMAIL PROTECTED]> 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 > > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > > > > __ > R-help@stat.math.ethz.ch 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. > __ R-help@stat.math.ethz.ch 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.
Re: [R] Power of test
Oh... power.t.test has the magic in it, which I overlooked. Thank you so much. ej On 10/27/06, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote: > A quick answer to your questions: > > 1. Since nobody knows the "true" delta. I prefer to calculate the power for a > range of deltas. Most of the time for a range spanning - 2 * expected delta > up to 2 * expected delta. This gives an idea on how the power changes if > delta changes. > 2. ?power.t.test explains how to calculate n for a given power, delta, sd and > sig.level. A quote from ?power.t.test: "Exactly one of the parameters 'n', > 'delta', 'power', 'sd', and 'sig.level' must be passed as NULL, and that > parameter is determined from the others." > > Cheers, > > Thierry > > > > ir. Thierry Onkelinx > > Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and > Forest > > Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, > methodology and quality assurance > > Gaverstraat 4 > > 9500 Geraardsbergen > > Belgium > > tel. + 32 54/436 185 > > [EMAIL PROTECTED] > > www.inbo.be > > > > Do not put your faith in what statistics say until you have carefully > considered what they do not say. ~William W. Watt > > A statistical analysis, properly conducted, is a delicate dissection of > uncertainties, a surgery of suppositions. ~M.J.Moroney > > > -----Oorspronkelijk bericht- > Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Ethan Johnsons > Verzonden: vrijdag 27 oktober 2006 16:59 > Aan: Peter Dalgaard > CC: r-help@stat.math.ethz.ch > Onderwerp: Re: [R] Power of test > > 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 <[EMAIL PROTECTED]> wrote: > > "Ethan Johnsons" <[EMAIL PROTECTED]> 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 > > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > > > > __ > R-help@stat.math.ethz.ch 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. > __ R-help@stat.math.ethz.ch 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.
Re: [R] Power of test
A quick answer to your questions: 1. Since nobody knows the "true" delta. I prefer to calculate the power for a range of deltas. Most of the time for a range spanning - 2 * expected delta up to 2 * expected delta. This gives an idea on how the power changes if delta changes. 2. ?power.t.test explains how to calculate n for a given power, delta, sd and sig.level. A quote from ?power.t.test: "Exactly one of the parameters 'n', 'delta', 'power', 'sd', and 'sig.level' must be passed as NULL, and that parameter is determined from the others." Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Ethan Johnsons Verzonden: vrijdag 27 oktober 2006 16:59 Aan: Peter Dalgaard CC: r-help@stat.math.ethz.ch Onderwerp: Re: [R] Power of test 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 <[EMAIL PROTECTED]> wrote: > "Ethan Johnsons" <[EMAIL PROTECTED]> 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 > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] Power of test
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 <[EMAIL PROTECTED]> wrote: > "Ethan Johnsons" <[EMAIL PROTECTED]> 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 > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > __ R-help@stat.math.ethz.ch 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.
Re: [R] Power of test
"Ethan Johnsons" <[EMAIL PROTECTED]> 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 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch 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.
Re: [R] Power of test
Ethan Johnsons wrote: > 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? RSiteSearch("power", restrict="functions") is helpful. For a comparison of two means, the most relevant hit is probably: http://finzi.psych.upenn.edu/R/library/stats/html/power.t.test.html > Thank you, > > ej > > __ > R-help@stat.math.ethz.ch 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. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch 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.