Repeated-Measures ANOVA across several conditions rather than timepoints

11 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Jeff Miller
Jeff Miller el 17 de Mzo. de 2021
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 comentarios
Jeff Miller
Jeff Miller el 18 de Mzo. de 2021
Oh, sorry, I always forget that by default fitrm interprets numbers as numerical covariates rather than discrete group indicators. I think you need to use the 'categorical' command like this:
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'});
WithinStructure.Contrast = categorical(WithinStructure.Contrast);
% and the same for .Value and .LR
% and then fitrm, etc
I think this will give you the correct df for Contrast and its interactions (2) and for the error terms involving contrast (8), and hopefully then also match the CallMrf output.
You can't see anything in the CallMrf source--it just calls the exe file for an old Pascal ANOVA program that does all the actual computations.
Emma Bailey
Emma Bailey el 19 de Mzo. de 2021
That worked perfectly I get the exact same as your table now - thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by