PowerAnalyses
Страница в процессе перевода. |
Statistical power analyses in Julia.
This package is similar to G*Power and R’s pwr
package. Unlike G*Power, PowerAnalyses is open source and can, therefore, be more easily improved and verified. Compared to pwr
, this package contains more analyses and thanks to Julia’s multiple dispatch the code of this package is simpler, that is, the code is less prone to errors.
Getting started
This package can be installed via:
using Pkg
Pkg.add("PowerAnalyses")
and allows you to determine one of the following parameters:
-
sample size
n
-
power
-
significance level
alpha
-
effect size
es
when knowing the other three parameters.
For example, to calculate the required sample size for a two tailed t-test, we can use the OneSampleTTest
type:
using PowerAnalyses
es = 0.5
alpha = 0.05
power = 0.95
T = OneSampleTTest(two_tails)
get_n(T; alpha, power, es)
53.940617903583274
Functions
The functions for determining the parameters take the following arguments:
#
PowerAnalyses.get_power
— Function
get_power(T::StatisticalTest; es::Real, alpha::Real, n)
Return the power for some test T
with effect size es
, required significance level alpha
and sample size n
.
#
PowerAnalyses.get_alpha
— Function
get_alpha(T::StatisticalTest; es::Real, power::Real, n)
Return the significance level for some test T
with effect size es
, power power
and sample size n
.
#
PowerAnalyses.get_es
— Function
get_es(T::StatisticalTest; alpha::Real, power::Real, n)
Return the minimum effect size for some test T
with significance level alpha
, power power
and sample size n
.
#
PowerAnalyses.get_n
— Function
get_n(T::StatisticalTest; alpha::Real, power::Real, es::Real)
Return minimum sample size n
for some test T
with significance level alpha
, power power
and effect size es
.
Tests
The following tests are implemented:
#
PowerAnalyses.ConstantVarianceChisqTest
— Type
ConstantVarianceChisqTest(tail::Tail) <: ChisqTest
Chi-square test for determining whether the population variance σ² equals a specific (constant) value. The effect size is the variance ratio
and defined as ratio = σ² / c
.
The result of this test is slightly different from GPower 3.1.9.7 even though the code here is based on the paper. It could be that GPower 3 has a different calculation for distribution scaling. |
#
PowerAnalyses.ConstantVectorHotellingTsqTest
— Type
ConstantVectorHotellingTsqTest(n_response_variables::Int) <: FTest
Hotelling’s T-square to test whether a vector of means differ from a constant mean vector.
#
PowerAnalyses.DependentSamplesTTest
— Type
DependentSamplesTTest(tail::Tail) <: TTest
Test a difference between pairs of values. Also known as a correlated pairs t-test, dependent samples t-test or dependent means t-test.
#
PowerAnalyses.DeviationFromZeroMultipleRegression
— Type
DeviationFromZeroMultipleRegression(n_predictors::Int) <: FTest
Deviation of R² from zero for multiple regression with n_predictors
. Combined with this test, the sample size n
means the total sample size.
#
PowerAnalyses.GoodnessOfFitChisqTest
— Type
GoodnessOfFitChisqTest(df::Int) <: ChisqTest
Chi-square goodness of fit test for categorical variables with more than two levels. Here, the degrees of freedom df
are n_groups - 1
.
#
PowerAnalyses.IncreaseMultipleRegression
— Type
IncreaseMultipleRegression(n_predictors::Int, n_tested_predictors::Int) <: FTest
Increase of R² for multiple regression with total number of predictors n_predictors
and number of tested predictors n_tested_predictors
.
#
PowerAnalyses.IndependentSamplesTTest
— Type
IndependentSamplesTTest(tail::Tail) <: TTest
Test a difference between two independent groups. When using this type, make sure that n
states the total number of samples in both groups. Also known as a independent means t-test or independent samples t-test.
#
PowerAnalyses.MultifactorFixedEffectsANOVA
— Type
MultifactorFixedEffectsANOVA(n_groups::Int, df::Int) <: FTest
Fixed effects, multifactor and planned comparisons ANOVA with n_groups
total groups in the design and df
degrees of freedom in the tested effect.
#
PowerAnalyses.OneSampleTTest
— Type
OneSampleTTest(tail::Tail) <: TTest
Test whether the sample differs from a constant.
#
PowerAnalyses.OneWayANOVA
— Type
OneWayANOVA(n_groups::Int) <: FTest
Test whether multiple means are equal. Also known as a one-way fixed effects ANOVA.
#
PowerAnalyses.Tail
— Type
Tail
Tail used in some of the tests. Can be one_tail
or two_tails
.
#
PowerAnalyses.TwoVectorsHotellingTsqTest
— Type
TwoVectorsHotellingTsqTest(n_response_variables::Int) <: FTest
Hotelling’s T-square to test whether two mean vectors differ.