# Repeated-Measures ANOVA across several conditions rather than timepoints

조회 수: 9(최근 30일)
Emma Bailey 2021년 3월 17일
댓글: Emma Bailey 2021년 3월 19일
So I have a table T (attached), which has the SSVEP amplitude in the first column, the subject number in the second, then the contrast condition (3rd), value condition(4th) and left/right(5th).
As there are multiple permutations of contrast/value/LR for each subject, I've been trying to do a repeated-measures ANOVA with fitrm and ranova, but I'm running into issues and I don't really understand. Even for the most basic model type I can think of:
rm = fitrm(T,'SSVEP ~ Contrast+Value+LR+Contrast*Value');
ranovatbl = ranova(rm)
I get the following output:
which is clearly incorrect!
From the few examples I have seen online (https://uk.mathworks.com/help/stats/fitrm.html#bt9ol4i-4), there always seems to be multiple measurements at different time points - but as in this repeated measures design, I have multiple conditions rather than multiple timepoints, I'm really pulling up blanks! I am also aware that I should probably be using ranovatbl = ranova(rm,'WithinModel',WM), but I have had absolutely zero success specifying this WM component!
Any help would be amazing!

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

### 채택된 답변

Jeff Miller 2021년 3월 17일
fitrm wants all the data for a single subject to be on a single row of the data table. In your case, that would mean a table newT with 5 rows for the 5 Ss and 12 columns for the 12 measurements. Assuming you arrange those 12 columns in the same order as you have your 12 rows for a single subject, you will then need something like this (unchecked):
WithinStructure = table([1 1 2 2 3 3 1 1 2 2 3 3]',[1 2 1 2 1 2 1 2 1 2 1 2]',[1 1 1 1 1 1 2 2 2 2 2 2]',...
'VariableNames',{'Contrast','Value','LR'});
% In the next line, '~1' indicates that there are no between-Ss factors.
rm = fitrm(newT,'col1-col12~1','WithinDesign',WithinStructure,'WithinModel','Contrast*Value*LR');
% You need to specify the repeated-measures factors again when you call ranova, like this:
ranovatable = ranova(rm,'WithinModel','1+Contrast*Value*LR');
In the end, you should get this ANOVA table:
% ANOVA For SSVEP
% Source df MS dfe MSe F pEta^2 P G-G P
% Mean 1 149753159.5 4 12048871.8 12.429 0.757 0.024 **
% LR 1 4966893.5 4 1497203.7 3.3174 0.453 0.143
% Value 1 207.69 4 148015.6 0.00140 0.000 0.972 ??
% LV 1 887505.6 4 150990.3 5.8779 0.595 0.072 *
% Contrast 2 32735265.9 8 3094230.4 10.579 0.726 0.006 0.031 ***
% LC 2 101685.4 8 73574.7 1.3821 0.257 0.305 0.307
% VC 2 58550.9 8 162855.5 0.35953 0.082 0.709 0.621
% LVC 2 59769.2 8 104015.9 0.57462 0.126 0.585 0.582
By the way, that anova table was computed from your original table format (which I prefer) with the command
CallMrf(T,'SSVEP',{},{'Contrast','Value','LR'},'Subject','outFileName')
from RawRT
I hope that helps you.
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
Emma Bailey 2021년 3월 19일
That worked perfectly I get the exact same as your table now - thank you so much!

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

### Community Treasure Hunt

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

Start Hunting!

Translated by