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_powerFunction

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_alphaFunction

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_esFunction

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_nFunction

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.ConstantVarianceChisqTestType

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.ConstantVectorHotellingTsqTestType

ConstantVectorHotellingTsqTest(n_response_variables::Int) <: FTest

Hotelling’s T-square to test whether a vector of means differ from a constant mean vector.

# PowerAnalyses.DependentSamplesTTestType

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.DeviationFromZeroMultipleRegressionType

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.GoodnessOfFitChisqTestType

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.IncreaseMultipleRegressionType

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.IndependentSamplesTTestType

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.MultifactorFixedEffectsANOVAType

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.OneSampleTTestType

OneSampleTTest(tail::Tail) <: TTest

Test whether the sample differs from a constant.

# PowerAnalyses.OneWayANOVAType

OneWayANOVA(n_groups::Int) <: FTest

Test whether multiple means are equal. Also known as a one-way fixed effects ANOVA.

# PowerAnalyses.TailType

Tail

Tail used in some of the tests. Can be one_tail or two_tails.

# PowerAnalyses.TwoVectorsHotellingTsqTestType

TwoVectorsHotellingTsqTest(n_response_variables::Int) <: FTest

Hotelling’s T-square to test whether two mean vectors differ.