I am looking to perform a nonparametric test for trend on a continuous outcome across three groups, preferably in Python. For example height (pretend height is not normal) in 4th, 5th and 6th graders.

I would like to implement something like the Cuzick method. Scipy has Wilcoxon rank sum and other nonparametric methods but only for two groups. Similarly, Scipy has a Kruskal-Wallis method for three groups but it does not indicate direction or trends. Does anything like this exist for exploring a directional trend across three groups?

To clarify I am trying to determining whether there is a significant shift in a continuous trait measured across three groups. The groups will be of very different size: group 1 has 1000's of samples and likely to be normally distributed, group 2 100's os samples, group 3 ~10 or less. Group 1 serves as the "control" group, and my hypothesis is that the mean value of group 1 will be shifted in either direction relative to group 0, and group 2 will be shifted further in the same direction as group 1. Because group 3 will always be very small compared to the other group, my instinct was to use nonparametric methods, but I am open to other suggestions.

Can anyone suggest a method to explore this type of directional trend?

  • $\begingroup$ Welcome to the site, @alexhli. If this question were only searching for a function or library to do this in Python, it would be off-topic for CV (see our help page). However, it's not clear to me whether that's what you are asking (eg, "preferably in Python"). If you have a substantive statistical question about these methods beyond looking for a function, would you edit to clarify it? $\endgroup$ – gung - Reinstate Monica Oct 17 '13 at 19:15
  • $\begingroup$ If you were to modify the question to something like "What is a way or ways to what I want, and is there a python implementation?" the first part should be sufficiently on topic. But then your question would require clarification (you end by asking about exploring, not testing -- those are very different exercises) $\endgroup$ – Glen_b -Reinstate Monica Oct 17 '13 at 20:24
  • $\begingroup$ There appear to be implementations of that Cuzick method in R. (e.g. Here, or here). I haven't tried these, but I'm wondering if a rank-based correlation like Spearman or Kendall would accomplish essentially the same thing. $\endgroup$ – Sal Mangiafico Aug 30 '18 at 0:59
  • $\begingroup$ Just for fun, I ran some comparisons on simulated data between the Cuzick test and Spearman correlation. (Not publication quality). Just looking at p-values: The p-values for the tests follow each other, but there's some scatter. For example when the p <= 0.05 for Cuzick test, 85% - 90% of p values from Spearman are <=0.05. If you look only at cases where Cuzick p <= 0.04 and Spearman p <= 0.05 this becomes about 95%. If you look only at cases where Cuzick p <= 0.03 and Spearman p <= 0.05 this becomes about 97%. There was no clear bias in power favoring either test. $\endgroup$ – Sal Mangiafico Aug 30 '18 at 14:16

It sounds like you're looking for the Jonckheere-Terpstra test: https://en.wikipedia.org/wiki/Jonckheere%27s_trend_test

It has higher power than the Kruskal-Wallis test because the alternative hypothesis is testing whether the groups have a directional ordering - what you're looking for - rather than simply being significantly different.

I couldn't find a built-in Python function (not that one doesn't exist), but it is fairly simple to code yourself. The Wikipedia page will probably get you there, but the procedure is very clearly explained in Higgins' Introduction to Modern Nonparametric Statistics, p. 101.

Also, it is implemented in R in the clinfun package.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.