[R] Power of t test for unequal variances?
David Winsemius
dwinsemius at comcast.net
Tue Dec 20 04:14:12 CET 2016
> 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
More information about the R-help
mailing list