This script is used to calulate the power, Type 1 and Type 2 error in the sex differences in visual perception project.
Because there are 4 variables, if we choose an initial \(\alpha=0.05\), the Bonferonni correction for multiple comparisons would be \(0.05/4=0.0125\). So, we choose \(p=0.01\) as our criterion.
We use the pwr
package for this analysis.
# Power Calculations For Two Samples (Same Sizes) T-Tests Of Means
library(pwr)
# assume 50 males and 250 females are collected. Males are predicted to have lower threshold than females. So we use one-tailed t test
pwr.t.test(n = 150, d = NULL, sig.level = 0.05/4, power=0.8 ,type="two.sample",alternative="greater")
##
## Two-sample t test power calculation
##
## n = 150
## d = 0.3575352
## sig.level = 0.0125
## power = 0.8
## alternative = greater
##
## NOTE: n is number in *each* group
# Power Calculations For Two Samples (Different Sizes) T-Tests Of Means
library(pwr)
# assume 50 males and 250 females are collected. Males are predicted to have lower threshold than females. So we use one-tailed t test
pwr.t2n.test(n1 =150, n2= 150, d = NULL, sig.level = 0.05/4
, power = 0.8, alternative = c( "less"))
##
## t test power calculation
##
## n1 = 150
## n2 = 150
## d = -0.3575352
## sig.level = 0.0125
## power = 0.8
## alternative = less
Assuming two-sample t-test, one tailed, and \(p=0.0125\).
pwr.t.test(n = NULL, d = 0.25, sig.level = 0.05/4 , power = 0.8, type = "two.sample", alternative = "greater")
##
## Two-sample t test power calculation
##
## n = 305.4207
## d = 0.25
## sig.level = 0.0125
## power = 0.8
## alternative = greater
##
## NOTE: n is number in *each* group
# Power Calculations For Correlation Test
# power of test or determine parameters to obtain target power (same as power.anova.test).
pwr.r.test(n = 147, r = NULL, sig.level = 0.05/5, power = 0.8,
alternative = c("less"))
##
## approximate correlation power calculation (arctangh transformation)
##
## n = 147
## r = -0.2574376
## sig.level = 0.01
## power = 0.8
## alternative = less
Assuming corelation test, one tailed, and \(p=0.0125\).