After more than a year of having to go back and forth between the R pwr package and G*Power, I finally decided that enough was enough and so there is now a Julia package for power analysis called PowerAnalyses.jl.

The aim of the package is quite straightforward and the same as the aforementioned packages: Given three parameters out of { alpha, power, effect size, sample size }, determine the fourth parameter. For example, to find the required sample size a study, use

julia> using PowerAnalyses
julia> es = 0.5
0.5
julia> alpha = 0.05
0.05
julia> power = 0.95
0.95
julia> n = get_n(OneSampleTTest(two_tails); alpha, power, es)
53.941

As a side note, this package was actually super much fun to make. The way that multiple-dispatch, Distributions.jl and Roots.jl worked together was just too good to be true

Specifically, for the interested people, the pwr package is full of code duplication. For example, compare:

Another explanation: Statistical tests can tell you whether something is significantly different from some other thing. However, if you donât have enough data, then there is a big chance that the test will always be not significant. For example, when you do a t-test to compare two samples of both 4 elements, the difference has to be huge for the test to say âthe samples are significantly differentâ.

With a power analysis, you can estimate how big your sample should be (a priori power analysis) to make it less likely that youâre wasting time on a study which would be very unlikely to find something anyway (to run an underpowered study).

(You could also just use a Bayesian analysis because it is more intuitive/coherent, but I guess thatâs a discussion for another thread.)

Iâve considered and tried basing the types on HypothesisTests.jl. The problem is that those types would make the API for PowerAnalyses much more complex without any clear benefit.