Mann-Kendall Tau-b with Sen's Method (enhanced)

A non-parametric trend test including Sen's slope method using Mann-Kendall Tau technique


Updated 27 Aug 2020

View License

The Mann-Kendall Tau non-parametric function computes a coefficient representing strength and direction of a trend for equally spaced data. While you do not need the Statistics Toolbox to compute Tau, you do need it to test for significance. This function will compute Tau-a and Tau-b, significance (and the various supporting statistics), and also a non-parametric slope method: Sens Method.

Note: Statistics Toolbox is only needed in this function to test for significance. Otherwise, there is nothing required beyond Matlab itself.

Enhancements include: now supports a seasonal kendall trend test recently submitted (sktt.m). Will allow for multiple observations in the same time index. Confidence intervals are added for Sens slope. Also a plot can be turned on/off.

Second enhancement: test for anomalies in trends, fixes, and notifies the user. Reference is in the comments of the function.

Given the speed of computers today, avoiding loops in Matlab is not as important for some computations as it has been in the past. Nevertheless, writing functions without loops is a form of elegance I think some people may appreciate. As such, this function is written without any loops. Example syntax to use the function is:
[taub tau h sig Z S sigma sen n senplot cilower ciupper] = ktaub(datain, alpha,wantplot)

Cite As

Jeff Burkey (2023). Mann-Kendall Tau-b with Sen's Method (enhanced) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Updated comments. v was an old version accidently uploaded. (oops).

Updated comments in file.

Added citation supporting method for computing confidence intervals for Sen's slope. Thanks goes to Dr. Jeff Thompson.

Enough inquiries about citation, I've added a suggested citation to the comments. Also included an HTML created from MATLAB Publish function.

Added a test for matlab version. When people get errors, it is generally because their version of matlab is too old and the syntax is not valid.

Updated calculation of confidence intervals on Sens slope.

Updated comments.

I've gotten a couple of inquiries asking for example dataset to use. I've included a MAT file that can be used with the m-file.

Now will test for anomalies in trend estimates. Fixes and notifies the user. See comments in function for more detail and the paper used for this enhancement.

I need to get used to uploading files. I uploaded the wrong version. Sorry. The version previously uploaded had a glitch in the Confidence interval calculations. Same glitch is in the seasonal kendall (sktt.m). Fixed now.

Sorry type-o in the description. This enhanced function WILL allow for multiple observations in the time index, ties, mission values, etc.

Try number 3. The webpage timed out on my try 2.

Updated the function to account for multiple observations per time index, also modifed outputs to support the newly added Seasonal Kendall trend test- sktt.m.

My last upload must have been too recent after the previous upload. As Nicholas mentioned s wasn't assigned for small N. Also the plotting routine didn't get uploaded with the last attempt. Here is another attempt.