Learn R Programming

pwrss (version 1.3.1)

power.f.ancova: Power Analysis for One-, Two-, Three-Way ANOVA/ANCOVA Using Effect Size (F-Test)

Description

Calculates power, sample size or effect size for one-way, two-way, or three-way ANOVA/ANCOVA. Set k.covariates = 0 for ANOVA, and k.covariates > 0 for ANCOVA. Note that in the latter, the effect size (eta.squared should be obtained from the relevant ANCOVA model, which is already adjusted for the explanatory power of covariates (thus, an additional R-squared argument is not required as an input).

Formulas are validated using G*Power and tables in the PASS documentation.

Usage

power.f.ancova(
  eta.squared = NULL,
  null.eta.squared = 0,
  factor.levels = 2,
  target.effect = NULL,
  k.covariates = 0,
  n.total = NULL,
  power = NULL,
  alpha = 0.05,
  ceil.n = TRUE,
  verbose = 1,
  utf = FALSE
)

Value

parms

list of parameters used in calculation.

test

type of the statistical test (F-Test).

eta.squared

(partial) eta-squared for the alternative.

df1

numerator degrees of freedom.

df2

denominator degrees of freedom.

ncp

non-centrality parameter for the alternative.

null.ncp

non-centrality parameter for the null.

f.alpha

critical value.

power

statistical power \((1-\beta)\).

n.total

total sample size.

Arguments

eta.squared

(partial) eta-squared for the alternative.

null.eta.squared

(partial) eta-squared for the null.

factor.levels

integer; number of levels or groups in each factor. For example, for two factors each having two levels or groups use e.g. c(2, 2), for three factors each having two levels (groups) use e.g. c(2, 2, 2).

target.effect

character; determine the main effect or interaction that is of interest, e.g., in a three-way-design, it is possible to define "A" (main effect of the first factor), "B:C" (interaction of factor two and three) or "A:B:C" (the three-way interaction of all factors); if target is not used, the three-way interaction is the default.

k.covariates

integer; number of covariates in an ANCOVA model

n.total

integer; total sample size

power

statistical power, defined as the probability of correctly rejecting a false null hypothesis, denoted as \(1 - \beta\).

alpha

type 1 error rate, defined as the probability of incorrectly rejecting a true null hypothesis, denoted as \(\alpha\).

ceil.n

logical; if FALSE sample size in each cell is not rounded up.

verbose

1 by default (returns test, hypotheses, and results), if 2 a more detailed output is given (plus key parameters and definitions), if 0 no output is printed on the console.

utf

logical; whether the output should show Unicode characters (if encoding allows for it). FALSE by default.

Details

Note that R has a partial matching feature which allows you to specify shortened versions of arguments, such as mu or mu.vec instead of mu.vector, or such as k or k.covariates instead of k.covariates.

References

Bulus, M., & Polat, C. (2023). pwrss R paketi ile istatistiksel guc analizi [Statistical power analysis with pwrss R package]. Ahi Evran Universitesi Kirsehir Egitim Fakultesi Dergisi, 24(3), 2207-2328. https://doi.org/10.29299/kefad.1209913

Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.

Examples

Run this code

#############################################
#              one-way ANOVA                #
#############################################

# Cohen's d = 0.50 between treatment and control
# translating into eta-squared = 0.059

# estimate sample size using ANOVA approach
power.f.ancova(eta.squared = 0.059,
               factor.levels = 2,
               power = .80, alpha = 0.05)

# estimate sample size using regression approach(F-Test)
power.f.regression(r.squared = 0.059,
                   k.total = 1,
                   power = 0.80, alpha = 0.05)

# estimate sample size using regression approach (t-Test)
p <- 0.50 # proportion of sample in treatment (allocation rate)
power.t.regression(beta = 0.50, r.squared = 0,
                   k.total = 1,
                   sd.predictor = sqrt(p * (1 - p)),
                   power = 0.80, alpha = 0.05)

# estimate sample size using t test approach
power.t.student(d = 0.50, power = 0.80, alpha = 0.05)

#############################################
#              two-way ANOVA                #
#############################################

# a researcher is expecting a partial eta-squared = 0.03
# for interaction of treatment (Factor A) with
# gender consisting of two levels (Factor B)

power.f.ancova(eta.squared = 0.03,
               factor.levels = c(2,2),
               power = 0.80, alpha = 0.05)

# estimate sample size using regression approach (F test)
# one dummy for treatment, one dummy for gender, and their interaction (k = 3)
# partial eta-squared is equivalent to the increase in R-squared by adding
# only the interaction term (m = 1)
power.f.regression(r.squared = 0.03,
                   k.total = 3, k.test = 1,
                   power = 0.80, alpha = 0.05)

#############################################
#              one-way ANCOVA               #
#############################################

# a researcher is expecting an adjusted difference of
# Cohen's d = 0.45 between treatment and control after
# controllling for the pretest (k.covariates = 1)
# translating into eta-squared = 0.048

power.f.ancova(eta.squared = 0.048,
               factor.levels = 2,
               k.covariates = 1,
               power = .80, alpha = 0.05)

#############################################
#              two-way ANCOVA               #
#############################################

# a researcher is expecting an adjusted partial eta-squared = 0.02
# for interaction of treatment (Factor A) with
# gender consisting of two levels (Factor B)

power.f.ancova(eta.squared = 0.02,
               factor.levels = c(2,2),
               k.covariates = 1,
               power = .80, alpha = 0.05)

Run the code above in your browser using DataLab