p_scale: p-value from Scale Test simulation

View source: R/p_scale.R

p_scaleR Documentation

p-value from Scale Test simulation

Description

Simulates data given one or two parent distributions and returns a p-value testing that the scale of the type distributions are the same. Default implementation uses Gaussian distributions, however the distribution function may be modified to reflect other populations of interest. Uses ansari.test or mood.test for the analysis.

Usage

p_scale(
  n,
  scale,
  n2_n1 = 1,
  two.tailed = TRUE,
  exact = NULL,
  test = "Ansari",
  parent = function(n, ...) rnorm(n),
  ...
)

Arguments

n

sample size per group

scale

the scale to multiply the second group by (1 reflects equal scaling)

n2_n1

sample size ratio

two.tailed

logical; use two-tailed test?

exact

a logical indicating whether an exact p-value should be computed

test

type of method to use. Can be either 'Ansari' or 'Mood'

parent

data generation function (default assumes Gaussian shape). Must be population mean centered

...

additional arguments to pass to simulation functions (if used)

Value

a single p-value

Author(s)

Phil Chalmers rphilip.chalmers@gmail.com

Examples


# n=30 per group,
#  Distributions Gaussian with sd=1 for first group and sd=2 for second
p_scale(30, scale=2)
p_scale(30, scale=2, test='Mood')

# compare chi-squared distributions
parent <- function(n, df, ...) rchisq(n, df=df) - df
p_scale(30, scale=2, parent=parent, df=3)


  # empirical power of the experiments
  p_scale(30, scale=2) |> Spower()
  p_scale(30, scale=2, test='Mood') |> Spower()

  p_scale(30, scale=2, parent=parent, df=3) |> Spower()
  p_scale(30, scale=2, test='Mood', parent=parent, df=3) |> Spower()



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