How can i understand the within and between model factors of a mixed model ANOVA

7 Ansichten (letzte 30 Tage)
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
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).
Julian Ostertag
Julian Ostertag am 19 Apr. 2024
Bearbeitet: Julian Ostertag am 19 Apr. 2024
Hi Jeff,
thank you for your answer. I know what you mean, and it may be the better way of organizing the data. I just have one concern regarding the naming of the columns. It would be something like:
"Group", "Left1", "Left2","Left3", "Right1", "Right2","Right3", "Front1", "Front2","Front3"
But then how would I be able to have time and location as separate factors, since in that data setup I cannot specify the timepoint specifically? Or is this then something that can be accounted for in the withinDesign?
Thats why in my setup I basically defined a new row to accoount for the different locations and a new column to account for the different timepoints. Another option I was thinking about would be to have a third column named "Timepoint" which is then a 1,2 or 3 and then subsequently only have one column for the data. But certainly, I would also like to understand your idea better, since it can for sure be also organized in that way. I just want to tell you my concern before doing so.
Best
Julian

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jeff Miller
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)

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by