Skip to content

Instantly share code, notes, and snippets.

@daskelly
Created March 26, 2020 02:29
Show Gist options
  • Save daskelly/aa5be568629bbdb3a1cb06dc8584f7ac to your computer and use it in GitHub Desktop.
Save daskelly/aa5be568629bbdb3a1cb06dc8584f7ac to your computer and use it in GitHub Desktop.
Simple code for a t-test with unequal variance on ranked values
wilcox_unequal_var <- function(x, y, ...) {
# The Wilcoxon rank sum test (Mann Whitney U test) does not perform
# that well on data where the variances are unequal. Some
# investigators have recommended as an alternative performing the
# unequal variance t-test on ranked values. See
# https://academic.oup.com/beheco/article/17/4/688/215960
# https://psycnet.apa.org/doiLanding?doi=10.1037%2Fh0078850
rr <- rank(c(x, y))
nx <- length(x)
t.test(rr[1:nx], rr[(nx+1):length(rr)], var.equal=FALSE, ...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment