How to test for a main effect of the between subjects-variable with fitrm and ranova?

22 visualizaciones (últimos 30 días)
I am using fitrm to do a two-way repeated measures ANOVA on EEG data from children. The within-subject (repated measures) variable is sleep (i.e., whether the child is awake or asleep during the EEG), and the between-subject variable is group (whether the child is in a clinical group or a healthy control group). I want to test for main effects of both sleep and group on my EEG measure, and also a group x sleep interaction. Obviously, I need to run a repeated-measures model, given that sleep is a within-subject measure. But, I also want to test for a main effect of my between subjects measure (group), and that is what I am having difficulty returning.
Right now, my code looks like this,
rm = fitrm(T_mse,'Awake-Asleep ~ Group','WithinDesign',Sleep);
ranovatbl = ranova(rm)
where T_mse is a 3-column table containing the EEG measure of interest, in which the first column (Group) contains the coded group labels (0 or 1), the second column (Awake) contains the EEG values for the awake condition, and the third column (Asleep) contains the EEG values for the asleep condition. So, I call fitrm and then plug the output into ranova to get a table with the following rows: (Intercept):Sleep, Group:Sleep, Error(Sleep). Ok great, now I have the main effect of Sleep and the Sleep x Group interaction, but, I also want to look for a main effect of Group. Can I do this without calling a separate function? Of course, if I call anovan, I can get the main effects of Group and Sleep and their interaction, but then this completely disregards the fact that Sleep is within-subject. To make my code more efficient, I'd prefer to just get everything by calling fitrm and ranova, is this possible?

Respuestas (1)

Jeff Miller
Jeff Miller el 30 de Mayo de 2020
% Define the within-Ss factor and give it a name. The 1 & 2 refer to Awake / Asleep
WithinStructure = table([1 2]','VariableNames',{'Sleep'});
% Tell fitrm about the within design & factor
rm = fitrm(datatable, 'Awake-Asleep ~ Group','WithinDesign',WithinStructure,'WithinModel','Sleep');
% Specify the repeated-measure factor again when you call ranova:
ranovatable = ranova(rm,'WithinModel','Sleep');

Community Treasure Hunt

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

Start Hunting!

Translated by