Skip to contents

R arm of the Python modules morie.fn.pwr_t, pwr_p, pwr_av and i_pwr; the missing quantity is found by bisection to 1e-12. PowerTTest: the power function of stats::power.t.test (noncentral t, ncp = sqrt(n/tsample) delta/sd); strict = TRUE (default) includes the far rejection tail of a two-sided test, FALSE is R's default. PowerPropTest: the Fleiss normal approximation of stats::power.prop.test, or Cohen's arcsine h (pwr::pwr.2p.test). PowerAnova: one-way ANOVA power with Cohen's f (ncp = f^2 k n). CalculateInteractionPower: noncentral-F power with ncp = f^2 N on (df1, N - df1 - 1).

Usage

PowerTTest(
  n = NULL,
  delta = NULL,
  sd = 1,
  alpha = 0.05,
  power = NULL,
  alternative = "two-sided",
  type = "two-sample",
  strict = TRUE
)

PowerPropTest(
  n = NULL,
  p1 = NULL,
  p2 = NULL,
  alpha = 0.05,
  power = NULL,
  alternative = "two-sided",
  strict = TRUE,
  method = "fleiss"
)

PowerAnova(n = NULL, k = NULL, f = NULL, alpha = 0.05, power = NULL)

CalculateInteractionPower(
  sample_size,
  alpha = 0.05,
  effect_size = 0.2,
  df1 = 1
)

Arguments

n

Sample size per group (PowerTTest, PowerPropTest, PowerAnova).

delta

True difference in means.

sd

Standard deviation.

alpha

Significance level.

power

Target power.

alternative

"two-sided" or "one-sided".

type

"two-sample", "one-sample" or "paired".

strict

Include the far rejection tail of a two-sided test.

p1, p2

Proportions.

method

"fleiss" or "cohen_h".

k

Number of groups.

f

Cohen's f.

sample_size

Total sample size N.

effect_size

Cohen's f of the tested terms.

df1

Numerator degrees of freedom.

Value

The missing quantity (a number).

References

Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences, 2nd ed. Erlbaum.

Fleiss, J. L. (1981). Statistical Methods for Rates and Proportions, 2nd ed. Wiley.

Faul, F., Erdfelder, E., Lang, A.-G. and Buchner, A. (2007). G*Power 3. Behavior Research Methods 39, 175-191.

Examples

PowerTTest(n = 20, delta = 1)
#> [1] 0.868953
PowerPropTest(n = 100, p1 = 0.5, p2 = 0.7)
#> [1] 0.8281098
PowerAnova(n = 20, k = 3, f = 0.25)
#> [1] 0.3744311
CalculateInteractionPower(200)
#> [1] 0.8036475