How can i understand the within and between model factors of a mixed model ANOVA
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Julian Ostertag
am 17 Apr. 2024
Kommentiert: Julian Ostertag
am 19 Apr. 2024
Hi everyone,
I am trying to run a mixed model ANOVA and struggle to define the within and between subject terms of the fitrm function.
Data description:
Lets say I have temerature data from 3 timepoints (10min, 30min and 60min) and three locations (left ear, right ear, forehead), additionally I have two groups (1,0) where group 1 gets a treatment and group 0 not. I want to run a mixed model ANOVA to see whether or not there are effects over time, i.e. does the temperature decrease, increase or stay the same. Simultaneously I want to see whether this is dependant on the group, i.e. does it matter if I am getting the treatment as well as the location that the measurement comes from, i.e. does it matter where am I measuring. In my heaad a mixed model ANOVA was teh right way to do so. I have created a dataset that should replicate the type of data I have and attached the file.
I have troubles wrapping my head around the within and between factors and how to specify them. At the moment my model runs with this specification:
withinFactors = 1:3; % 1,2,3 for Meas1, Meas2 and Meas3
% Define the model formula
modelFormula = 'Meas1-Meas3 ~ Group:Location';
% Fit mixed-design ANOVA model
rmModel = fitrm(data_tbl, modelFormula, 'WithinDesign', withinFactors);
And I get a decent output with it. However my struggel is that I would like to have the Location Variable as a withinFactor and I do not know how to handle this, at least it does not appear very intuitively. I have tried to understand the matlab examples where two withinfactors are supplied, but I simply cannot transfer it to my code since I do not understand what going on. Any help would be much appreciated.
I hope the data supplied is sufficient, if you need anything else, pleas elet me know.
2 Kommentare
Jeff Miller
am 19 Apr. 2024
I don't understand how the data_tbl created by your attached script matches up with the design you describe. For example, the different locations appear in different rows of data_tbl, which makes it look like location is a between factor rather than a within factor.
From your data description I was expecting 9 data points per row of data_tbl (3 time points x 3 locations, both within), with one row per subject (different rows labelled 1 or 0 to indicate group).
Akzeptierte Antwort
Jeff Miller
am 19 Apr. 2024
Yes, this is something that can be accounted for using withinDesign. See https://au.mathworks.com/matlabcentral/answers/467222-ranova-with-two-within-factors for an example. After you rearrange your data to have 9 data columns per subject, I think you will want something like this:
WithinStructure = table([1 1 1 2 2 2 3 3 3]',[1 2 3 1 2 3 1 2 3]','VariableNames',{'Location','TimePoint'});
WithinStructure.TimePoint = categorical(WithinStructure.TimePoint); % probably you want this
WithinStructure.Location = categorical(WithinStructure.Location); % probably you want this
rm = fitrm(data_tbl,'Left1,Left2,Left3,Right1,Right2,Right3,Front1,Front2,Front3~Group','WithinDesign',WithinStructure,'WithinModel','Location*TimePoint');
ranovatable = ranova(rm,'WithinModel','Group*Location*TimePoint');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Repeated Measures and MANOVA finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!