Skip to content
Prev 300144 / 398506 Next

significance test interquartile ranges

Hello,

Em 14-07-2012 13:08, peter dalgaard escreveu:
Right, thank you! It forced me to pay more attention to what I was 
reading. The "test is aimed at differences in scale only, presuming no 
difference in location"
http://www.stat.ncsu.edu/information/library/mimeo.archive/ISMS_1986_1499.pdf

The original can be found at
http://www.dwc.knaw.nl/DL/publications/PU00018486.pdf

If we subtract the median of each sample to each of them, the medians 
become zero but the IQRs remain as they were. In my simulation I had 
chosen samples from distributions with equal mean, and that point passed 
unnoticed.

The code should then be slightly revised. I'll repost it because there 
was a typo in the 'method' member of the returned list

iqr.test <- function(x, y){
	data.name <- deparse(substitute(x))
	data.name <- paste(data.name, ", ", deparse(substitute(y)), sep="")
	x <- x - median(x)
	y <- y - median(y)
	qq <- quantile(c(x, y), prob = c(0.25, 0.75))
	a <- sum(qq[1] < x & x < qq[2])
	b <- length(x) - a
	c <- sum(qq[1] < y & y < qq[2])
	d <- length(y) - b
	m <- matrix(c(a, c, b, d), ncol = 2)
	numer <- sum(lfactorial(c(margin.table(m, 1), margin.table(m, 2))))
	denom <- sum(lfactorial(c(a, b, c, d, sum(m))))
	p.value <- 2*exp(numer - denom)
	method <- "Westenberg-Mood test for IQR equality"
	alternative <- "the IQRs are not equal"
	ht <- list(
		p.value = p.value,
		method = method,
		alternative = alternative,
		data.name = data.name
	)
	class(ht) <- "htest"
	ht
}

Rui Barradas