Problem using ttest and signrank functions

3 次查看(过去 30 天)
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 中查找有关 Descriptive Statistics and Visualization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by