MauchlyTest: Mauchly's Test for Sphericity (1 factor) v1.0

View source: R/MauchlyTest.R

MauchlyTestR Documentation

Mauchly's Test for Sphericity (1 factor) v1.0

Description

Tests for sphericity in repeated measures designs. Uses an interface for type formula dv ~ within | id, where:

  • dv: variable numerical response,

  • within: within-subjects factor (repeated levels),

  • id: subject/sample identifier.

Usage

MauchlyTest(formula, data, alpha = 0.05, digits = 4, do_print = TRUE)

Arguments

formula

Formula dv ~ within | id.

data

data.frame with the variables.

alpha

Significance level (default 0.05).

digits

Decimals for printing (default 4).

do_print

if TRUE, print a friendly summary.

Details

Calculates Mauchly's statistic W, its approximation W corrected, the p-value and the correction coefficients for lack of sphericity (Greenhouse–Geisser y Huynh–Feldt).

Value

Objeto de clase "sphericity" with:

Method

Cadena con el método.

Statistic

Lista con W y Chi2.

df

Grados de libertad.

p_value

Valor-p.

Decision

"Sphericity" o "No sphericity" según alpha.

Epsilons

GG and HF.

Components

List with n (subjects), k (levels), S (covariances), eigen (eigenvalues).

References

Mauchly, J. W. (1940). Significance test for sphericity of a normal n-variate distribution. The Annals of Mathematical Statistics, 11(2), 204–209. https://doi.org/10.1214/aoms/1177731915

Examples

# Ejemplo mínimo (datos ficticios):
set.seed(1)
d <- data.frame(
  id = rep(1:10, each = 4),
  within = rep(paste0("t", 1:4), times = 10),
  y = as.numeric(rep(rnorm(10, 10, 2), each = 4)) +
      rep(c(0, .5, 1.2, .8), times = 10) + rnorm(40, 0, 1)
)
res <- MauchlyTest(y ~ within | id, data = d, do_print = TRUE)
summary(res)

Analitica documentation built on Nov. 5, 2025, 5:13 p.m.