How to do ANOVA repeated measures?
Show older comments

I have 12 Female and 11 Male rats which participate in a sucrose tracking experiment for 4 different levels of sucrose concentration. I have approach rate data (between 0 and 1) for each animal for 4 different concentration. I have attached the figure. I want to do ANOVA repeated measures for the experiment to check the effect of concentration as well as gender. I wrote this following code. But I'm not sure if this is correct or how to interpret the result.
dataForFemale = loadFile.featureForEachSubjectId{1};
dataForMale = loadFile.featureForEachSubjectId{2};
for i = 1:4
dataMatrix(:,i) = [dataForFemale{i} dataForMale{i}]';
end
Gender = [repmat({'F'},1,length(dataForFemale{1})),repmat({'M'},1,length(dataForMale{1}))]';
t = [Gender, array2table(dataMatrix)];
t.Properties.VariableNames = {'Gender','c1','c2','c3','c4'};
rm = fitrm(t, 'c1-c4 ~ Gender', 'WithinDesign', table([1, 2, 3, 4]','VariableNames', {'Concentration'}));
result = ranova(rm);
multcompare(rm, 'Concentration', 'By', 'Gender');
3 Comments
Scott MacKenzie
on 30 Apr 2023
Edited: Scott MacKenzie
on 30 Apr 2023
Your ANOVA code is correct.
Bear in mind that you have a mixed design with one within-subjects factor (concentration with four levels) and one between-subjects factor (gender with two levels). The "repeated-measures" aspect of the ANOVA only pertains to concentration.
Atanu
on 1 May 2023
Scott MacKenzie
on 1 May 2023
Edited: Scott MacKenzie
on 1 May 2023
You're welcome. I just had another look and notice that you omitted the within-subjects IV (sucrose concentration) in the ranova function. I've added it, rearranged the code slightly, and posted an answer. Hope this helps.
Accepted Answer
More Answers (0)
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
