p_var.test: p-value from variance test simulation

View source: R/p_var.test.R

p_var.testR Documentation

p-value from variance test simulation

Description

Generates one or or more sets of continuous data group-level data to perform a variance test, and return a p-value. When two-samples are investigated the var.test function will be used, otherwise functions from the EnvStats package will be used.

Usage

p_var.test(
  n,
  vars,
  n.ratios = rep(1, length(vars)),
  sigma2 = 1,
  two.tailed = TRUE,
  test = "Levene",
  correct = TRUE,
  gen_fun = gen_var.test,
  ...
)

gen_var.test(n, vars, n.ratios = rep(1, length(vars)), ...)

Arguments

n

sample size per group, assumed equal across groups

vars

a vector of variances to use for each group; length of 1 for one-sample tests

n.ratios

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

sigma2

population variance to test against in one-sample test

two.tailed

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

test

type of test to use in multi-sample applications. Can be either 'Levene' (default), 'Bartlett', or 'Fligner'

correct

logical; use correction when test = 'Bartlett'?

gen_fun

function used to generate the required discrete data. Object returned must be a matrix with k rows and k columns of counts. Default uses gen_var.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_var.test

Examples


# one sample
p_var.test(100, vars=10, sigma2=9)

# three sample
p_var.test(100, vars=c(10, 9, 11))
p_var.test(100, vars=c(10, 9, 11), test = 'Fligner')
p_var.test(100, vars=c(10, 9, 11), test = 'Bartlett')


  # power to detect three-group variance differences
  p_var.test(n=100, vars=c(10,9,11)) |> Spower()

  # sample size per group to achieve 80% power
  p_var.test(n=NA, vars=c(10,9,11)) |>
         Spower(power=.80, interval=c(100, 1000))



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