Problem using ttest and signrank functions

2 Ansichten (letzte 30 Tage)
Eric
Eric am 22 Sep. 2014
Kommentiert: José-Luis am 22 Sep. 2014
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 Kommentar
Eric
Eric am 22 Sep. 2014
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

José-Luis
José-Luis am 22 Sep. 2014
[p, h, stats] = signrank(squeeze(post), squeeze(pre), 'alpha', pval);
  2 Kommentare
Eric
Eric am 22 Sep. 2014
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 am 22 Sep. 2014
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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics and Visualization 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!

Translated by