Is there a function similar to stats::power.t.test that can handle unequal variances from two samples? I noticed that stats::t.test has an argument for indicating whether or not to treat the two sample variances as equal.? Wondering why stats::power.t.test doesn?t have that option. Thanks,Mauricio
Power of t test for unequal variances?
6 messages · Mauricio Cornejo, David Winsemius, Gerrit Eichner
On Dec 19, 2016, at 1:47 PM, Mauricio Cornejo via R-help <r-help at r-project.org> wrote: Is there a function similar to stats::power.t.test that can handle unequal variances from two samples? I noticed that stats::t.test has an argument for indicating whether or not to treat the two sample variances as equal. Wondering why stats::power.t.test doesn?t have that option. Thanks,Mauricio [[alternative HTML version deleted]]
Because R was developed by statisticians for statisticians and they assumed those other statisticians would know how to extend its functions when needed. But R-help is not advertised as the place to ask such questions when you don't have the statistical skills. (You might want to look at the code of `t.test` to see how you might construct appropriate arguments for `power.t.test` in the situation you imagine. Seems to me it should be fairly straightforward. `power.t.test` is built around the non-central t-distribution and solves a uniroot problem for the missing parameter among n, delta, power, sd, and sig.level, given the other 4 parameters.)
David Winsemius Alameda, CA, USA
On Dec 19, 2016, at 3:31 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Dec 19, 2016, at 1:47 PM, Mauricio Cornejo via R-help <r-help at r-project.org> wrote: Is there a function similar to stats::power.t.test that can handle unequal variances from two samples? I noticed that stats::t.test has an argument for indicating whether or not to treat the two sample variances as equal. Wondering why stats::power.t.test doesn?t have that option. Thanks,Mauricio [[alternative HTML version deleted]]
Because R was developed by statisticians for statisticians and they assumed those other statisticians would know how to extend its functions when needed. But R-help is not advertised as the place to ask such questions when you don't have the statistical skills. (You might want to look at the code of `t.test` to see how you might construct appropriate arguments for `power.t.test` in the situation you imagine. Seems to me it should be fairly straightforward. `power.t.test` is built around the non-central t-distribution and solves a uniroot problem for the missing parameter among n, delta, power, sd, and sig.level, given the other 4 parameters.)
The other R-specific response might have been to teach you to use R's functions to do a bit of searching:
?available.packages
old.opt <- options(available_packages_filters =
c("R_version", "CRAN", "duplicates"))
# saved options from prior state
avail <- available.packages()
names(avail)
NULL # oops, not a list.
str( avail)
chr [1:9731, 1:17] "A3" "abbyyR" "abc" "ABCanalysis" ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:9731] "A3" "abbyyR" "abc" "ABCanalysis" ...
..$ : chr [1:17] "Package" "Version" "Priority" "Depends" ...
colnames(avail)
#--- result---
[1] "Package" "Version"
[3] "Priority" "Depends"
[5] "Imports" "LinkingTo"
[7] "Suggests" "Enhances"
[9] "License" "License_is_FOSS"
[11] "License_restricts_use" "OS_type"
[13] "Archs" "MD5sum"
[15] "NeedsCompilation" "File"
[17] "Repository"
#---------
avail[ grepl("pow" ,avail[ ,"Package"] , ignore.case=TRUE), "Package"]
asypow bivarRIpower clusterPower
"asypow" "bivarRIpower" "clusterPower"
easypower fpow longpower
"easypower" "fpow" "longpower"
matpow mnormpow PharmPow
"matpow" "mnormpow" "PharmPow"
powell PoweR Power2Stage
"powell" "PoweR" "Power2Stage"
powerAnalysis powerbydesign powerGWASinteraction
"powerAnalysis" "powerbydesign" "powerGWASinteraction"
poweRlaw powerMediation powerpkg
"poweRlaw" "powerMediation" "powerpkg"
powerplus powerSurvEpi PowerTOST
"powerplus" "powerSurvEpi" "PowerTOST"
PowerUpR rPowerSampleSize twoStageGwasPower
"PowerUpR" "rPowerSampleSize" "twoStageGwasPower"
A more usable result:
names( avail[ grepl("pow" ,avail[ ,"Package"] , ignore.case=TRUE), "Package"] )
[1] "asypow" "bivarRIpower"
[3] "clusterPower" "easypower"
[5] "fpow" "longpower"
[7] "matpow" "mnormpow"
[9] "PharmPow" "powell"
[11] "PoweR" "Power2Stage"
[13] "powerAnalysis" "powerbydesign"
[15] "powerGWASinteraction" "poweRlaw"
[17] "powerMediation" "powerpkg"
[19] "powerplus" "powerSurvEpi"
[21] "PowerTOST" "PowerUpR"
[23] "rPowerSampleSize" "twoStageGwasPower"
options(old.opt) # reset options to default values
So you may find additional user-contributed power-oriented packages.
-- David Winsemius Alameda, CA, USA
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
David Winsemius Alameda, CA, USA
Hello, Mauricio, maybe pwr.t2n.test() in package pwr or/and n.ttest() in package samplesize do what you need/want. Hth -- Gerrit --------------------------------------------------------------------- Dr. Gerrit Eichner Mathematical Institute, Room 212 gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/eichner --------------------------------------------------------------------- Am 20.12.2016 um 00:31 schrieb David Winsemius:
On Dec 19, 2016, at 1:47 PM, Mauricio Cornejo via R-help <r-help at r-project.org> wrote: Is there a function similar to stats::power.t.test that can handle unequal variances from two samples? I noticed that stats::t.test has an argument for indicating whether or not to treat the two sample variances as equal. Wondering why stats::power.t.test doesn?t have that option. Thanks,Mauricio [[alternative HTML version deleted]]
Because R was developed by statisticians for statisticians and they assumed those other statisticians would know how to extend its functions when needed. But R-help is not advertised as the place to ask such questions when you don't have the statistical skills. (You might want to look at the code of `t.test` to see how you might construct appropriate arguments for `power.t.test` in the situation you imagine. Seems to me it should be fairly straightforward. `power.t.test` is built around the non-central t-distribution and solves a uniroot problem for the missing parameter among n, delta, power, sd, and sig.level, given the other 4 parameters.)
1 day later
Gerrit, thanks for the suggestion. ?samplesize::n.ttest does seem to handle unequal variances.
On Tuesday, December 20, 2016 2:55 AM, Gerrit Eichner <Gerrit.Eichner at math.uni-giessen.de> wrote:
Hello, Mauricio, maybe pwr.t2n.test() in package pwr or/and n.ttest() in package?samplesize do what you need/want. ? Hth? --? Gerrit
On Dec 19, 2016, at 1:47 PM, Mauricio Cornejo via R-help <r-help at r-project.org> wrote: Is there a function similar to stats::power.t.test that can handle unequal variances from two samples? I noticed that stats::t.test has an argument for indicating whether or not to treat the two sample variances as equal.? Wondering why stats::power.t.test doesn?t have that option. Thanks, Mauricio
David, I was not aware I could search through the list of available packages. ?Thanks very much for the tip. Regarding your guidance that my question may not have been appropriate for R-help as it may not have been specifically an R question ... since it seemed like an R question to me, are there any particular criteria that would help me determine if my question is sufficiently specific to R to be appropriate for R-help? Thanks again, Mauricio
On Monday, December 19, 2016 10:14 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Dec 19, 2016, at 3:31 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Dec 19, 2016, at 1:47 PM, Mauricio Cornejo via R-help <r-help at r-project.org> wrote: Is there a function similar to stats::power.t.test that can handle unequal variances from two samples? I noticed that stats::t.test has an argument for indicating whether or not to treat the two sample variances as equal.? Wondering why stats::power.t.test doesn?t have that option. Thanks,Mauricio ??? [[alternative HTML version deleted]]
Because R was developed by statisticians for statisticians and they assumed those other statisticians would know how to extend its functions when needed. But R-help is not advertised as the place to ask such questions when you don't have the statistical skills. (You might want to look at the code of `t.test` to see how you might construct appropriate arguments for `power.t.test` in the situation you imagine. Seems to me it should be fairly straightforward. `power.t.test` is built around the non-central t-distribution and solves a uniroot problem for the missing parameter among? n, delta, power, sd, and sig.level, given the other 4 parameters.)
The other R-specific response might have been to teach you to use R's functions to do a bit of searching:
?available.packages
old.opt <- options(available_packages_filters =
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? c("R_version",? "CRAN", "duplicates"))
# saved options from prior state
avail <- available.packages()
names(avail)
NULL? # oops, not a list.
str( avail)
chr [1:9731, 1:17] "A3" "abbyyR" "abc" "ABCanalysis" ...
- attr(*, "dimnames")=List of 2
? ..$ : chr [1:9731] "A3" "abbyyR" "abc" "ABCanalysis" ...
? ..$ : chr [1:17] "Package" "Version" "Priority" "Depends" ...
colnames(avail)
#--- result---
[1] "Package"? ? ? ? ? ? ? "Version"? ? ? ? ? ? ?
[3] "Priority"? ? ? ? ? ? ? "Depends"? ? ? ? ? ? ?
[5] "Imports"? ? ? ? ? ? ? "LinkingTo"? ? ? ? ? ?
[7] "Suggests"? ? ? ? ? ? ? "Enhances"? ? ? ? ? ?
[9] "License"? ? ? ? ? ? ? "License_is_FOSS"? ? ?
[11] "License_restricts_use" "OS_type"? ? ? ? ? ? ?
[13] "Archs"? ? ? ? ? ? ? ? "MD5sum"? ? ? ? ? ? ?
[15] "NeedsCompilation"? ? ? "File"? ? ? ? ? ? ? ?
[17] "Repository"? ? ? ?
#---------?
avail[ grepl("pow" ,avail[ ,"Package"] , ignore.case=TRUE), "Package"]
? ? ? ? ? ? ? ? asypow? ? ? ? ? bivarRIpower? ? ? ? ? clusterPower
? ? ? ? ? ? ? "asypow"? ? ? ? "bivarRIpower"? ? ? ? "clusterPower"
? ? ? ? ? ? easypower? ? ? ? ? ? ? ? ? fpow? ? ? ? ? ? ? longpower
? ? ? ? ? "easypower"? ? ? ? ? ? ? ? "fpow"? ? ? ? ? ? "longpower"
? ? ? ? ? ? ? ? matpow? ? ? ? ? ? ? mnormpow? ? ? ? ? ? ? PharmPow
? ? ? ? ? ? ? "matpow"? ? ? ? ? ? "mnormpow"? ? ? ? ? ? "PharmPow"
? ? ? ? ? ? ? ? powell? ? ? ? ? ? ? ? ? PoweR? ? ? ? ? ? Power2Stage
? ? ? ? ? ? ? "powell"? ? ? ? ? ? ? ? "PoweR"? ? ? ? ? "Power2Stage"
? ? ? ? powerAnalysis? ? ? ? ? powerbydesign? powerGWASinteraction
? ? ? "powerAnalysis"? ? ? ? "powerbydesign" "powerGWASinteraction"
? ? ? ? ? ? ? poweRlaw? ? ? ? powerMediation? ? ? ? ? ? ? powerpkg
? ? ? ? ? ? "poweRlaw"? ? ? "powerMediation"? ? ? ? ? ? "powerpkg"
? ? ? ? ? ? powerplus? ? ? ? ? powerSurvEpi? ? ? ? ? ? ? PowerTOST
? ? ? ? ? "powerplus"? ? ? ? "powerSurvEpi"? ? ? ? ? ? "PowerTOST"
? ? ? ? ? ? ? PowerUpR? ? ? rPowerSampleSize? ? ? twoStageGwasPower
? ? ? ? ? ? "PowerUpR"? ? "rPowerSampleSize"? ? "twoStageGwasPower"
A more usable result:
names( avail[ grepl("pow" ,avail[ ,"Package"] , ignore.case=TRUE), "Package"] )
[1] "asypow"? ? ? ? ? ? ? "bivarRIpower"? ? ? ?
[3] "clusterPower"? ? ? ? "easypower"? ? ? ? ?
[5] "fpow"? ? ? ? ? ? ? ? "longpower"? ? ? ? ?
[7] "matpow"? ? ? ? ? ? ? "mnormpow"? ? ? ? ? ?
[9] "PharmPow"? ? ? ? ? ? "powell"? ? ? ? ? ? ?
[11] "PoweR"? ? ? ? ? ? ? ? "Power2Stage"? ? ? ?
[13] "powerAnalysis"? ? ? ? "powerbydesign"? ? ?
[15] "powerGWASinteraction" "poweRlaw"? ? ? ? ? ?
[17] "powerMediation"? ? ? "powerpkg"? ? ? ? ? ?
[19] "powerplus"? ? ? ? ? ? "powerSurvEpi"? ? ? ?
[21] "PowerTOST"? ? ? ? ? ? "PowerUpR"? ? ? ? ? ?
[23] "rPowerSampleSize"? ? "twoStageGwasPower"?
options(old.opt)? # reset options to default values
So you may find additional user-contributed power-oriented packages.
-- David Winsemius Alameda, CA, USA
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
David Winsemius Alameda, CA, USA