phill.short
phill.short

Reputation: 1

Multiple comparison for repeated measures ANOVA in matlab

I want to find possible differences between different conditions. I have n subjects for which I have a mean value for every condition for every subject respectively. The values between subjects vary a lot, that's why I wanted to perform a repeated measures anova to control for that.

My within subject factor would be the condition then and I don't have any between subjects factor.

So far I have the following code:
%% create simulated numbers
meanPerf = randn(20,3);

%% create a table array with the mean performance for every condition

tableData = table(meanPerf(:,1),meanPerf(:,2),meanPerf(:,3),'VariableNames',{'meanPerf1','meanPerf2','meanPerf3'})

tableInfo = table([1,2,3]','VariableNames',{'Conditions'})

%% fit repeated measures model to the table data
repMeasModel = fitrm(tableData,'meanPerf1meanPerf3~1','WithinDesign',tableInfo);

%% perform repeated measures anova to check for differences
ranovaTable = ranova(repMeasModel)

My first question is: Am I doing this correctly?

The second question is: How can I perform a post hoc analysis to find out which of the condition are significantly different from each other?

I tried using:

multcompare(ranovaTable,'Conditions');

but that produced the following error:

Error using internal.stats.parseArgs (line 42)
Wrong number of arguments.

I am using Matlab 2015b.

Would be great if you could help me out. I think I'm loosing my mind over this.

Best, Phill

Upvotes: 0

Views: 3683

Answers (1)

Francesco
Francesco

Reputation: 1

I was trying the same thing using Matlab R2016a, and I get the following multcompare error message: "STATS must be a stats output structure from ANOVA1, ANOVA2, ANOVAN, AOCTOOL, KRUSKALWALLIS, or FRIEDMAN.".

However, this discussion was helpful for me: https://www.mathworks.com/matlabcentral/answers/140799-3-way-repeated-measures-anova-pairwise-comparisons-using-multcompare

You might try something like: multcompare(repMeasModel,'Factor1','By','Factor2)

I believe you'll need to create factors in the within structure of your model too.

Upvotes: 0

Related Questions