Mann Kendall Test - Sen's Slope

Hello to everyone,

Let’s suppose we have 3-hourly fluxes of solar radiation at surface, for a period 1980-2020.
I want to apply Mann Kendall Test to this time-series and find the Sen’s slope, intercept, p_value and tau.
I am new user and i don’t find any package to calculate this. Have you any Julian suggestions ? ?
I know about python’s pymannkendall, that gives that i want, but when i PyCall it, it gives me error (too large iterator) for the whole time series period. However when i use it for the half period for example, it works fine…

Thank you for your time.


just got your email :slight_smile:

As far as I know, there is nothing coded right now in Julia. There is this Matlab Toolbox/code:

The license allows for redistribution in code or binary form provided you keep the copyrights, etc…

It is about 250 lines of code, so might be “straightforward” to recode it from this source?

thanks for your advice.
I will start to recode it.

Here is the non parametric Mann-Kendall Test and Sen’s slope for Julia:

As you can see input/output is sth like this:
julia> mk(x,y)
(reject_null_hypothesis = false, p_value = 0.4369827573849885, Tau = -0.02374739039665971, slope = -7.613151196044908e-5, intercept = 0.5150870782436969)

BUT, the issue now is that when my dataset is too large this function is too slow or give OutOfMemory Error. Too large i mean the length is ~10,000 in 1GB RAM, or 200,000 for 32 GB.

However, with the same length, the GLM.jl [ lm = fit(LinearModel, @formula(y ~ x),df) ] works fine !
So, i think that with some way, someone, can modify this function in order to win these memory issues.
I would greatly appreciate if anyone could find a solution to this.

Cheers, Michael