# Mann-Kendall test for multiple groups

I'm currently working on a problem, where I want to test weather there is a trend in the course of a certain metric in an animal, where I wanted to use something like the Mann-Kendall test. The problem is that I have data for multiple animals, which presumably have different starting values.

Therefore I think it is not wise compare all data points with each other but rather only data points of the respective animal with each other but I still want a result across all animals, e.g. the value decreases over time in all animals (with some tau value).

Is there a good way of doing it? My Idea would be to modify the Mann-Kendall so that the mean of the rank difference is not taken across all possible pairs of permutation but rather only on the pairs of the same animal. But then also the variance has to be changed which seemed to me quite tedious to calculate and was probably done already. Does anybody know a source to that or how it is called? Or is there a better way of doing it?

Regarding

A parametric model might be more powerful and more informative. A parametric model can provide information about the magnitude and linearity of the trend, not just whether it's "statistically significant."

I could find different opinions on weather to use parametric or non-parametric tests. My current consense out of all what I read is that one should use parametric tests if there is reason to believe that the requirment is meet, i.e. most of the time some sort of normality assumption and else use non-parametric although parametric are often quite good also for not normality distributed data but are usaly outperformed by non-parametric test in this scenario. For my case there is no good reason to assume why the data should be normal distributed i even expect the error is more leaning to one side then to the other.

Furthermore I'm at the moment mainly interested in testing for trends in the data and i'm not sure weather they are linear.

Model time flexibly, for example with restricted cubic regression splines. You can then test whether there is evidence of a significant non-linear component to the trend.

This maybe solves this problem but i don't have any experience with such test and have to look into it.

Do separate Mann-Kendall tests on each of the animals. Get the normalized score value for each animal (S divided by square root of var(S), both provided by the MannKendall() function in the Kendall package). Determine whether the mean of the normalized score value over all animals is different from 0 via a one-sample t-test.

This works independent to the sample size? Because i only have 4 animals in total.

I just read about the seasonal mann Kandell test, this should yield similar results to your proposed method right? (each animal is one season)

A parametric model might be more powerful and more informative. A parametric model can provide information about the magnitude and linearity of the trend, not just whether it's "statistically significant."

The Mann-Kendall test is just the Kendall rank-correlation test of values against time. As the manual for the Kendall() function in the Kendall package says:

It may also be noted that usual Pearson correlation is fairly robust and it usually agrees well in terms of statistical significance with results obtained using Kendall’s rank correlation.

The Pearson correlation is the standardized linear regression coefficient. So why not try simple linear regression versus time? Or, better, allow for a flexibly non-linear association of your outcome metric versus time. You can do that with a parametric regression model that includes time and the individual animals as predictors of your outcome metric.

Model time flexibly, for example with restricted cubic regression splines. You can then test whether there is evidence of a significant non-linear component to the trend.

Choose whether to treat animals as fixed or random effects based on your study design. Either approach will account for "different starting values." You could also allow for different trends among animals beyond their "different starting values" with interaction terms for fixed effects, or with random slopes.

If you nevertheless want to do Mann-Kendall tests you might take advantage of the following characteristic of the Kendall rank-correlation, from the above manual page:

An advantage of the Kendall rank correlation over the Spearman rank correlation is that the score function S nearly normally distributed for small n and the distribution of S is easier to work with.

Do separate Mann-Kendall tests on each of the animals. Get the normalized score value for each animal (S divided by square root of var(S), both provided by the MannKendall() function in the Kendall package). Determine whether the mean of the normalized score value over all animals is different from 0 via a one-sample t-test.

In response to revised question:

there is no good reason to assume why the data should be normal distributed

The data don't have to have a normal distribution. It's ideal if the errors around the model predictions are. Under much weaker assumptions, a linear regression (potentially including non-linear terms like regression splines) can provide very useful models.

I'm at the moment mainly interested in testing for trends in the data and i'm not sure weather they are linear

Restricting yourself to a trend test might undercut your ability to find the true association between outcome and time. For example, say you have a very rapid initial trend followed by a slow continued trend or no later trend. The Mann-Kendall test might well show no trend at all, depending on the proportion of your data from the late slow/no-trend timepoints. That's why I suggested looking at your data first. A regression spline or a generalized additive model can pick up that type of behavior over time while a simple trend test might not.

This [one-sample t-test] works independent to the sample size? Because i only have 4 animals in total.

With only 4 animals in your sample you have limited power to detect a true response, but you can still perform a 1-sample t-test to see if the mean normalized score over those 4 is different from the null hypothesis of a 0 mean value.

I just read about the seasonal mann Kandell test, this should yield similar results to your proposed method right?

I don't have experience with the seasonal test. If each animal has all measurements from a single season, it wouldn't seem to be helpful for you, as it evidently tries to account for seasonal variation within each time series.

• There are multivariate implementations of the MK test however, how would they compare to this simple t-test over independent MK tests? (In particular, does correlation between different time series have impact on the result?) Commented Jun 1, 2023 at 20:55
• @joaocandre In general, when there are correlations you are best served by a multivariate model and test. You might get the same point estimates, but the (co)variance estimates will be better as they account for the correlations. I don't have specific experience with the multivariate MK test, however.
– EdM
Commented Jun 1, 2023 at 21:24
• One additional comment I would make is that using a t-test allows testing for both (positive/negative) trends simultaneously, by using the absolute value of the test statistic (unsure if test requirements/assumptions remain valid) Commented Jun 2, 2023 at 1:17

Use z-Cusum because your variable may be increasing during a particular time interval and then decrease thereafter, effectively cancelling out over the whole timespan. Cusum can show when it is increasing and when it's not.