File Exchange

image thumbnail

Seasonal Kendall Test with Slope for Serial Dependent Data

version (13.1 KB) by Jeff Burkey
Seasonal trends using tau-a,b and seasonal slope with intervals, accounts for serial dependence.


Updated 21 Feb 2012

View Version History

View License

Seasonal Kendall Trend Test for Data with and without Searial Dependance.

Tau-b seasonal: takes into account ties (and multiple observations, except, the data are preprocessed in a subfucntion and multiple observatiosn per a given season are averaged using median).

Tau-a seasonal: does not consider multiple observations per season as ties. The data are preprocessed, seasons with multiple observations are summarized with a median value.

This routine will take into data evenly spaced by seasons. Compute Seasonal Tau-b, Tau, Sen's slope and it's confidence intervals.

Accounting for Serial Correlation is based on the below paper:
Hirsch, R. M., Slack, J. R., A Nonparametric Trend Test for Seasonal Data with Serial Dependence. Water Resources Research Vol 20, No. 6, pages 727-732, June 1984.

12/13/2008 - added Homogeneity test of trends for different seasons.
12/17/2008 - added adjustments to significance with serial
correlations removed by computing covariance instead of assuming zero.
Starting season can be users specified.
12/18/2008 - mulitiple observations in a single season are median averaged.
1/17/2009 - checks for anomalies and provides solutions and/or
notifications. Also requires the updated ktaub.m file
because of the need for a computed variance with no ies
2/2/2009 - modified comments in this file
2/21/2012 - when there were multiple values within the same season,
the seasonAverage subroutine wasn't storing the averaged data
correctly. Fixed in this revision. Thank you to Juan Carlos for pointing
this out!

Dependencies: ktaub.m
Statistics Toolbox

This function does require ktaub.m which has also been revised to support this function, so if you've previously downloaded ktuab.m, please check to make sure you have the most recent version.

Note: Calculating the covariance depends on when your seasons start in the year. For example, the USGS program Kendall.exe will automatically assume that Season 1 is the start of a water year (i.e. Season 1 = October, Season 12 = September). True that the 1984 Hirsch paper is dervied using 12-seasons (i.e. months), it is certainly reasonable to assume that the number of seasons can be something other than 12 months, and not necessariliy starting in October. So this function allows for the user to specify when Season 1 is to start. This nuance is critical because incomplete years are filled in with mid-ranks in the covariance.

These seasonal statistics were inspired by: Richard O. Gilbert, Pacific Northwest National Laboratories, "Statistical methods for Environmental Pollution Monitoring", 1987, Van Nostrand Reinhold, New York Publishing, ISBN 0-442-23050-8.

A good supporting statistic that may prove useful is performing a global trend test evaluating homogeneity of trends for different stations and seasons.
See the posted function namged: GlobalTrends.m
datain structure is assumed to vary as the following:
datain(:,1) = Time (e.g. year)
datain(:,2) = season
datain(:,3) = data
alpha = assumed level of confidence
wantplot = flag if ~= 0 then a figure will be created if Tau-b is
significant. StartSeason = shift seasons to start with this one.
Example: StartSeason = 10 will shift seasons 10 = 1, then years are adjusted to start with the new season shift.

[taubsea tausea Sens h sig sigAdj Zs Zmod Ss Sigmas CIlower CIupper]
= sktt(datain,alpha,wantplot,StartSeason)

Cite As

Jeff Burkey (2020). Seasonal Kendall Test with Slope for Serial Dependent Data (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Halya Petzold

Just a heads up to any users: I think this function ignores values of zero. See lines 384 and 419 within the serialAdjusted function built in to sktt.

nguyen ly sy phu

Masanta, Can you explain more about the function that you're mentioned. Sorry because I didn't fully understand your meaning.
Thank you

load ex1b
[taubsea tausea Sens h sig sigAdj Zs Zmod Ss Sigmas CIlower CIupper]= sktt(datain,alpha,wantplot,startSeason)

nguyen ly sy phu

Hello, Jeff.
Can your code export the monthly trend for every month (ex: Month = season) because I only can obtain the overall trend (yearly trend). Also, the calculated for the serial dependence or independence?
Thank you

Wu Zhiyong

Thanks Jeff.

nicolas zegre

thank you for all that you contribute to hydro analyses, greatly appreciated! Is there significant trend in the example data that you provide for sktt?

Jeff Burkey

It certainly has potential. But whether it can or not reallyh depends on what you're trying to do. As you can imagine statistics is all about semantics. Seasonality can have different meanings. My code will perform a trend analysis on a time series. how you set up your data for seasons is dependant on what question you're trying to answer. I also wrote a Kendall seasonal program, but again you need to be very clear on what you want a season to mean. I would read the comments in the files to get a better understanding.


I´m new in matlab.
I need analyze the seasonality in wind data. This routine can help me?

Jeff Burkey

I've included a MAT file with example data to run the function. I hope this helps.

MATLAB Release Compatibility
Created with R2008b
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!