Three-way repeated-measures ANOVA with no between-factor

22 次查看(过去 30 天)
I have always shied away from using fitrm and ranova in MATLAB, because somehow I never understood how it worked. As a result, I would parse the data and perform the analysis on SPSS, but now I have no access to it, so it is hopefully time I learn how to do it.
For context, I have data from a study with faces. Participants were shown faces of two genders, smile or no smile and region. All the independent variables have 2 levels. These have been tested via three metrics, let's call them I, N, and C. There is no between-subjects factor, so I have taken the advice of other answers and used:
formula = 'I,N,C~1';
What I am unable to figure out:
Assume we have:
t = table(gender, smile, region, I, N C,...
'VariableNames',{'Gender', 'Smile', 'Region', 'I', 'N', 'C'});
formula = 'I,N,C ~ 1';
How do we construct the within matrix? I do not understand how the table is supposed to be constructed:
withinMatrix = table([1 1 2]', [1 2 2]', VariableNames={'g','a'});
rm = fitrm(t, formula, WithinDesign=withinMatrix);
result = ranova(rm);
phoc = multcompare(rm, 'Gender', 'By', 'Smile');
The above is just an example. What I don't get is what those vectors in the withinMatrix represent and what the associated variable names are supposed to represent ('g' and 'a').
Another thing that I'm failing to get is, once we include just the intercept, where do we view the main effects? The result from ranova (I guess justifiably), does not show them.
My goal is to run a repeated-measures ANOVA, test for effects and interactions amongst all factors and then perform multcompare for post-hoc comparisons. Even multcompare is obscure to me. I have seen answers including placeholders such as
'Factor1', 'By', 'Factor2'
, as demonstrated in the multcompare above, which appears to be undocumented - forgive me if I'm incorrectly surmising this. I understand that Factor1 and Factor2 are to be replaced with the independent variables fed into the model. Is there anything other than 'By', for example? The resulting table from multcompare shows the output with the two comparisons, yet I do not understand which dependent variable they correspond to: all of them collectively? This assumes that all I, N, and C are added to the model.
My questions are not bound to data, but I'll be happy to provide a sample if needed.
Thank you in advance!
  2 个评论
Jeff Miller
Jeff Miller 2024-1-24
From your description of the data table, it looks like you have 8 rows per participant (with the various combinations of the 2x2x2 design). fitrm and ranova want (I think) one row per participant, with the various conditions (and, in your case DVs) spread out across multiple columns. withinMatrix then indicates the factor levels for each of the different columns.
Maybe this 2x2 within example will help: link
LM_BU
LM_BU 2024-1-25
Hi Jeff, thank you for your reply.
Just to makle sure we're on the same page regarding the format of the data.
I have an original matrix of 30x600. The columns correspond to the rating each question the participants were asked, whereas the 30 rows represent the participants.
With the guidance from your reply and given the three within-subject independent variables, i.e., Smile, Gender, and Region, I take the mean(:, 2) of this matrix, given filtered searches for each factor (e.g., data(:, strcmp(gender,'Female'))) creating 6 variables (2 levels per condition, as it is a 2x2x2 design as you pointed out) of size 30x1. For now, let us assume I have 1 dependent variable, called "C", even though the 600 entries contain data for the remaining two dependent variables, i.e., "N" and "I".
Next, I create the table for the withindesign:
withinMatrix = table([1 2 1 2 1 2 1 2]', [1 1 2 2 1 1 2 2]',...
[1 1 1 1 2 2 2 2]', 'VariableNames', {'Gender', 'Smile' ,'Region'});
Using fullfact ([2 2 2]), it results in 8 combinations. Yet, when I'm fitting the above to rm, MATLAB throws an error indicating that "Specified design has 8 points; 6 required.". Which combination(s) am I supposed to get rid of?
On a side note, I dread to think the next multcompare stage that requires specific handling for interactions, as I've seen on the forums.

请先登录,再进行评论。

采纳的回答

Jeff Miller
Jeff Miller 2024-1-25
It sounds like you are almost there but this isn't right: "given filtered searches for each factor (e.g., data(:, strcmp(gender,'Female'))) creating 6 variables"
You need to create 8 variables--one for each combination of levels across the three factors--so you need 8 means, each computed something more like this:
data(:, strcmp(gender,'Female') & strcmp(region,'South') & strcmp(smile,'Happy') )
And, the order of these 8 variables has to match with the labels you specified in withinMatrix. For example, your withinMatrix shows that the first four variables are for one region and the last 4 are for the other region; within each region, the first two variables are for smile1 and the next two are for smile2; and the genders are strictly alternating variables.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Repeated Measures and MANOVA 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by