The code performs original two tailed Mann-Kendall test. It tests the null hypothesis of trend absence in the vector V, against the alternative of trend.
The result of the test is returned in H = 1 indicates a rejection of the null hypothesis at the alpha significance level. H = 0 indicates a failure to reject the null hypothesis at the alpha significance level.
Can anyone help me please? I have tried different types of vectors and it doesn't work. I am getting two errors, first:
??? Undefined function or method 'Sqrt' for input arguments of type 'double'
and then too many outputs.
I would really appreciate if anyone could tell me an example of the vectors and if there is any other mistake. Thanks
alpha = alpha/2; %
S = S + sum(sign(V(i+1:n) - V(i)));
p_value=2*(1-normcdf(abs(z),0,1)); % tail on both sides
First of all thank you. I've made some minor change to your code as follow,to include tied groups in Calculating the variance:
after line 48:
% Determining the variance (tied group included)
It is working very well and is very convenient to use since it returns the result of the hypothesis test, not just the test statistic. But: the alternative of S = 0 --> Z = 0 is not accounted for if I'm right.
For future updates I would also wish for a default significance level (for convenience). And perhaps a mention in the help text that there should be no autocorrelation in residuals.