john.nagao.statistic: John and Nagao test statistics

View source: R/john_nagao_tests.R

john.nagao.statisticR Documentation

John and Nagao test statistics

Description

This function computes the test statistic for testing equality of covariance matrices as described by John (1972) and Nagao (1973)

Usage

john.nagao.statistic(x, test = "identity")

Arguments

x

data matrix with rows representing samples and columns representing variables

test

The type of test being performed - "identity"(default) or "sphericity". If test == "identity", the Nagao test statistic is computed and when test == "sphericity", the John test statistic is computed.

Value

A list with two values

test.statistic

The test statistic value

p.value

The p-value

References

S. John. The Distribution of a Statistic Used for Testing Sphericity of Normal Distributions. Biometrika, 59(1):169–173, 1972. H. Nagao. On some test criteria for covariance matrix. The Annals of Statistics, 1(4):700–709, 1973.

Examples

library(mvtnorm)
# Nagao's test for identity
x = rmvnorm(n = 20, mean = numeric(100), sigma = diag(100))
john.nagao.statistic(x, test = "identity")
# John's test for sphericity
y = rmvnorm(n = 10, mean = runif(100, 1, 3), sigma = diag(rgamma(100, 10, 3)))
john.nagao.statistic(y, test = "sphericity")

dnayyala/cramp documentation built on June 27, 2023, 1:34 p.m.