Why is my Mixed ANOVA including the intercept as an interaction term?
7 views (last 30 days)
Show older comments
Hi there,
I have been getting different outputs from Matlab to JASP and SPSS, both of which agree that Matlab is wrong, which I think is due to the intercept being included as an interaction term in the model spec.
I have run a 2b*6w*2w Mixed ANOVA in Matlab. (Between-2=Consciousness, Within-6 = Conguency, Within-2 =Target) However I am getting the intercept as an interaction term in my ranova table:
Matlab Output
The factors Congruency and Target should be reported only as a main effects, not as an interaction with the intercept.
I'm including a JASP output so to compare the difference between the two softwares.
Could you take a look at my code, I think I've done something wrong in the Wilkinson notation of the model specification, and tell me how I stop it using the intercept as an interaction term.
OverallDataTable=readtable('Data.xlsx')
WithinDesign=table(categorical({'Related Hand','Related Foot','Unrelated Hand','Unrelated Foot', ...
'Neutral Hand','Neutral Foot','Related Hand','Related Foot','Unrelated Hand','Unrelated Foot', ...
'Neutral Hand','Neutral Foot'}'),categorical({'BP','BP','BP','BP','BP','BP','O','O','O','O','O','O'}'), ...
'VariableNames',{'Congruency','Target'});
OverallMixedANOVA=fitrm(OverallDataTable,'BP_RH_Con-O_NF_Sub~Consciousness',WithinDesign=WithinDesign);
OverallMixedANOVATable=ranova(OverallMixedANOVA,"WithinModel",'Congruency*Target')
Thanks for any and all advice
Dan
0 Comments
Accepted Answer
Jeff Miller
on 31 Aug 2024
I think you need
OverallDataTable.Consciousness = categorical(OverallDataTable.Consciousness);
2 Comments
Adam Danz
on 5 Sep 2024
Edited: Adam Danz
on 16 Sep 2024
The doc page for fitrm states that "fitrm treats the variables used in model terms as categorical if they are categorical (nominal or ordinal), logical, character arrays, string arrays, or cell arrays of character vectors". I am just now realizing that the Consciousness variable is double, not logical.
Another solution would be to set Consciousness to logical.
More Answers (1)
Adam Danz
on 30 Aug 2024
You can remove the interaction term by including "-1" in the model spec (doc). I also included terms for Congruency and Target in the WithinModel so the table rows match the JASP version.
format longg
% No change here
OverallDataTable=readtable('Data.xlsx')
WithinDesign=table(categorical({'Related Hand','Related Foot','Unrelated Hand','Unrelated Foot', ...
'Neutral Hand','Neutral Foot','Related Hand','Related Foot','Unrelated Hand','Unrelated Foot', ...
'Neutral Hand','Neutral Foot'}'),categorical({'BP','BP','BP','BP','BP','BP','O','O','O','O','O','O'}'), ...
'VariableNames',{'Congruency','Target'})
OverallMixedANOVA=fitrm(OverallDataTable,'BP_RH_Con-O_NF_Sub~Consciousness',WithinDesign=WithinDesign);
%% New WithinModel spec
OverallMixedANOVATable=ranova(OverallMixedANOVA,"WithinModel",'Congruency+Target+Congruency*Target-1')
Comparing these results with your MATLAB table screen shot does not indicate that removing the main intercept term made a difference for the other terms. I also noticed that data in rows 1, 4, and 7 above do not match the JASP table but the other rows do match. I'm not familiar with JASP but I did see that they may have recently changed thier default ANOVA methods (JASP doc).
Make sure you're using the same alpha value (0.05) in both cases.
Your data does not contain any missing data (NaNs) so that rules out the possibilty that treatment of missing data differs.
I noticed that the JASP table warns against sphericity assumption violations which makes me wonder if any corrections are being applied in JASP (e.g. Greenhouse-Geisser or Huynh-Feldt adjustments).
There's a possibilty that sum of squares is calucated differently but I would expect that to affect all SumSq values, not just select rows.
Lastly, there could be differences in how the overall mixed ANOVA model was specified.
Unfortunately I don't have time to dig further but I would chose one of the rows that have conflicting results and compute the SumSq to make sense of it.
I plotted the data as a sanity check.
M = table2array(OverallDataTable);
boxchart(M(:,2:end-1))
xline(6.5) % separate conscious and subc. groups
See Also
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!