Code correct? - signrank testing
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi.
I want to compare two conditions of my dataset using the signrank function (data distribution is not normal). The data ("outputmatrix2") is threedimensional (pixels-timesteps-conditions) and unwanted pixels are set to NaN- which would be all but approximately 80.
Unfortunately, in almost every timestep, I get significant differences between the two conditions, even before stimulus onset (see attached image, "0" on x-axis is stimulus onset, an asterisk above the 2 graphs indicates significance with p<0.05).
I wonder, if my- pretty primitive- code is correct? Or maybe anyone has any other suggestions? Thx!
% settings
from_plot = -20; to_plot = 200;
condA = [19];
condB = [23];
clear cond2b cond1b A A2 A3 B B2 B3 AAA AA C D AAA2 D2 C2 AA2 p2 indeks2
% get rid of NaNs
A = nanmean(outputmatrix2(:,:,condA),3);
for j=1:size(outputmatrix2,2) %frames
A2 = A(:,j);
A2 = A2(A2==A2);
A3 (:,j) = A2;
end
B = nanmean(outputmatrix2(:,:,condB),3);
for j=1:size(outputmatrix2,2)%frames
B2 = B(:,j);
B2 = B2(B2==B2);
B3 (:,j) = B2;
end
% testing
for jj=1:size(A3,2)
[p2(1,jj),h2(1,jj)]=signrank(A3(:,jj),B3(:,jj));
end
% create fancy asterisk-plot for significance
indeks2 = find(p2<0.05);
AAA2(1,:)=nanmean(A3,1);
AAA2(2,:)=nanmean(B3,1);
AA2=nanmax(AAA2,[],1)+0.0001;
C2=zeros(size(AA2)); C2(indeks2)=1;
D2=AA2.*C2; D2(D2==0)=NaN;
% errorbar
A3std = nanstd(A3);
B3std = nanstd(B3);
D2 = D2+max([A3std; B3std]);
% plot
ff=figure;
hold on;
plot1 = plot(from_plot:10:to_plot,nanmean(A3(:,18:40),1),'o-','Linewidth',3,'markersize',4,'Color','green');
errorbar(from_plot:10:to_plot,nanmean(A3(:,18:40),1),A3std(:,18:40),'ko-','Linewidth',2,'markersize',4,'Color','green'); hold on;
plot2 = plot(from_plot:10:to_plot,nanmean(B3(:,18:40),1),'ro-','Linewidth',3,'markersize',4,'Color','black');
errorbar(from_plot:10:to_plot,nanmean(B3(:,18:40),1),B3std(:,18:40),'ro-','Linewidth',2,'Color','black');
plot(from_plot:10:to_plot,D2(:,18:40),'k*','markersize',8,'LineWidth',1)
plot(from_plot:10:to_plot,zeros(1,23),'k--')
set(gca,'Fontsize',14,'XGrid','on','XLim',[from_plot to_plot])
plot3 = [plot1,plot2];
LE = legend(plot3,{'cond_A'; 'cond_B'});
set(LE,'Interpreter','none','Fontsize',16)
set(gcf,'PaperPositionMode','auto')
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Hypothesis Tests finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!