Mann-Kendall & Sen's Slope Calculator
How to Use This Mann-Kendall Calculator
- Paste your series in time order. One value per line works; two columns (year, value or 2015-01, value) are better because Sen's slope then uses real time spacing.
- Pick the test variant. Start with Original. Then open the Autocorrelation tab: if lag-1 autocorrelation is significant, switch to Hamed-Rao. For monthly or weekly data with a seasonal cycle, use Seasonal.
- Read the verdict and the slope together. The p-value says whether a monotonic trend is detectable; Sen's slope and its confidence interval say how large it is, in your units per time unit.
- Check robustness. The All methods tab runs every variant on your data. A trend that only one variant finds should be treated with caution.
- Export. Copy the report sentence, download the CSV, or copy the Python code to reproduce the result in your own analysis.
What is the Mann-Kendall Trend Test?
The Mann-Kendall (MK) test is a non-parametric test for a monotonic trend in a time series: a tendency for values to consistently increase or decrease over time, not necessarily in a straight line. It was introduced by Henry Mann (1945) and its distribution was developed by Maurice Kendall (1975). It is the default trend test in hydrology, climatology, water-quality monitoring and remote sensing because it makes very few assumptions.
The idea is simple. Compare every observation with every later observation. Count how many later values are higher (+1) and how many are lower (−1). If there is no trend, pluses and minuses should roughly cancel. If there is an upward trend, pluses dominate. The total is the statistic S.
Null hypothesis H₀
The data are independent and identically distributed: no monotonic trend.
Alternative H₁ (two-sided)
There is a monotonic upward or downward trend.
Why researchers prefer it
- No normality assumption. Only the signs of differences matter, so skewed rainfall or streamflow data are fine.
- Robust to outliers. One extreme flood year changes only a few signs, not the whole result.
- Handles missing values and non-detects. Gaps are skipped; values below a detection limit can be treated as ties.
What it assumes
- Independence of observations. This is the assumption most often violated in environmental data, and the reason the modified tests exist (see autocorrelation).
- A consistent measurement process. A gauge relocation or a sensor change can create a step that MK will report as a "trend".
- Monotonicity. A series that rises and then falls can return "no trend" even though it changed a lot.
If you need a refresher on z-scores and normal p-values used in the last step, see our z-score calculator and the bell curve guide. For drought indices that are often tested for trends with MK, read SPI and SPEI explained.
Mann-Kendall Formulas: S, Var(S), Z, p-value and Kendall's τ
For a series \(x_1, x_2, \dots, x_n\) in time order:
Worked micro-example (n = 5)
Series: 3, 5, 4, 7, 6. Pairs with the first value 3: (5−3)+, (4−3)+, (7−3)+, (6−3)+ → +4. From 5: (4)−, (7)+, (6)+ → +1. From 4: +, + → +2. From 7: (6)− → −1. So \(S = 4+1+2-1 = 6\), \(\operatorname{Var}(S) = 5\cdot4\cdot15/18 = 16.67\), \(Z = (6-1)/4.08 = 1.22\), \(p = 0.22\). An upward tendency, but with five points it is not significant. Load the "Small example" above to see the same mechanics on 10 points, including the sign matrix.
Sen's Slope Estimator and its Confidence Interval
The MK test says whether there is a trend. Sen's slope (Theil 1950; Sen 1968), also called the Theil-Sen estimator, says how fast. It is the median of the slopes between every pair of points:
The intercept of the robust line is \(b = \operatorname{median}(x) - \beta\cdot\operatorname{median}(t)\), so the line passes through the median point. Because Sen's slope is a median, about 29% of the points can be outliers before it breaks down, compared with a single point for ordinary least squares.
Autocorrelation: Hamed-Rao and Trend-Free Pre-Whitening
Environmental series are often positively autocorrelated: a wet year tends to follow a wet year, groundwater levels change slowly, and NDVI depends on last month's vegetation. Positive autocorrelation makes runs of high and low values look like trends, so the original MK test rejects H₀ far more often than the nominal 5%. The "Autocorrelated" example above is a pure AR(1) process with no trend by construction, yet the original test reports p < 0.05.
Hamed & Rao (1998) variance correction
Keep S, but inflate its variance by the effective sample size factor computed from the autocorrelation \(\rho_k\) of the ranks of the detrended series (only significant lags are used):
Trend-free pre-whitening, TFPW (Yue et al. 2002)
- Estimate Sen's slope \(\beta\) and remove it: \(Y'_t = X_t - \beta t\).
- Compute the lag-1 autocorrelation \(r_1\) of \(Y'\) and remove the AR(1) part: \(Y''_t = Y'_t - r_1 Y'_{t-1}\).
- Add the trend back, \(Y_t = Y''_t + \beta t\), and run the original MK test on \(Y\) (one value shorter).
Seasonal Mann-Kendall Test
Monthly rainfall, streamflow, temperature and water-quality data have a strong annual cycle. Comparing a July value with a January value says more about seasons than about trends, and the cycle's variance hides real change. Hirsch, Slack & Smith (1982) proposed computing MK separately for each season and summing:
The "Monthly flow" example shows why this matters: the original test on 120 monthly values gives p ≈ 0.13 (no trend), while the seasonal test finds a highly significant increase. The basic seasonal test assumes seasons are independent of each other; if adjacent months are strongly correlated, its p-value is also optimistic.
Seven Interpretation Pitfalls (and How to Avoid Them)
1 · Significant ≠ important
With long records, tiny slopes become significant. Always report Sen's slope with its CI and compare the total change with natural variability.
2 · Not significant ≠ no change
A non-significant result may mean the record is too short or too noisy. Look at the CI: if it spans large positive and negative values, the data are simply uninformative.
3 · Steps look like trends
A gauge relocation or sensor switch creates a jump that MK reads as a trend. Check metadata and run a change-point test (e.g. Pettitt) before claiming a gradual trend.
4 · Autocorrelation
Check lag-1 autocorrelation of the detrended series. If significant, use Hamed-Rao and say so in your methods.
5 · Start and end years
Starting a record in a drought year can manufacture an upward trend. Test sensitivity by shifting the window a few years.
6 · Many stations or pixels
Testing 10,000 grid cells at α = 0.05 gives ~500 false positives. Control the false discovery rate (Benjamini-Hochberg; see Wilks 2016) before mapping "significant" pixels.
7 · Monotonic, not linear
MK detects monotonic change, and Sen's slope summarises it as a straight line. If the plot is clearly curved, describe the shape, don't just quote a slope.
Bonus · Small n
Below n = 10 the normal approximation is rough. Use exact critical values and be cautious with any conclusion.
How to Report Mann-Kendall Results in a Paper or Thesis
A complete report states the test variant, the significance level, the statistic, the p-value and the magnitude with uncertainty. A template:
The calculator writes this sentence for you from your own numbers (tab Report & export). In the methods section, cite Mann (1945) and Kendall (1975) for the test, Sen (1968) for the slope, and the correction you used (Hamed & Rao 1998 or Yue et al. 2002). If you used Python, cite pyMannKendall (Hussain & Mahmud 2019).
Mann-Kendall vs Linear Regression Trend Test
| Aspect | Mann-Kendall + Sen's slope | Linear regression (OLS t-test) |
|---|---|---|
| Trend shape | Any monotonic trend | Linear trend only |
| Distribution | None required | Normal, constant-variance residuals |
| Outliers | Robust (median-based) | Sensitive; one point can flip the slope |
| Missing values / non-detects | Skipped / treated as ties | Skipped; non-detects need special handling |
| Power when data truly normal | ~95% of OLS efficiency | Highest |
| Autocorrelation | Needs correction (Hamed-Rao, TFPW) | Needs correction (e.g. effective n, GLS) |
| Typical use | Hydrology, climate, water quality, NDVI time series | Well-behaved, roughly normal data |
Related Tools and Guides
Frequently Asked Questions
What does the Mann-Kendall test tell you?
It tests whether a time series has a monotonic upward or downward trend. The null hypothesis is that the observations are independent and identically distributed with no trend. A small p-value (for example below 0.05) means a monotonic trend is statistically detectable. The test does not tell you how large the trend is; Sen's slope estimates the magnitude.
What is the difference between the Mann-Kendall test and Sen's slope?
The Mann-Kendall test answers "is there a trend?" using the signs of all pairwise differences. Sen's slope answers "how fast is it changing?" as the median of all pairwise slopes (xj − xi)/(tj − ti). They are usually reported together: the MK p-value for significance and Sen's slope with its confidence interval for magnitude.
How many data points do I need for a Mann-Kendall test?
The test can be computed with as few as 4 values, but the normal approximation used for the p-value is reliable only for about n ≥ 10. For n below 10, compare S against exact tables. For climate and hydrology, 20–30 or more years are commonly recommended because short records are dominated by natural variability.
When should I use the modified Mann-Kendall test?
Use a modified test when the series is serially correlated. Positive autocorrelation makes the original test detect trends too often. The Hamed-Rao (1998) variance correction is a good default. Trend-free pre-whitening (Yue et al., 2002) is popular but can still have an inflated false-positive rate, so compare both.
What is Kendall's tau in the Mann-Kendall test?
Kendall's tau is S divided by the number of pairs, n(n−1)/2. It ranges from −1 (every later value is smaller) to +1 (every later value is larger) and is a rank correlation between the data and time. It describes the consistency of the trend, not its rate of change.
Can I use the Mann-Kendall test on monthly data?
Yes, but monthly data usually contain a seasonal cycle. Use the Seasonal Mann-Kendall test (Hirsch et al., 1982), which compares January only with January, February only with February, and so on, and then combines the seasons. Select "Seasonal" and set the period to 12.
Does the Mann-Kendall test require normally distributed data?
No. It is non-parametric and uses only the signs of differences, so it works with skewed data, outliers and values below a detection limit (treated as ties). It does assume the observations are independent, which is why autocorrelation matters.
References
Mann, H. B. (1945). Nonparametric tests against trend. Econometrica, 13(3), 245–259.
Kendall, M. G. (1975). Rank Correlation Methods (4th ed.). Charles Griffin, London.
Theil, H. (1950). A rank-invariant method of linear and polynomial regression analysis. Proceedings of the Royal Netherlands Academy of Sciences, 53.
Sen, P. K. (1968). Estimates of the regression coefficient based on Kendall's tau. Journal of the American Statistical Association, 63(324), 1379–1389.
Hirsch, R. M., Slack, J. R., & Smith, R. A. (1982). Techniques of trend analysis for monthly water quality data. Water Resources Research, 18(1), 107–121.
Gilbert, R. O. (1987). Statistical Methods for Environmental Pollution Monitoring. Van Nostrand Reinhold, New York.
Hamed, K. H., & Rao, A. R. (1998). A modified Mann-Kendall trend test for autocorrelated data. Journal of Hydrology, 204(1–4), 182–196.
Yue, S., Pilon, P., Phinney, B., & Cavadias, G. (2002). The influence of autocorrelation on the ability to detect trend in hydrological series. Hydrological Processes, 16(9), 1807–1829.
Bayazit, M., & Önöz, B. (2007). To prewhiten or not to prewhiten in trend analysis? Hydrological Sciences Journal, 52(4), 611–624.
Wilks, D. S. (2016). "The stippling shows statistically significant grid points": How research results are routinely overstated and overinterpreted, and what to do about it. Bulletin of the American Meteorological Society, 97(12), 2263–2273.
Hussain, M. M., & Mahmud, I. (2019). pyMannKendall: a python package for non parametric Mann Kendall family of trend tests. Journal of Open Source Software, 4(39), 1556. github.com/mmhs013/pyMannKendall