p_anova.test: p-value from one-way ANOVA simulation

View source: R/p_anova.test.R

p_anova.testR Documentation

p-value from one-way ANOVA simulation

Description

Generates continuous multi-sample data to be analyzed by a one-way ANOVA, and return a p-value. Uses the function oneway.test to perform the analyses. The data and associated test assume that the conditional observations are normally distributed and have have equal variance by default, however these may be modified.

Usage

p_anova.test(
  n,
  k,
  f,
  n.ratios = rep(1, k),
  two.tailed = TRUE,
  var.equal = TRUE,
  means = NULL,
  sds = NULL,
  gen_fun = gen_anova.test,
  ...
)

gen_anova.test(n, k, f, n.ratios = rep(1, k), means = NULL, sds = NULL, ...)

Arguments

n

sample size per group

k

number of groups

f

Cohen's f effect size

n.ratios

allocation ratios reflecting the sample size ratios. Default of 1 sets the groups to be the same size (n * n.ratio)

two.tailed

logical; should a two-tailed or one-tailed test be used?

var.equal

logical; use the pooled SE estimate instead of the Welch correction for unequal variances?

means

(optional) vector of means. When specified the input f is ignored

sds

(optional) vector of SDs. When specified the input f is ignored

gen_fun

function used to generate the required data. Object returned must be a matrix with k rows and k columns of numeric data. Default uses gen_anova.test. User defined version of this function must include the argument ...

...

additional arguments to be passed to gen_fun. Not used unless a customized gen_fun is defined

Value

a single p-value

Author(s)

Phil Chalmers rphilip.chalmers@gmail.com

See Also

gen_anova.test

Examples


# n=50 in 3 groups, "medium" effect size
p_anova.test(50, k=3, f=.25)

# explicit means/sds
p_anova.test(50, 3, means=c(0,0,1), sds=c(1,2,1))


  # compare simulated results to pwr package
  pwr::pwr.anova.test(f=0.28, k=4, n=20)
  p_anova.test(n=20, k=4, f=.28) |> Spower()



Spower documentation built on April 4, 2025, 5:11 a.m.