Apply Mann-Kendall Test on a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hello friends, me again
I have the code below for calcute Mann-Kendall test. this code only works for a vector but i would like to apply it on a matrix with 40*5260
when i try to do it for an example like a 40*10 i don't get error but only give me one H nad p-value, rather than 10 H, p-value.
sorry it might be simple but i'm not good in Matlab yet
could you please help.
thanks in advance
function[H,p_value]=Mann_Kendall(V,alpha) %% alpha can be 0.05
V=reshape(V,size(V),1);
alpha = alpha/2; %
n=length(V);
i=0; j=0; S=0;
for i=1:n-1
for j= i+1:n
S= S + sign(V(j)-V(i));
end
end
VarS=(n*(n-1)*(2*n+5))/18;
StdS=sqrt(VarS);
%%%% Note: ties are not considered
if S >= 0
Z=((S-1)/StdS)*(S~=0);
else
Z=(S+1)/StdS;
end
p_value=2*(1-normcdf(abs(Z),0,1)); %% Two-tailed test
pz=norminv(1-alpha,0,1);
H=abs(Z)>pz; %%
return
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Hypothesis Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!