Why am I getting different outputs between Matlab & SPSS?

조회 수: 6 (최근 30일)
Dan
Dan 2024년 8월 23일
답변: Dan 2024년 8월 31일
I am running a 3-way mixed ANOVA (2*6*2).
The between variable is Consciousness with 2 levels (conscious/ subconscious)
The within variables are: Congruency with 6 levels (RH, RF, UH, UF, NH, NF) & Target with 2 levels (BodyPart, Object).
I have run this in Matlab and had assumed I had generated the correct output, Code:
%Within Design Table
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'});
%%
%3-Way Mixed Anova
OverallMixedANOVA=fitrm(OverallDataTable,'BP_RH_Con-O_NF_Sub~Consciousness',WithinDesign=WithinDesign,WithinModel='separatemeans');
%Sphericity Calculation & Error Correction
OverallSphericity=mauchly(OverallMixedANOVA)
OverallErrorCorrect=epsilon(OverallMixedANOVA)
%Anova Table output
[OverallMixedANOVATable,A,C,D]=ranova(OverallMixedANOVA,"WithinModel",'Congruency*Target')
%Corrections for significant sphericity
%CorrectedOverallMixedANOVATable=OverallMixedANOVATable;
%CorrectedOverallMixedANOVATable.DF=OverallMixedANOVATable.DF*OverallErrorCorrect.GreenhouseGeisser
Below is the Matlab Output:
The same data was used in SPSS to check my code. For all previous (2-way RM-) ANOVAs I have performed on Matlab the output has been the same, but in this case the output was different.
Here is the SPSS code pasted to the log:
GLM BP_RH O_RH BP_RF O_RF BP_UH O_UH BP_UF O_UF BP_NH O_NH BP_NF O_NF BY Consciousness
/WSFACTOR=Congruency 6 Polynomial Target 2 Polynomial
/MEASURE=Tradeoff
/METHOD=SSTYPE(3)
/PRINT=DESCRIPTIVE ETASQ OPOWER HOMOGENEITY
/CRITERIA=ALPHA(.05)
/WSDESIGN=Congruency Target Congruency*Target
/DESIGN=Consciousness.
Output from SPSS pasted below:
Different values are highlighted in blue.
I'd like to know why I am getting different values. I know that the p values are still signficant for both methods of analysis, but when looking for replicability this doesnt seem to be satisfactory.
My Questions are:
Have I input the factors correctly in the Matlab code?
Why are the values different between the two softwares?
Does it matter that Matlab and SPSS generate different statistics?
Do you have any reccomendations for what I can do to improve my code?
Thanks in advance
*Edit 1, Ive uploaded the data if anyone wants to have a look.
** PS, I ran the same analyiss using JASP and generated the same output as SPSS.
  댓글 수: 4
dpb
dpb 2024년 8월 23일
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,WithinModel='separatemeans');
Unrecognized function or variable 'OverallDataTable'.
Dan
Dan 2024년 8월 27일
Sorry for the late reply, I didn't understand what you ment by this to begin with.
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)
%Here is the actual ANOVA command
[OverallMixedANOVATable,A,C,D]=ranova(OverallMixedANOVA,"WithinModel",'Congruency*Target')
This should fit the model, but it is still generating results different to those generated by JASP & SPSS. Any ideas?

댓글을 달려면 로그인하십시오.

채택된 답변

Dan
Dan 2024년 8월 31일
Just marking this as solved
Conscious needed to be a categorical array
OverallDataTable.Consciousness=categorical(OverallDataTable.Consciousness)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Analysis of Variance and Covariance에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by