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
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
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Repeated Measures and MANOVA 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!