Problem using ttest and signrank functions

조회 수: 9 (최근 30일)
Eric
Eric 2014년 9월 22일
댓글: José-Luis 2014년 9월 22일
I'm trying to use the ttest and the signrank functions but they don't work.
When using the ttest function it says:
Undefined function or variable 't'.
Error in nanmean (line 7) N = sum(~isnan(t), dim);
Error in ttest (line 131) xmean = nanmean(x,dim);
and for the signrank it says:
Error using signrank (line 95) SIGNRANK requires vector rather than matrix data.
I have the following toolboxes installed: MATLAB Version 8.2 (R2013b) Signal Processing Toolbox Version 6.20 (R2013b) Statistical Parametric Mapping Version 5236 (SPM8) Statistics Toolbox Version 8.3 (R2013b)
Thank you very much in advance.
  댓글 수: 1
Eric
Eric 2014년 9월 22일
Sorry about that. Here is the code for performing the Wilcoxon Signed-Rank Test on EEG data:
pval = 0.05
all = Alphapower;
dataalpha1 = all(1:3,:,:);
dataalpha2 = all(4:6,:,:);
for channel = 1:19
pre = dataalpha1(:,1,channel);
post = dataalpha2(:,2,channel);
[p, h, stats] = signrank(post, pre, 'alpha', pval);
end

댓글을 달려면 로그인하십시오.

채택된 답변

José-Luis
José-Luis 2014년 9월 22일
[p, h, stats] = signrank(squeeze(post), squeeze(pre), 'alpha', pval);
  댓글 수: 2
Eric
Eric 2014년 9월 22일
Thank you for the answer. But does this return values from comparisons for each column (like channel 1 pre compared to channel 1 post)?
José-Luis
José-Luis 2014년 9월 22일
No, your code was not working because dataalpha1 and dataalpha2 were not vectors but matrices of size [: 1 1]. Squeeze() just makes them a vector array, which is what the function is expecting. You could also do:
[p, h, stats] = signrank(post(:), pre(:), 'alpha', pval);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by