N-way ANOVA wrong results
Mostrar comentarios más antiguos
Hi everyone,
I am doing some statistics functions in Matlab and checking them in SPSS. I am doing N-way ANOVA in Matlab, but it gives me wrong results comparing it to SPSS. As you can see later, the results completely differ, they are not even close. This is my code (I am showing you the brief version of the data to show what is going on):
connection= [0.3950; 0.3774; 0.0622; 0.0140; 0.1424; 0.1029; 0.1711; ...
0.1595; 0.0774; 0.0111];
abstinence=[12;6;8;11;14;6;3;6;3;4];
relapse=[0;1;2;0;1;1;3;0;1;0];
[~,tbl]=anovan(connection,{abstinence, relapse},'display','on','model','full',...
'varnames',{'Abstinence','Relapse'}, 'continuous',[1,2]);
I am doing it to be full interaction and with continuous predictors, the same as in SPSS. And this gives me this results in Matlab:
Source Sum Sq. d.f. Mean Sq. F Prob>F
----------------------------------------------------------------
Abstinence 0.02207 1 0.02207 0.93 0.3714
Relapse 0.01428 1 0.01428 0.6 0.4667
Abstinence*Relapse 0.01587 1 0.01587 0.67 0.4441
Error 0.14196 6 0.02366
Total 0.1653 9
And in SPSS (sorry it is in Spanish: Abstinencia is Abstinence and Recaidas is Relapse, just in case):

I don't know why this is happening or if I am doing something wrong. Besides, I have changed 'model' to 'interaction' and it does not work either. Please any help is welcomed!
Thanks in advanced.
Respuesta aceptada
Más respuestas (1)
Jeff Miller
el 4 de Jun. de 2019
0 votos
The SPSS output does not match up with the data that you posted, so maybe you should check that analysis first. For your connection values, these are the correct SS & df Total values, as produced by MATLAB: 0.1653 9. Since those numbers don't appear in the SPSS output table, I am wondering whether VAR00005 is some other variable. Even if the programs were fitting slightly different models, MATLAB's SS total and SPSS's Total corrigedo should be identical if the data values were the same.
6 comentarios
Elsa Martinez
el 4 de Jun. de 2019
John TS
el 3 de Mayo de 2020
I am actually having the same problem. In my case flow rate was a treatment with 3 levels that I tuned during experiments to 10, 15 and 20 l/min.
Here, flow rate is a continuous (random factor) instead of a fixed factor, since the magnitude of the values have order. Both Matlab and SPSS are set to Type III Sum of Squares...Matlab gives the degrees of freedom for flow rate as 1; and SPSS gives 2...Can someone explain this difference. When I make flow rate a fixed factor in both software packages I get the same result, i.e. SPSS and Matlab agree with the same significance and both having d.f. = 2 for flow rate.

Jeff Miller
el 3 de Mayo de 2020
Matlab often treats numerical variables as linear predictor covariates. Hence it gives them only 1 df, corresponding to the slope of the dependent variable against the predictor. I suspect that is what is going on with your flow rate variable.
John TS
el 5 de Mayo de 2020
Jeff Miller, Thanks for the response...makes sense. Maybe improving the documentation on 'continuous' in N-way ANOVA would help. For now I have to rely on SPSS to confirm the Matlab stats results. Also having different results when using kstest() in Matlab for normality, compared to SPSS.
@John TS you could go to the anovan page of the online documentation and scroll to the very bottom where you can give that page a star-rating and after that you have the opportunity to type suggestions for improvement to the documentation. The doc team will get that feedback.
@Jeff Miller , thanks for answering stats questions and offering great advice. Not many contributors here take on the stats questions.
Jeff Miller
el 5 de Mayo de 2020
Thanks, Adam, I appreciate the feedback.
Categorías
Más información sobre Analysis of Variance and Covariance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
