R/lw.test.R

Defines functions lw.test

# Ledoit-Wolf sphericity test for high-dimensional data
lw.test = function(X) {
	n = nrow(X) - 1   # Fujikoshi et al., p. 219
	p = ncol(X)
	S = cov(X)
	trS = sum(diag(S))
	trS2 = sum(S^2)
	stat = (n*p*trS2/trS^2 - n - p - 1) / 2
	pvalue = 2 * pnorm(-abs(stat))
	list(stat=stat, pvalue=pvalue)
}

Try the refund package in your browser

Any scripts or data that you put into this service are public.

refund documentation built on Nov. 14, 2023, 5:07 p.m.