Recap the concept of statistical power
Introduce power analysis for study planning
Differentiate analytic from simulation based power calculations
Introduce R tools for both analytic and simulation power calculations
In planning, power analysis often boils down to understanding what sample size is big enough for a study.
What is big enough?
Power analysis can help us to work out how much data we should collect for our studies.
So you don't waste your time.
So you don't waste other people's time.
So you can answer the question(s) you're interested in.
Analytical solutions essentially just take known numbers;
...and solve for an unknown number
If you have an...
If you have an...
For complex designs, simulation can be used to estimate power.
If enough simulations are conducted, simulation-based estimates of power will approximate estimates of power from analytical solutions.
Why is it needed?
People commonly talk about underpowered studies.
This is not strictly true.
What we are conducting our power analysis on is a particular combination of design, statistical test, and effect size.
Read more here
Often researchers are asked to calculate power after they have collected data.
It is meaningless.
Consider a definition of power (bold added):
"The power of a test to detect a correct alternative hypothesis is the pre-study probability that the test will reject the test hypothesis (e.g., the probability that P will not exceed a pre-specified cut-off such as 0.05)." (Greenland et al., 2016, p. 345)
Conventionally, alpha is fixed, most commonly at .05. A common conventional value for power is .8.
However, both of these conventions are arbitrary cut-offs on continuous scales.
Note that if these conventions are used together, we should expect four times as many Type II errors as Type I errors.
It is important to justify your decisions, including the alpha and power levels you choose (see Lakens et al., 2017).
Where we left off...
Let's use an an independent samples t-test.
In our imaginary study, we will compare the high striker scores of two population-representative groups:
We hypothesise that the training group will have higher scores.
To begin, let's work with typical sample and effect sizes.
The median total sample size across four APA journals in 2006 was 40 (Marsazalek, Barber, Kohlhart, & Holmes, 2011, Table 1).
A Cohen's d effect size of 0.5 has been considered a medium effect size (Cohen, 1992, Table 1). We can plug these values in and work out what our statistical power would be with them if we use the conventional alpha level of .05.
We will use the pwr
package.
library(pwr)pwr.t.test(n = 20, d = 0.5, sig.level = .05, type= "two.sample", alternative = "two.sided")
pwr.t.test(n = 20,d = 0.5, sig.level = .05, type= "two.sample", alternative = "two.sided")
## ## Two-sample t test power calculation ## ## n = 20## d = 0.5## sig.level = 0.05## power = 0.337939## alternative = two.sided## ## NOTE: n is number in *each* group
Our power is only .34!
So if there is a true standardised effect of .5 in the population, studies with 20 participants per group should only expect to reject the null hypothesis about 34% of the time.
pwr.t.test(n = 20, d = 0.5, sig.level = .05, type= "two.sample", alternative = "greater")
## ## Two-sample t test power calculation ## ## n = 20## d = 0.5## sig.level = 0.05## power = 0.4633743## alternative = greater## ## NOTE: n is number in *each* group
pwr.t.test(power = 0.95, d = 0.5, sig.level = .05, type= "two.sample", alternative = "greater")
## ## Two-sample t test power calculation ## ## n = 87.26261## d = 0.5## sig.level = 0.05## power = 0.95## alternative = greater## ## NOTE: n is number in *each* group
pwr.t.test(power = 0.95, d = 0.5, sig.level = .005, type= "two.sample", alternative = "greater")
## ## Two-sample t test power calculation ## ## n = 144.1827## d = 0.5## sig.level = 0.005## power = 0.95## alternative = greater## ## NOTE: n is number in *each* group
res <- pwr.t.test(power = 0.95, d = 0.5, sig.level = .005, type= "two.sample", alternative = "greater")plot(res)
Where we left off...
We are primarily showing you how to use the pwr
functions for common tests.
But sometimes we need to estimate power a different way.
Here we will briefly flag two packages that can be used for power by simulation.
paramtest
)To use paramtest
we define a function that...
We then use the paramtest
functions to run the simulation.
paramtest
)t_func <- function(simNum, N, d) { # simNum is the number of simulations we want x1 <- rnorm(N, 0, 1) # N is the number of participants in each group x2 <- rnorm(N, d, 1) # d is the expected effect size t <- t.test(x1, x2, var.equal=TRUE) # runs t-tests on the simulated datasets stat <- t$statistic # extracts t-values from the t-tests p <- t$p.value # extracts p-values from the t-tests return(c(t = stat, p = p, sig = (p < .05)))}
paramtest
)head(results(power_ttest <- run_test( t_func, n.iter = 1000, output = 'data.frame', N = 20, d = 0.5)))
## Running 1,000 tests...
## iter t.t p sig## 1 1 -1.2440002 0.22111872 0## 2 2 -0.1268177 0.89975335 0## 3 3 -0.6888123 0.49512577 0## 4 4 -2.1953907 0.03431417 1## 5 5 -1.4636570 0.15151133 0## 6 6 -0.0323007 0.97440132 0
paramtest
)table(power_ttest$results$sig)/1000
## ## 0 1 ## 0.647 0.353
WebPower
)I want to do no more than tell you WebPower
exists.
There is an R package that does all of the simple analytic tests
Power analysis is an important step in study design
For simple models, we can make use of the pwr._
functions for analytic solutions
For complex models, we can estimate power by simulation.
Both can be done in R.
Recap the concept of statistical power
Introduce power analysis for study planning
Differentiate analytic from simulation based power calculations
Introduce R tools for both analytic and simulation power calculations
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |