How to use ranksum with splitapply?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everybody!
I just started with Matllab last week. I am trying to use the ranksum function with splitapply in order to get the p-value for my 2 different groups, but it is not working. Basically I have an excel file where the first column has a set of on/off parameters and on the 18th column I have the values I want to analyse. I want to get the p-value between on and off values (see below)
Column 1 Column 18
ON 4.3
OFF 7.2
OFF 5.6
ON 8.9
OFF 3.7
(etc) (etc)
I want to get the p-value between datasets [4.3, 8.9] and [7.2 , 5.6 , 3.7], any idea on how to do this?
Thanks in advance!
[num,text,raw]=xlsread('d1_m2_filipa.xlsx');
i=text(:,1);
o=[1:length(y)];
w=[2:length(i)];
k=text(w,1);
y=num(:,18);
grpNums=findgroups(k);
q=splitapply(@mean,y,grpNums);
err=splitapply(@std,y,grpNums);
d=splitapply(@jbtest,y,grpNums);
e=0;
if d==0
e=splitapply(@ranksum,y,grpNums)
else e=0
end
0 Commenti
Risposte (1)
Asvin Kumar
il 29 Ott 2019
The splitapply function applies the function mentioned as an argument to each group. For the ranksum function we would need to provide two sets of data. We can provide these by partitioning the data using findgroups.
You can use the following code for reference and adapt it to your use case:
[grpNums, grps] = findgroups(k);
off = y(k==grps(1));
on = y(k==grps(2));
[p,h] = ranksum(on,off);
Here’s the documentation of findgroups for reference:
0 Commenti
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!